[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Allow setting qemu process name
From: |
Todd T. Fries |
Subject: |
Re: [Qemu-devel] [PATCH] Allow setting qemu process name |
Date: |
Thu, 23 Jul 2009 06:47:16 -0500 |
User-agent: |
Mutt/1.5.19 (2009-01-05) |
Penned by Andi Kleen on 20090701 11:32.52, we have:
|
| [this is a port of a old KVM userland patch I had; Avi back then suggested to
| submit it to qemu]
|
| 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.
|
| Signed-off-by: Andi Kleen <address@hidden>
|
| diff --git a/vl.c b/vl.c
| index 7b7489c..584c48e 100644
| --- a/vl.c
| +++ b/vl.c
| @@ -68,6 +68,7 @@
| #include <pty.h>
| #include <malloc.h>
| #include <linux/rtc.h>
| +#include <sys/prctl.h>
|
| /* For the benefit of older linux systems which don't supply it,
| we use a local copy of hpet.h. */
| @@ -526,6 +527,19 @@ void hw_error(const char *fmt, ...)
| va_end(ap);
| abort();
| }
| +
| +static void set_proc_name(const char *prefix, const char *s)
| +{
| +#ifdef __linux__
| + char name[16];
| + if (!s)
| + return;
| + /* Could rewrite argv[0] too, but that's a bit more complicated.
| + This simple way is enough for `top'. */
| + snprintf(name, sizeof name, "%s-%.10s", prefix, s);
| + prctl(PR_SET_NAME, name);
#elif defined(__OpenBSD__)
if (!s)
setproctitle("%s-%.10s", prefix, s);
| +#endif
| +}
|
| /***************/
| /* ballooning */
| @@ -6008,11 +6022,15 @@ int main(int argc, char **argv, char **envp)
| if (kvm_enabled()) {
| int ret;
|
| + set_proc_name("kvm", qemu_name);
| +
| ret = kvm_init(smp_cpus);
| if (ret < 0) {
| fprintf(stderr, "failed to initialize KVM\n");
| exit(1);
| }
| + } else {
| + set_proc_name("qemu", qemu_name);
| }
|
| if (monitor_device) {
| --
| address@hidden -- Speaking for myself only.
|
--
Todd Fries .. address@hidden
_____________________________________________
| \ 1.636.410.0632 (voice)
| Free Daemon Consulting, LLC \ 1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX)
| "..in support of free software solutions." \ sip:address@hidden
| \ sip:address@hidden
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A
http://todd.fries.net/pgp.txt
- Re: [Qemu-devel] [PATCH] Allow setting qemu process name, (continued)
Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Avi Kivity, 2009/07/01
- Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Luiz Capitulino, 2009/07/01
- Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Avi Kivity, 2009/07/01
- Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Luiz Capitulino, 2009/07/01
- Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Avi Kivity, 2009/07/01
- Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Jamie Lokier, 2009/07/01
Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Stefan Weil, 2009/07/01
Re: [Qemu-devel] [PATCH] Allow setting qemu process name,
Todd T. Fries <=
Re: [Qemu-devel] [PATCH] Allow setting qemu process name, Richard W.M. Jones, 2009/07/24