Blob Blame History Raw
From c828a666c154dece5bce0530c6a53d72d91ca3a1 Mon Sep 17 00:00:00 2001
Message-Id: <c828a666c154dece5bce0530c6a53d72d91ca3a1@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 9 Jun 2017 12:49:04 +0200
Subject: [PATCH] Add virtio-related options to filesystems
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

https://bugzilla.redhat.com/show_bug.cgi?id=1283251

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit b10c22d9fa11e2a67eca04592688bd701700f77f)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 docs/formatdomain.html.in                              |  5 +++++
 docs/schemas/domaincommon.rng                          |  1 +
 src/conf/domain_conf.c                                 | 10 ++++++++++
 src/conf/domain_conf.h                                 |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml |  3 ++-
 5 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 2b26f090cd..8d3f916a19 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3293,6 +3293,11 @@
             or "handle", but no formats. Virtuozzo driver supports
             a type of "ploop" with a format of "ploop".
           </li>
+          <li>
+          For virtio-backed devices,
+          <a href="#elementsVirtio">Virtio-specific options</a> can also be
+          set. (<span class="since">Since 3.5.0</span>)
+          </li>
         </ul>
       </dd>
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 2108d23df7..5e526b6100 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2202,6 +2202,7 @@
           <value>immediate</value>
         </attribute>
       </optional>
+      <ref name='virtioOptions'/>
       <empty/>
     </element>
   </define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2e5eeb1172..5c7ffc0419 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1905,6 +1905,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
     virStorageSourceFree(def->src);
     VIR_FREE(def->dst);
     virDomainDeviceInfoClear(&def->info);
+    VIR_FREE(def->virtio);
 
     VIR_FREE(def);
 }
@@ -9451,6 +9452,9 @@ virDomainFSDefParseXML(xmlNodePtr node,
             goto error;
     }
 
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
+        goto error;
+
     def->src->path = source;
     source = NULL;
     def->dst = target;
@@ -19246,6 +19250,10 @@ virDomainFsDefCheckABIStability(virDomainFSDefPtr src,
         return false;
     }
 
+    if (src->virtio && dst->virtio &&
+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
+        return false;
+
     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
         return false;
 
@@ -21713,6 +21721,8 @@ virDomainFSDefFormat(virBufferPtr buf,
 
     }
 
+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
+
     if (virBufferUse(&driverBuf)) {
         virBufferAddLit(buf, "<driver");
         virBufferAddBuffer(buf, &driverBuf);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 205c9e27b1..fdd852c29d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -876,6 +876,7 @@ struct _virDomainFSDef {
     unsigned long long space_hard_limit; /* in bytes */
     unsigned long long space_soft_limit; /* in bytes */
     bool symlinksResolved;
+    virDomainVirtioOptionsPtr virtio;
 };
 
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
index 867e56c107..33da214611 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
@@ -36,12 +36,13 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
     </controller>
     <filesystem type='mount' accessmode='passthrough'>
+      <driver iommu='on' ats='on'/>
       <source dir='/export/fs1'/>
       <target dir='fs1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </filesystem>
     <filesystem type='mount' accessmode='mapped'>
-      <driver type='path' wrpolicy='immediate'/>
+      <driver type='path' wrpolicy='immediate' iommu='on' ats='on'/>
       <source dir='/export/fs2'/>
       <target dir='fs2'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
-- 
2.13.1