render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 00aaab7312b72b5ef1785793f97849a69f425b83 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <00aaab7312b72b5ef1785793f97849a69f425b83@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Fri, 9 Jun 2017 12:49:07 +0200
3e5111
Subject: [PATCH] Add virtio-related options to input devices
3e5111
MIME-Version: 1.0
3e5111
Content-Type: text/plain; charset=UTF-8
3e5111
Content-Transfer-Encoding: 8bit
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1283251
3e5111
3e5111
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
(cherry picked from commit cc0933d3501229cdc8cf183a52a14c9b1c8de666)
3e5111
Signed-off-by: Ján Tomko <jtomko@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 docs/formatdomain.html.in                              |  7 +++++++
3e5111
 docs/schemas/domaincommon.rng                          |  5 +++++
3e5111
 src/conf/domain_conf.c                                 | 18 ++++++++++++++++++
3e5111
 src/conf/domain_conf.h                                 |  1 +
3e5111
 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  4 ++++
3e5111
 5 files changed, 35 insertions(+)
3e5111
3e5111
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
3e5111
index 6be015f866..dc8e7d2dc7 100644
3e5111
--- a/docs/formatdomain.html.in
3e5111
+++ b/docs/formatdomain.html.in
3e5111
@@ -5712,6 +5712,13 @@ qemu-kvm -net nic,model=? /dev/null
3e5111
       event device passed through to guests. (KVM only)
3e5111
     

3e5111
 
3e5111
+    

3e5111
+        The subelement driver can be used to tune the virtio
3e5111
+        options of the device:
3e5111
+        Virtio-specific options can also be
3e5111
+        set. (Since 3.5.0)
3e5111
+    

3e5111
+
3e5111
     

Hub devices

3e5111
 
3e5111
     

3e5111
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
3e5111
index ee49d6eb58..78023ff4af 100644
3e5111
--- a/docs/schemas/domaincommon.rng
3e5111
+++ b/docs/schemas/domaincommon.rng
3e5111
@@ -3936,6 +3936,11 @@
3e5111
 
3e5111
   <define name="input">
3e5111
     <element name="input">
3e5111
+      <optional>
3e5111
+        <element name="driver">
3e5111
+          <ref name="virtioOptions"/>
3e5111
+        </element>
3e5111
+      </optional>
3e5111
       <choice>
3e5111
         <group>
3e5111
           <attribute name="type">
3e5111
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
3e5111
index a0de639e51..d8ca25da38 100644
3e5111
--- a/src/conf/domain_conf.c
3e5111
+++ b/src/conf/domain_conf.c
3e5111
@@ -1400,6 +1400,7 @@ void virDomainInputDefFree(virDomainInputDefPtr def)
3e5111
 
3e5111
     virDomainDeviceInfoClear(&def->info);
3e5111
     VIR_FREE(def->source.evdev);
3e5111
+    VIR_FREE(def->virtio);
3e5111
     VIR_FREE(def);
3e5111
 }
3e5111
 
3e5111
@@ -11587,6 +11588,9 @@ virDomainInputDefParseXML(const virDomainDef *dom,
3e5111
         goto error;
3e5111
     }
3e5111
 
3e5111
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
3e5111
+        goto error;
3e5111
+
3e5111
  cleanup:
3e5111
     VIR_FREE(evdev);
3e5111
     VIR_FREE(type);
3e5111
@@ -19328,6 +19332,10 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src,
3e5111
         return false;
3e5111
     }
3e5111
 
3e5111
+    if (src->virtio && dst->virtio &&
3e5111
+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
3e5111
+        return false;
3e5111
+
3e5111
     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
3e5111
         return false;
3e5111
 
3e5111
@@ -23404,6 +23412,7 @@ virDomainInputDefFormat(virBufferPtr buf,
3e5111
     const char *type = virDomainInputTypeToString(def->type);
3e5111
     const char *bus = virDomainInputBusTypeToString(def->bus);
3e5111
     virBuffer childbuf = VIR_BUFFER_INITIALIZER;
3e5111
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
3e5111
 
3e5111
     /* don't format keyboard into migratable XML for backward compatibility */
3e5111
     if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
3e5111
@@ -23427,6 +23436,15 @@ virDomainInputDefFormat(virBufferPtr buf,
3e5111
                       type, bus);
3e5111
 
3e5111
     virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2);
3e5111
+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
3e5111
+    if (virBufferCheckError(&driverBuf) < 0)
3e5111
+        return -1;
3e5111
+
3e5111
+    if (virBufferUse(&driverBuf)) {
3e5111
+        virBufferAddLit(&childbuf, "
3e5111
+        virBufferAddBuffer(&childbuf, &driverBuf);
3e5111
+        virBufferAddLit(&childbuf, "/>\n");
3e5111
+    }
3e5111
     virBufferEscapeString(&childbuf, "<source evdev='%s'/>\n", def->source.evdev);
3e5111
     if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0)
3e5111
         return -1;
3e5111
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
3e5111
index b79fb50c79..4c33b0d15e 100644
3e5111
--- a/src/conf/domain_conf.h
3e5111
+++ b/src/conf/domain_conf.h
3e5111
@@ -1282,6 +1282,7 @@ struct _virDomainInputDef {
3e5111
         char *evdev;
3e5111
     } source;
3e5111
     virDomainDeviceInfo info;
3e5111
+    virDomainVirtioOptionsPtr virtio;
3e5111
 };
3e5111
 
3e5111
 typedef enum {
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
index 85d1145263..773038a320 100644
3e5111
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
@@ -54,15 +54,19 @@
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
3e5111
     </interface>
3e5111
     <input type='mouse' bus='virtio'>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
3e5111
     </input>
3e5111
     <input type='keyboard' bus='virtio'>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
3e5111
     </input>
3e5111
     <input type='tablet' bus='virtio'>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
3e5111
     </input>
3e5111
     <input type='passthrough' bus='virtio'>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <source evdev='/dev/input/event1234'/>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
3e5111
     </input>
3e5111
-- 
3e5111
2.13.1
3e5111