]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add support for Xen input device in QEMU driver for xenner
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 15 May 2008 16:11:40 +0000 (16:11 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 15 May 2008 16:11:40 +0000 (16:11 +0000)
ChangeLog
src/qemu_conf.c
src/qemu_conf.h
src/qemu_driver.c
tests/qemuxml2argvdata/qemuxml2argv-input-xen.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c
tests/qemuxml2xmltest.c

index cf5d9c02eea61d0e24b895284fec1f3405886534..bc6422bc323d096241b4f40ccd1ef57878433ef9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu May 15 12:08:08 EST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+       Support paravirt framebuffer input configuration for xenner guests
+       * src/qemu_drive.c, src/qemu_conf.c, src/qemu_conf.h: Add support
+        for 'xen' input device type for Xenner PVFB
+       * tests/qemuxml2argv-input-xen.{args,xml}: Test case data
+       files for xen input devices
+       * tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add
+       test case for xen input devices
+
 Thu May 15 11:57:08 EST 2008 Daniel P. Berrange <berrange@redhat.com>
 
        Support paravirt disk configuration for xenner guests
index ed0fa902270e9f707b25b0d629515828f028c02c..a23f28c577b8e766bf85fe8344cf5e327e9b2c65 100644 (file)
@@ -1365,6 +1365,7 @@ cleanup:
 
 /* Parse the XML definition for a network interface */
 static int qemudParseInputXML(virConnectPtr conn,
+                              const struct qemud_vm_def *vm,
                               struct qemud_vm_input_def *input,
                               xmlNodePtr node) {
     xmlChar *type = NULL;
@@ -1391,26 +1392,46 @@ static int qemudParseInputXML(virConnectPtr conn,
     }
 
     if (bus) {
-        if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
-            if (input->type == QEMU_INPUT_TYPE_TABLET) {
+        if (STREQ(vm->os.type, "hvm")) {
+            if (STREQ((const char*)bus, "ps2")) { /* Only allow mouse */
+                if (input->type != QEMU_INPUT_TYPE_MOUSE) {
+                    qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                                     _("ps2 bus does not support %s input device"),
+                                     (const char*)type);
+                    goto error;
+                }
+                input->bus = QEMU_INPUT_BUS_PS2;
+            } else if (STREQ((const char *)bus, "usb")) { /* Allow mouse & tablet */
+                input->bus = QEMU_INPUT_BUS_USB;
+            } else {
                 qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
-                                 _("ps2 bus does not support %s input device"),
-                                 (const char*)type);
+                                 _("unsupported input bus %s"), (const char*)bus);
                 goto error;
             }
-            input->bus = QEMU_INPUT_BUS_PS2;
-        } else if (STREQ((const char *)bus, "usb")) { /* Allow mouse & keyboard */
-            input->bus = QEMU_INPUT_BUS_USB;
         } else {
-            qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
-                             _("unsupported input bus %s"), (const char*)bus);
-            goto error;
+            if (STREQ((const char *)bus, "xen")) { /* Allow mouse only */
+                input->bus = QEMU_INPUT_BUS_XEN;
+                if (input->type != QEMU_INPUT_TYPE_MOUSE) {
+                    qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                                     _("xen bus does not support %s input device"),
+                                     (const char*)type);
+                    goto error;
+                }
+            } else {
+                qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+                                 _("unsupported input bus %s"), (const char*)bus);
+                goto error;
+            }
         }
     } else {
-        if (input->type == QEMU_INPUT_TYPE_MOUSE)
-            input->bus = QEMU_INPUT_BUS_PS2;
-        else
-            input->bus = QEMU_INPUT_BUS_USB;
+        if (!strcmp(vm->os.type, "hvm")) {
+            if (input->type == QEMU_INPUT_TYPE_MOUSE)
+                input->bus = QEMU_INPUT_BUS_PS2;
+            else
+                input->bus = QEMU_INPUT_BUS_USB;
+        } else {
+            input->bus = QEMU_INPUT_BUS_XEN;
+        }
     }
 
     xmlFree(type);
@@ -1998,7 +2019,7 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
                          "%s", _("failed to allocate space for input string"));
                 goto error;
             }
