Allow setting qemu process name v2
Set the Linux process name to the name argument specified with name. I find this useful to see which guests are taking CPU time in top. This doesn't affect ps, which checks argv[0], but rewriting the environment uses much more code, so I only used this simple way. v2: Use separate process= argument, no prefixes. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
e3fc14c3a1
commit
1889465a1c
|
@ -363,12 +363,14 @@ Network adapter that supports CDC ethernet and RNDIS protocols.
|
||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
DEF("name", HAS_ARG, QEMU_OPTION_name,
|
DEF("name", HAS_ARG, QEMU_OPTION_name,
|
||||||
"-name string set the name of the guest\n")
|
"-name string1[,process=string2] set the name of the guest\n"
|
||||||
|
" string1 sets the window title and string2 the process name (on Linux)\n")
|
||||||
STEXI
|
STEXI
|
||||||
@item -name @var{name}
|
@item -name @var{name}
|
||||||
Sets the @var{name} of the guest.
|
Sets the @var{name} of the guest.
|
||||||
This name will be displayed in the SDL window caption.
|
This name will be displayed in the SDL window caption.
|
||||||
The @var{name} will also be used for the VNC server.
|
The @var{name} will also be used for the VNC server.
|
||||||
|
Also optionally set the top visible process name in Linux.
|
||||||
ETEXI
|
ETEXI
|
||||||
|
|
||||||
DEF("uuid", HAS_ARG, QEMU_OPTION_uuid,
|
DEF("uuid", HAS_ARG, QEMU_OPTION_uuid,
|
||||||
|
|
29
vl.c
29
vl.c
|
@ -68,6 +68,7 @@
|
||||||
#include <pty.h>
|
#include <pty.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <linux/rtc.h>
|
#include <linux/rtc.h>
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
/* For the benefit of older linux systems which don't supply it,
|
/* For the benefit of older linux systems which don't supply it,
|
||||||
we use a local copy of hpet.h. */
|
we use a local copy of hpet.h. */
|
||||||
|
@ -300,6 +301,20 @@ void hw_error(const char *fmt, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_proc_name(const char *s)
|
||||||
|
{
|
||||||
|
#ifdef __linux__
|
||||||
|
char name[16];
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
|
name[sizeof(name) - 1] = 0;
|
||||||
|
strncpy(name, s, sizeof(name));
|
||||||
|
/* Could rewrite argv[0] too, but that's a bit more complicated.
|
||||||
|
This simple way is enough for `top'. */
|
||||||
|
prctl(PR_SET_NAME, name);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/***************/
|
/***************/
|
||||||
/* ballooning */
|
/* ballooning */
|
||||||
|
@ -5416,7 +5431,19 @@ int main(int argc, char **argv, char **envp)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case QEMU_OPTION_name:
|
case QEMU_OPTION_name:
|
||||||
qemu_name = optarg;
|
qemu_name = qemu_strdup(optarg);
|
||||||
|
{
|
||||||
|
char *p = strchr(qemu_name, ',');
|
||||||
|
if (p != NULL) {
|
||||||
|
*p++ = 0;
|
||||||
|
if (strncmp(p, "process=", 8)) {
|
||||||
|
fprintf(stderr, "Unknown subargument %s to -name", p);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
p += 8;
|
||||||
|
set_proc_name(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#if defined(TARGET_SPARC) || defined(TARGET_PPC)
|
#if defined(TARGET_SPARC) || defined(TARGET_PPC)
|
||||||
case QEMU_OPTION_prom_env:
|
case QEMU_OPTION_prom_env:
|
||||||
|
|
Loading…
Reference in New Issue