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

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

 



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@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 2c4a37d..64da7d0 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -797,7 +797,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;
@@ -1663,9 +1665,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;
+        }
     }
 
     /*
@@ -1718,9 +1733,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 9fa4559..c5491b7 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -69,6 +69,8 @@ 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 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..0ea6fa1 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-uuid.xml
@@ -5,7 +5,7 @@
   <currentMemory>219200</currentMemory>
   <vcpu>1</vcpu>
   <os>
-    <type arch='i686' machine='pc'>hvm</type>
+    <type arch='x86_64' machine='pc'>xen</type>
     <boot dev='hd'/>
   </os>
   <features>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d1cef0e..faa8396 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -190,7 +190,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);
@@ -241,7 +241,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 |
--
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]