render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From e0bb36c4d7c60336d2aba94013c2946e1594959b Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <e0bb36c4d7c60336d2aba94013c2946e1594959b@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Fri, 9 Jun 2017 12:49:03 +0200
3e5111
Subject: [PATCH] Add virtio-related options to controllers
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 c85217cf8a81879d065b9d13e876eec141f63f6f)
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                              |  6 ++++++
3e5111
 docs/schemas/domaincommon.rng                          |  1 +
3e5111
 src/conf/domain_conf.c                                 | 10 ++++++++++
3e5111
 src/conf/domain_conf.h                                 |  1 +
3e5111
 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  2 ++
3e5111
 5 files changed, 20 insertions(+)
3e5111
3e5111
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
3e5111
index bb7a85a1a1..2b26f090cd 100644
3e5111
--- a/docs/formatdomain.html.in
3e5111
+++ b/docs/formatdomain.html.in
3e5111
@@ -3597,6 +3597,12 @@
3e5111
         iothread value. The iothread value
3e5111
         must be within the range 1 to the domain iothreads value.
3e5111
       
3e5111
+      
virtio options
3e5111
+      
3e5111
+        For virtio controllers,
3e5111
+        Virtio-specific options can also be
3e5111
+        set. (Since 3.5.0)
3e5111
+      
3e5111
     
3e5111
     

3e5111
       USB companion controllers have an optional
3e5111
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
3e5111
index f838dc55fd..2108d23df7 100644
3e5111
--- a/docs/schemas/domaincommon.rng
3e5111
+++ b/docs/schemas/domaincommon.rng
3e5111
@@ -2019,6 +2019,7 @@
3e5111
             <optional>
3e5111
               <ref name="driverIOThread"/>
3e5111
             </optional>
3e5111
+            <ref name="virtioOptions"/>
3e5111
           </element>
3e5111
         </optional>
3e5111
       </interleave>
3e5111
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
3e5111
index a4b4f70855..2e5eeb1172 100644
3e5111
--- a/src/conf/domain_conf.c
3e5111
+++ b/src/conf/domain_conf.c
3e5111
@@ -1873,6 +1873,7 @@ void virDomainControllerDefFree(virDomainControllerDefPtr def)
3e5111
         return;
3e5111
 
3e5111
     virDomainDeviceInfoClear(&def->info);
3e5111
+    VIR_FREE(def->virtio);
3e5111
 
3e5111
     VIR_FREE(def);
3e5111
 }
3e5111
@@ -9037,6 +9038,9 @@ virDomainControllerDefParseXML(xmlNodePtr node,
3e5111
         cur = cur->next;
3e5111
     }
3e5111
 
3e5111
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
3e5111
+        goto error;
3e5111
+
3e5111
     /* node is parsed differently from target attributes because
3e5111
      * someone thought it should be a subelement instead...
3e5111
      */
3e5111
@@ -19214,6 +19218,10 @@ virDomainControllerDefCheckABIStability(virDomainControllerDefPtr src,
3e5111
         }
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
@@ -21504,6 +21512,8 @@ virDomainControllerDriverFormat(virBufferPtr buf,
3e5111
     if (def->iothread)
3e5111
         virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread);
3e5111
 
3e5111
+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
3e5111
+
3e5111
     if (virBufferUse(&driverBuf)) {
3e5111
         virBufferAddLit(buf, "
3e5111
         virBufferAddBuffer(buf, &driverBuf);
3e5111
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
3e5111
index eac1919175..205c9e27b1 100644
3e5111
--- a/src/conf/domain_conf.h
3e5111
+++ b/src/conf/domain_conf.h
3e5111
@@ -813,6 +813,7 @@ struct _virDomainControllerDef {
3e5111
         virDomainUSBControllerOpts usbopts;
3e5111
     } opts;
3e5111
     virDomainDeviceInfo info;
3e5111
+    virDomainVirtioOptionsPtr virtio;
3e5111
 };
3e5111
 
3e5111
 
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
index 6dd82de648..867e56c107 100644
3e5111
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
@@ -27,10 +27,12 @@
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
3e5111
     </controller>
3e5111
     <controller type='scsi' index='0' model='virtio-scsi'>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
3e5111
     </controller>
3e5111
     <controller type='pci' index='0' model='pci-root'/>
3e5111
     <controller type='virtio-serial' index='0'>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
3e5111
     </controller>
3e5111
     <filesystem type='mount' accessmode='passthrough'>
3e5111
-- 
3e5111
2.13.1
3e5111