From b81a7ece97e24dacd9a1ce458ea02e58725e5e98 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 25 Aug 2009 14:17:29 +0100 Subject: [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/qemuxml2argvtest.c: Add missing QEMUD_CMD_FLAG_DOMID params --- src/qemu/qemu_conf.c | 31 ++++++++++++++----- src/qemu/qemu_conf.h | 1 + .../qemuxml2argv-bootloader.args | 2 +- .../qemuxml2argv-input-xen.args | 2 +- .../qemuxml2argv-misc-uuid.args | 2 +- tests/qemuxml2argvtest.c | 6 ++-- 6 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 273aecac76..8f2774bb9b 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -851,7 +851,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; @@ -1720,9 +1722,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; + } } /* @@ -1775,9 +1790,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/qemu_conf.h b/src/qemu/qemu_conf.h index 7b35b6d9cf..82eb89f848 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -69,6 +69,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_PCIDEVICE = (1 << 17), /* PCI device assignment only supported by qemu-kvm */ QEMUD_CMD_FLAG_MEM_PATH = (1 << 18), /* mmap'ped guest backing supported */ QEMUD_CMD_FLAG_DRIVE_SERIAL = (1 << 19), /* -driver serial= available */ + QEMUD_CMD_FLAG_XEN_DOMID = (1 << 20), /* -xen-domid (new style xen integration) */ }; /* Main driver state */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args index 8a15524da2..bcae18a682 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 64c0e1cb4c..65fb07318e 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 c735dc7be4..e949a6013a 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 -nographic -monitor unix:/tmp/test-monitor,server,nowait -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 8318a2c998..32551468ce 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -195,7 +195,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("hugepages", QEMUD_CMD_FLAG_MEM_PATH); @@ -246,11 +246,11 @@ 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 | - QEMUD_CMD_FLAG_UUID | QEMUD_CMD_FLAG_DOMID); + QEMUD_CMD_FLAG_UUID); DO_TEST("net-user", 0); DO_TEST("net-virtio", 0); DO_TEST("net-eth", 0);