[libvirt] [PATCH 2/8] conf: parse and format virtio input bus in domain XML

Ján Tomko jtomko at redhat.com
Fri Nov 20 08:59:37 UTC 2015


To be used by the family of virtio input devices:

<input type='mouse' bus='virtio'/>
<input type='tablet' bus='virtio'/>
<input type='keyboard' bus='virtio'/>

https://bugzilla.redhat.com/show_bug.cgi?id=1231114
---
 docs/formatdomain.html.in                          |  6 ++++-
 docs/schemas/domaincommon.rng                      |  1 +
 src/conf/domain_conf.c                             |  6 +++--
 src/conf/domain_conf.h                             |  1 +
 .../qemuxml2argvdata/qemuxml2argv-virtio-input.xml | 26 ++++++++++++++++++++++
 tests/qemuxml2xmltest.c                            |  2 ++
 6 files changed, 39 insertions(+), 3 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e5e0167..d334071 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4801,6 +4801,9 @@ qemu-kvm -net nic,model=? /dev/null
   <devices>
     <input type='mouse' bus='usb'/>
     <input type='keyboard' bus='usb'/>
+    <input type='mouse' bus='virtio'/>
+    <input type='keyboard' bus='virtio'/>
+    <input type='tablet' bus='virtio'/>
   </devices>
   ...</pre>
 
@@ -4812,7 +4815,8 @@ qemu-kvm -net nic,model=? /dev/null
         The tablet provides absolute cursor movement,
         while the mouse uses relative movement. The optional
         <code>bus</code> attribute can be used to refine the exact device type.
-        It takes values "xen" (paravirtualized), "ps2" and "usb".</dd>
+        It takes values "xen" (paravirtualized), "ps2" and "usb" or
+        (<span class="since">since 1.3.0</span>) "virtio".</dd>
     </dl>
 
     <p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 994face..b740db8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3591,6 +3591,7 @@
             <value>ps2</value>
             <value>usb</value>
             <value>xen</value>
+            <value>virtio</value>
           </choice>
         </attribute>
       </optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0ac7dbf..419bfb9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -543,7 +543,8 @@ VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST,
               "ps2",
               "usb",
               "xen",
-              "parallels")
+              "parallels",
+              "virtio")
 
 VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST,
               "sdl",
@@ -22357,7 +22358,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
             goto error;
 
     for (n = 0; n < def->ninputs; n++)
-        if (def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_USB &&
+        if ((def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_USB ||
+             def->inputs[n]->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) &&
             virDomainInputDefFormat(buf, def->inputs[n], flags) < 0)
             goto error;
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8d43ee6..81c546d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1297,6 +1297,7 @@ typedef enum {
     VIR_DOMAIN_INPUT_BUS_USB,
     VIR_DOMAIN_INPUT_BUS_XEN,
     VIR_DOMAIN_INPUT_BUS_PARALLELS, /* pseudo device for VNC in containers */
+    VIR_DOMAIN_INPUT_BUS_VIRTIO,
 
     VIR_DOMAIN_INPUT_BUS_LAST
 } virDomainInputBus;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml
new file mode 100644
index 0000000..11fb566
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-input.xml
@@ -0,0 +1,26 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</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/qemu</emulator>
+    <controller type='usb' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='virtio'/>
+    <input type='keyboard' bus='virtio'>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+    </input>
+    <input type='tablet' bus='virtio'/>
+    <memballoon model='virtio'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index cbd4d0d..535dfb8 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -626,6 +626,8 @@ mymain(void)
     DO_TEST("memory-hotplug-dimm");
     DO_TEST("net-udp");
 
+    DO_TEST("virtio-input");
+
     qemuTestDriverFree(&driver);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
-- 
2.4.6




More information about the libvir-list mailing list