[libvirt] [PATCH] Fix handling of Xen(ner) detection

Latest upstream QEMU can be built with Xen support, which introduces a -xen-domid argument. This was mistakenly detected as -domid due to old Xenner support. Adapt to cope with both syntax. Also only set domid if the virt type is xen, or the guest type is xen * src/qemu_conf.c, src/qemu_conf.h: Detect new -xen-domid flag in preference to -domid. * tests/qemuxml2argvdata/qemuxml2argv-bootloader.args, tests/qemuxml2argvdata/qemuxml2argv-input-xen.args: Add missing -domid param * tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args: Remove bogus -boot param. * tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml: Fix domain type to be xen * tests/qemuxml2argvtest.c: Add missing QEMUD_CMD_FLAG_DOMID params --- src/qemu_conf.c | 31 +++++++++++++++---- src/qemu_conf.h | 1 + .../qemuxml2argvdata/qemuxml2argv-bootloader.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-input-xen.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml | 3 +- tests/qemuxml2argvtest.c | 4 +- 7 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/qemu_conf.c b/src/qemu_conf.c index 22f5edd..e8414c3 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -769,7 +769,9 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_NAME; if (strstr(help, "-uuid")) flags |= QEMUD_CMD_FLAG_UUID; - if (strstr(help, "-domid")) + if (strstr(help, "-xen-domid")) + flags |= QEMUD_CMD_FLAG_XEN_DOMID; + else if (strstr(help, "-domid")) flags |= QEMUD_CMD_FLAG_DOMID; if (strstr(help, "-drive")) { flags |= QEMUD_CMD_FLAG_DRIVE; @@ -1594,9 +1596,22 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG_LIT("-uuid"); ADD_ARG_LIT(uuid); } - if (qemuCmdFlags & QEMUD_CMD_FLAG_DOMID) { - ADD_ARG_LIT("-domid"); - ADD_ARG_LIT(domid); + if (def->virtType == VIR_DOMAIN_VIRT_XEN || + STREQ(def->os.type, "xen") || + STREQ(def->os.type, "linux")) { + if (qemuCmdFlags & QEMUD_CMD_FLAG_DOMID) { + ADD_ARG_LIT("-domid"); + ADD_ARG_LIT(domid); + } else if (qemuCmdFlags & QEMUD_CMD_FLAG_XEN_DOMID) { + ADD_ARG_LIT("-xen-attach"); + ADD_ARG_LIT("-xen-domid"); + ADD_ARG_LIT(domid); + } else { + qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, + _("qemu emulator '%s' does not support xen"), + def->emulator); + goto error; + } } /* @@ -1649,9 +1664,11 @@ int qemudBuildCommandLine(virConnectPtr conn, break; } } - boot[def->os.nBootDevs] = '\0'; - ADD_ARG_LIT("-boot"); - ADD_ARG_LIT(boot); + if (def->os.nBootDevs) { + boot[def->os.nBootDevs] = '\0'; + ADD_ARG_LIT("-boot"); + ADD_ARG_LIT(boot); + } if (def->os.kernel) { ADD_ARG_LIT("-kernel"); diff --git a/src/qemu_conf.h b/src/qemu_conf.h index a126dac..99aac81 100644 --- a/src/qemu_conf.h +++ b/src/qemu_conf.h @@ -67,6 +67,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_HOST_NET_ADD = QEMUD_CMD_FLAG_0_10, /* host_net_add monitor command */ QEMUD_CMD_FLAG_PCIDEVICE = (1 << 17), /* PCI device assignment only supported by qemu-kvm */ + QEMUD_CMD_FLAG_XEN_DOMID = (1 << 18), /* -xen-domid (new style xen integration) */ }; /* Main driver state */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args index 8a15524..bcae18a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/xenner -S -M xenner -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -bootloader /usr/bin/pygrub -cdrom /dev/cdrom -net none -serial none -parallel none -usb +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/xenner -S -M xenner -m 214 -smp 1 -domid 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -bootloader /usr/bin/pygrub -cdrom /dev/cdrom -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args index 64c0e1c..65fb073 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/xenner -S -M xenner -m 214 -smp 1 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -bootloader /foo -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3 +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/xenner -S -M xenner -m 214 -smp 1 -domid 6 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -bootloader /foo -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args index c735dc7..c4df9ae 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.args @@ -1 +1 @@ -LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -name QEMUGuest1 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 -domid 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -name QEMUGuest1 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 -domid 6 -nographic -monitor unix:/tmp/test-monitor,server,nowait -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml index 1b37bdc..7f77e01 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml @@ -5,8 +5,7 @@ <currentMemory>219200</currentMemory> <vcpu>1</vcpu> <os> - <type arch='i686' machine='pc'>hvm</type> - <boot dev='hd'/> + <type arch='x86_64' machine='pc'>xen</type> </os> <features> <acpi/> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6f25e7d..ad7a690 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -186,7 +186,7 @@ mymain(int argc, char **argv) DO_TEST("boot-cdrom", 0); DO_TEST("boot-network", 0); DO_TEST("boot-floppy", 0); - DO_TEST("bootloader", 0); + DO_TEST("bootloader", QEMUD_CMD_FLAG_DOMID); DO_TEST("clock-utc", 0); DO_TEST("clock-localtime", 0); DO_TEST("disk-cdrom", 0); @@ -236,7 +236,7 @@ mymain(int argc, char **argv) DO_TEST("graphics-sdl-fullscreen", 0); DO_TEST("input-usbmouse", 0); DO_TEST("input-usbtablet", 0); - DO_TEST("input-xen", 0); + DO_TEST("input-xen", QEMUD_CMD_FLAG_DOMID); DO_TEST("misc-acpi", 0); DO_TEST("misc-no-reboot", 0); DO_TEST("misc-uuid", QEMUD_CMD_FLAG_NAME | -- 1.6.2.5

On Fri, Aug 28, 2009 at 11:21:07AM +0100, Daniel P. Berrange wrote:
Latest upstream QEMU can be built with Xen support, which introduces a -xen-domid argument. This was mistakenly detected as -domid due to old Xenner support. Adapt to cope with both syntax. Also only set domid if the virt type is xen, or the guest type is xen
* src/qemu_conf.c, src/qemu_conf.h: Detect new -xen-domid flag in preference to -domid.
Patch looks fine except I had to rebase it
* tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml: Fix domain type to be xen
But the test are failing for me for example we end up with <os> <type arch='x86_64' machine='pc'>xen</type> <boot dev='hd'/> </os> and that doesn't match ostypehvm nor ostypexen, the first one because the value is not hvm the second one because the machine='pc' is not one of the accepted attributes values. Attaching the result of my rebase, but a bit of checking still needed I think, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Fri, Sep 04, 2009 at 03:15:53PM +0200, Daniel Veillard wrote:
On Fri, Aug 28, 2009 at 11:21:07AM +0100, Daniel P. Berrange wrote:
Latest upstream QEMU can be built with Xen support, which introduces a -xen-domid argument. This was mistakenly detected as -domid due to old Xenner support. Adapt to cope with both syntax. Also only set domid if the virt type is xen, or the guest type is xen
* src/qemu_conf.c, src/qemu_conf.h: Detect new -xen-domid flag in preference to -domid.
Patch looks fine except I had to rebase it
* tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml: Fix domain type to be xen
But the test are failing for me for example we end up with
<os> <type arch='x86_64' machine='pc'>xen</type> <boot dev='hd'/> </os>
and that doesn't match ostypehvm nor ostypexen, the first one because the value is not hvm the second one because the machine='pc' is not one of the accepted attributes values.
Hmm, I did fix all the test cases, because several had bogus XML for xenner, but I'll re-check this again Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard