]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Add virtio-related options to input devices
authorJán Tomko <jtomko@redhat.com>
Mon, 8 Aug 2016 13:42:18 +0000 (15:42 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 8 Jun 2017 14:32:53 +0000 (16:32 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml

index d7af60fbd8bfaa8763dda7ad5f7cb981ef92c170..52119f0a0a8fea8009ac4cd58d4fd2cf533df0a8 100644 (file)
@@ -5715,6 +5715,13 @@ qemu-kvm -net nic,model=? /dev/null
       event device passed through to guests. (KVM only)
     </p>
 
+    <p>
+        The subelement <code>driver</code> can be used to tune the virtio
+        options of the device:
+        <a href="#elementsVirtio">Virtio-specific options</a> can also be
+        set. (<span class="since">Since 3.5.0</span>)
+    </p>
+
     <h4><a name="elementsHub">Hub devices</a></h4>
 
     <p>
index 0955fc8764f4d51a1d1beadc6b49620fb44bc50f..4950ddc10915c7fd3f5e04cf3831988a42268896 100644 (file)
 
   <define name="input">
     <element name="input">
+      <optional>
+        <element name="driver">
+          <ref name="virtioOptions"/>
+        </element>
+      </optional>
       <choice>
         <group>
           <attribute name="type">
index d3bbbac441c14bcc3c49e1df00b06a96a04c58fa..5c32f9368136a8cc27db0a843da04dc653554f8f 100644 (file)
@@ -1400,6 +1400,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def)
 
     virDomainDeviceInfoClear(&def->info);
     VIR_FREE(def->source.evdev);
+    VIR_FREE(def->virtio);
     VIR_FREE(def);
 }
 
@@ -11614,6 +11615,9 @@ virDomainInputDefParseXML(const virDomainDef *dom,
         goto error;
     }
 
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
+        goto error;
+
  cleanup:
     VIR_FREE(evdev);
     VIR_FREE(type);
@@ -19354,6 +19358,10 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src,
         return false;
     }
 
+    if (src->virtio && dst->virtio &&
+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
+        return false;
+
     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
         return false;
 
@@ -23448,6 +23456,7 @@ virDomainInputDefFormat(virBufferPtr buf,
     const char *type = virDomainInputTypeToString(def->type);
     const char *bus = virDomainInputBusTypeToString(def->bus);
     virBuffer childbuf = VIR_BUFFER_INITIALIZER;
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
 
     /* don't format keyboard into migratable XML for backward compatibility */
     if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
@@ -23471,6 +23480,15 @@ virDomainInputDefFormat(virBufferPtr buf,
                       type, bus);
 
     virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2);
+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
+    if (virBufferCheckError(&driverBuf) < 0)
+        return -1;
+
+    if (virBufferUse(&driverBuf)) {
+        virBufferAddLit(&childbuf, "<driver");
+        virBufferAddBuffer(&childbuf, &driverBuf);
+        virBufferAddLit(&childbuf, "/>\n");
+    }
     virBufferEscapeString(&childbuf, "<source evdev='%s'/>\n", def->source.evdev);
     if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0)
         return -1;
index a692c32e1a16662f5c9258bc46b7d8af12db5df2..e67b6fd4f9ce60a6f8650adfc16f238425d07516 100644 (file)
@@ -1282,6 +1282,7 @@ struct _virDomainInputDef {
         char *evdev;
     } source;
     virDomainDeviceInfo info;
+    virDomainVirtioOptionsPtr virtio;
 };
 
 typedef enum {
index 85d1145263de3bee070f5e31440e41aa1b6ebb5c..773038a320e6b6ecd6ace87680e61bae00f1d615 100644 (file)
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
     </interface>
     <input type='mouse' bus='virtio'>
+      <driver iommu='on' ats='on'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
     </input>
     <input type='keyboard' bus='virtio'>
+      <driver iommu='on' ats='on'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
     </input>
     <input type='tablet' bus='virtio'>
+      <driver iommu='on' ats='on'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
     </input>
     <input type='passthrough' bus='virtio'>
+      <driver iommu='on' ats='on'/>
       <source evdev='/dev/input/event1234'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
     </input>