[libvirt] [PATCHv5 12/13] Add compatibility attribute to input devices

Ján Tomko jtomko at redhat.com
Tue Aug 23 22:20:54 UTC 2016


<input type='mouse' bus='virtio'>
  <driver compatibility='modern'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
</input>
<input type='keyboard' bus='virtio'>
  <driver compatibility='modern'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
</input>
<input type='tablet' bus='virtio'>
  <driver compatibility='modern'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
</input>
<input type='passthrough' bus='virtio'>
  <driver compatibility='modern'/>
  <source evdev='/dev/input/event1234'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
</input>

https://bugzilla.redhat.com/show_bug.cgi?id=1227354
---
 docs/formatdomain.html.in                                   | 7 +++++++
 docs/schemas/domaincommon.rng                               | 5 +++++
 src/conf/domain_conf.c                                      | 7 +++++++
 src/conf/domain_conf.h                                      | 1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml     | 4 ++++
 tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml | 4 ++++
 6 files changed, 28 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index d640e8d..8913e91 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5230,6 +5230,13 @@ qemu-kvm -net nic,model=? /dev/null
       event device passed through to guests. (KVM only)
     </p>
 
+    <p>
+      The <code>compatibility</code> attribute of the <code>driver</code> element
+      can be used to specify the compatibility of virtio devices. Allowed values
+      are <code>legacy</code>, <code>transitional</code> and <code>modern</code>.
+      <span class="since">Since 2.2.0</span>.
+    </p>
+
     <h4><a name="elementsHub">Hub devices</a></h4>
 
     <p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f250cbc..b69c3ce 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3792,6 +3792,11 @@
 
   <define name="input">
     <element name="input">
+      <optional>
+        <element name="driver">
+          <ref name="compatibility"/>
+        </element>
+      </optional>
       <choice>
         <group>
           <attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 03c856c..ad349fb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10730,6 +10730,9 @@ virDomainInputDefParseXML(const virDomainDef *dom,
         goto error;
     }
 
+    if (virDomainDriverCompatibilityParseXML(ctxt, &def->compatibility) < 0)
+        goto error;
+
  cleanup:
     VIR_FREE(evdev);
     VIR_FREE(type);
@@ -21972,6 +21975,10 @@ virDomainInputDefFormat(virBufferPtr buf,
                       type, bus);
 
     virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2);
+    if (def->compatibility) {
+        virBufferAsprintf(&childbuf, "<driver compatibility='%s'/>\n",
+                          virDomainDriverCompatibilityTypeToString(def->compatibility));
+    }
     virBufferEscapeString(&childbuf, "<source evdev='%s'/>\n", def->source.evdev);
     if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0)
         return -1;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ecccc0a..0f5fc0d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1229,6 +1229,7 @@ struct _virDomainInputDef {
         char *evdev;
     } source;
     virDomainDeviceInfo info;
+    virDomainDriverCompatibility compatibility;
 };
 
 typedef enum {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
index fecf9e5..1414a0d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-revision.xml
@@ -71,15 +71,19 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
     </interface>
     <input type='mouse' bus='virtio'>
+      <driver compatibility='modern'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
     </input>
     <input type='keyboard' bus='virtio'>
+      <driver compatibility='modern'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
     </input>
     <input type='tablet' bus='virtio'>
+      <driver compatibility='modern'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
     </input>
     <input type='passthrough' bus='virtio'>
+      <driver compatibility='modern'/>
       <source evdev='/dev/input/event1234'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
     </input>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
index f1c728e..d9dc27c 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-revision.xml
@@ -71,15 +71,19 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
     </interface>
     <input type='mouse' bus='virtio'>
+      <driver compatibility='modern'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
     </input>
     <input type='keyboard' bus='virtio'>
+      <driver compatibility='modern'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
     </input>
     <input type='tablet' bus='virtio'>
+      <driver compatibility='modern'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
     </input>
     <input type='passthrough' bus='virtio'>
+      <driver compatibility='modern'/>
       <source evdev='/dev/input/event1234'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
     </input>
-- 
2.7.3




More information about the libvir-list mailing list