-            if (qemudParseInputXML(conn, input, obj->nodesetval->nodeTab[i]) < 0) {
+            if (qemudParseInputXML(conn, def, input, obj->nodesetval->nodeTab[i]) < 0) {
                 free(input);
                 goto error;
             }
@@ -2852,7 +2873,7 @@ static int qemudSaveConfig(virConnectPtr conn,
 
 struct qemud_vm_device_def *
 qemudParseVMDeviceDef(virConnectPtr conn,
-                      struct qemud_driver *driver ATTRIBUTE_UNUSED,
+                      const struct qemud_vm_def *def,
                       const char *xmlStr)
 {
     xmlDocPtr xml;
@@ -2880,7 +2901,7 @@ qemudParseVMDeviceDef(virConnectPtr conn,
         qemudParseInterfaceXML(conn, &(dev->data.net), node);
     } else if (xmlStrEqual(node->name, BAD_CAST "input")) {
         dev->type = QEMUD_DEVICE_DISK;
-        qemudParseInputXML(conn, &(dev->data.input), node);
+        qemudParseInputXML(conn, def, &(dev->data.input), node);
     } else if (xmlStrEqual(node->name, BAD_CAST "sound")) {
         dev->type = QEMUD_DEVICE_SOUND;
         qemudParseSoundXML(conn, &(dev->data.sound), node);
@@ -3950,14 +3971,15 @@ char *qemudGenerateXML(virConnectPtr conn,
 
     input = def->inputs;
     while (input) {
-        if (input->bus != QEMU_INPUT_BUS_PS2)
+        if (input->bus == QEMU_INPUT_BUS_USB)
             virBufferVSprintf(&buf, "    <input type='%s' bus='usb'/>\n",
                               input->type == QEMU_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
         input = input->next;
     }
     /* If graphics is enable, add implicit mouse */
     if (def->graphicsType != QEMUD_GRAPHICS_NONE)
-        virBufferAddLit(&buf, "    <input type='mouse' bus='ps2'/>\n");
+        virBufferVSprintf(&buf, "    <input type='mouse' bus='%s'/>\n",
+                          STREQ(def->os.type, "hvm") ? "ps2" : "xen");
 
     switch (def->graphicsType) {
     case QEMUD_GRAPHICS_VNC:
index 183b16de45fd8c6e17b51dcc276da3c93f2218b1..ccf8a2281fde5e19ab56847a1bb432fe55cbf714 100644 (file)
@@ -189,6 +189,7 @@ enum qemu_vm_input_type {
 enum qemu_vm_input_bus {
     QEMU_INPUT_BUS_PS2,
     QEMU_INPUT_BUS_USB,
+    QEMU_INPUT_BUS_XEN,
 };
 
 struct qemud_vm_input_def {
@@ -474,7 +475,7 @@ void        qemudRemoveInactiveVM       (struct qemud_driver *driver,
 
 struct qemud_vm_device_def *
             qemudParseVMDeviceDef       (virConnectPtr conn,
-                                         struct qemud_driver *driver,
+                                         const struct qemud_vm_def *def,
                                          const char *xmlStr);
 
 struct qemud_vm_def *
index 6ba617909c941fd2141de8756e5033a39607efef..34193bd235fd7eb94dbd362f01656c87d8cf62c2 100644 (file)
@@ -2516,7 +2516,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
         return -1;
     }
 
-    dev = qemudParseVMDeviceDef(dom->conn, driver, xml);
+    dev = qemudParseVMDeviceDef(dom->conn, vm->def, xml);
     if (dev == NULL) {
         return -1;
     }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args
new file mode 100644 (file)
index 0000000..d23818d
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/xenner -M xenner -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc :-5901
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml
new file mode 100644 (file)
index 0000000..a8efef0
--- /dev/null
@@ -0,0 +1,24 @@
+<domain type='kvm'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type>xen</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/xenner</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+    </disk>
+    <input type='mouse' bus='xen'/>
+    <graphics type='vnc' port='-1'/>
+  </devices>
+</domain>
index 30009e7533327f8a4b6cf977079d155750a3169b..d647227a91368bf46c51f1cc4bb945d00a631ba2 100644 (file)
@@ -158,6 +158,7 @@ main(int argc, char **argv)
     DO_TEST("graphics-sdl", 0);
     DO_TEST("input-usbmouse", 0);
     DO_TEST("input-usbtablet", 0);
+    DO_TEST("input-xen", 0);
     DO_TEST("misc-acpi", 0);
     DO_TEST("misc-no-reboot", 0);
     DO_TEST("net-user", 0);
index fda89b4e44c35cd6ab8957bd48eb8f5f8969c4ce..6dfc66f67fdf0b72dab4c2d8761747595c8fcdd6 100644 (file)
@@ -107,6 +107,7 @@ main(int argc, char **argv)
     DO_TEST("graphics-sdl");
     DO_TEST("input-usbmouse");
     DO_TEST("input-usbtablet");
+    DO_TEST("input-xen");
     DO_TEST("misc-acpi");
     DO_TEST("misc-no-reboot");
     DO_TEST("net-user");