[libvirt] process= support for 'qemu-kvm -name' [Bug 576950]

Daniel P. Berrange berrange at redhat.com
Tue Mar 30 14:05:06 UTC 2010


On Sun, Mar 28, 2010 at 10:19:51PM -0400, John Morrissey wrote:
> I wrote (attached here, and to the bug) a quick patch that sets the process
> name to the same value as the window title.
> 
> I'm unsure where to go from here. Should I add support for converting
> "native" QEMU command lines to libvirt XML? What would that look like, since
> I'm not modifying the libvirt format? Should it just drop any ,process= from
> the QEMU command line it's parsing? I also imagine the test cases will need
> updating.

Yes it would be sufficient to just drop any ',process=' bit.

> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 616af6e..a175cd7 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -1126,8 +1126,11 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
>          flags |= QEMUD_CMD_FLAG_ENABLE_KVM;
>      if (strstr(help, "-no-reboot"))
>          flags |= QEMUD_CMD_FLAG_NO_REBOOT;
> -    if (strstr(help, "-name"))
> +    if (strstr(help, "-name")) {
>          flags |= QEMUD_CMD_FLAG_NAME;
> +        if (strstr(help, ",process="))
> +            flags |= QEMUD_CMD_FLAG_NAME_PROCESS;
> +    }
>      if (strstr(help, "-uuid"))
>          flags |= QEMUD_CMD_FLAG_UUID;
>      if (strstr(help, "-xen-domid"))
> @@ -3550,7 +3553,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
>  
>      if (qemuCmdFlags & QEMUD_CMD_FLAG_NAME) {
>          ADD_ARG_LIT("-name");
> -        ADD_ARG_LIT(def->name);
> +        if (qemuCmdFlags & QEMUD_CMD_FLAG_NAME_PROCESS) {
> +            char *name;
> +            if (virAsprintf(&name, "%s,process=%s",
> +                            def->name, def->name) < 0)
> +                goto no_memory;
> +            ADD_ARG_LIT(name);

I think it will be quite misleading to do this. eg a VM named 'foo'

  # qemu-system-x86_64 -vnc :2 -hda /var/lib/libvirt/images/plain.img -name foo,process=foo

Now the process listing shows

  # ps -w
    PID TTY          TIME CMD
  12009 pts/1    00:00:01 bash
  12646 pts/1    00:00:00 ksmtuned
  14494 pts/1    00:00:02 foo
  14508 pts/1    00:00:00 sleep
  14511 pts/1    00:00:00 ps

which leaves no indication that 'foo' is a QEMU process at all which is 
rather bad IMHO. At the very least I think we should keep the binary base
name here, and have the VM name as a postfix, eg so it shows


  # ps -w
    PID TTY          TIME CMD
  12009 pts/1    00:00:01 bash
  12646 pts/1    00:00:00 ksmtuned
  14494 pts/1    00:00:02 qemu-system-x86_64 (foo)
  14508 pts/1    00:00:00 sleep
  14511 pts/1    00:00:00 ps

Regards,
Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list