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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]