6d3351
From f9a338cd5d0477291a0001a527d0add941f7ea37 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <f9a338cd5d0477291a0001a527d0add941f7ea37@dist-git>
6d3351
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
6d3351
Date: Fri, 9 Jun 2017 12:49:01 +0200
6d3351
Subject: [PATCH] add virtio-related options to memballoon
6d3351
MIME-Version: 1.0
6d3351
Content-Type: text/plain; charset=UTF-8
6d3351
Content-Transfer-Encoding: 8bit
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1283251
6d3351
6d3351
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6d3351
(cherry picked from commit 82223f9364a9f47a39b7c66c241b82ae62f9fb4b)
6d3351
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 docs/formatdomain.html.in                          |  7 +++++++
6d3351
 docs/schemas/domaincommon.rng                      |  5 +++++
6d3351
 src/conf/domain_conf.c                             | 24 ++++++++++++++++++++++
6d3351
 src/conf/domain_conf.h                             |  1 +
6d3351
 .../qemuxml2argv-virtio-options.xml                |  1 +
6d3351
 5 files changed, 38 insertions(+)
6d3351
6d3351
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
6d3351
index 23546daae9..2556f383fc 100644
6d3351
--- a/docs/formatdomain.html.in
6d3351
+++ b/docs/formatdomain.html.in
6d3351
@@ -6913,6 +6913,7 @@ qemu-kvm -net nic,model=? /dev/null
6d3351
     <memballoon model='virtio'>
6d3351
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
6d3351
       <stats period='10'/>
6d3351
+      <driver iommu='on' ats='on'/>
6d3351
     </memballoon>
6d3351
   </devices>
6d3351
 </domain>
6d3351
@@ -6957,6 +6958,12 @@ qemu-kvm -net nic,model=? /dev/null
6d3351
           Since 1.1.1, requires QEMU 1.5
6d3351
         

6d3351
       
6d3351
+      
driver
6d3351
+      
6d3351
+        For model virtio memballoon,
6d3351
+        Virtio-specific options can also be
6d3351
+        set. (Since 3.5.0)
6d3351
+      
6d3351
     
6d3351
     

Random number generator device

6d3351
 
6d3351
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
6d3351
index 9e68bbc52d..f571af6706 100644
6d3351
--- a/docs/schemas/domaincommon.rng
6d3351
+++ b/docs/schemas/domaincommon.rng
6d3351
@@ -3730,6 +3730,11 @@
6d3351
             </attribute>
6d3351
           </element>
6d3351
         </optional>
6d3351
+        <optional>
6d3351
+          <element name="driver">
6d3351
+            <ref name="virtioOptions"/>
6d3351
+          </element>
6d3351
+        </optional>
6d3351
       </interleave>
6d3351
     </element>
6d3351
   </define>
6d3351
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
6d3351
index bba50cf3fd..4768d02029 100644
6d3351
--- a/src/conf/domain_conf.c
6d3351
+++ b/src/conf/domain_conf.c
6d3351
@@ -2292,6 +2292,7 @@ void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def)
6d3351
         return;
6d3351
 
6d3351
     virDomainDeviceInfoClear(&def->info);
6d3351
+    VIR_FREE(def->virtio);
6d3351
 
6d3351
     VIR_FREE(def);
6d3351
 }
6d3351
@@ -12970,6 +12971,9 @@ virDomainMemballoonDefParseXML(xmlNodePtr node,
6d3351
     else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
6d3351
         goto error;
6d3351
 
6d3351
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
6d3351
+        goto error;
6d3351
+
6d3351
  cleanup:
6d3351
     VIR_FREE(model);
6d3351
     VIR_FREE(deflate);
6d3351
@@ -19582,6 +19586,10 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src,
6d3351
         return false;
6d3351
     }
6d3351
 
6d3351
+    if (src->virtio && dst->virtio &&
6d3351
+        !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
6d3351
+        return false;
6d3351
+
6d3351
     if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
6d3351
         return false;
6d3351
 
6d3351
@@ -22934,6 +22942,22 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
6d3351
         return -1;
6d3351
     }
6d3351
 
6d3351
+    if (def->virtio) {
6d3351
+        virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
6d3351
+
6d3351
+        virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
6d3351
+
6d3351
+        if (virBufferCheckError(&driverBuf) < 0) {
6d3351
+            virBufferFreeAndReset(&childrenBuf);
6d3351
+            return -1;
6d3351
+        }
6d3351
+        if (virBufferUse(&driverBuf)) {
6d3351
+            virBufferAddLit(&childrenBuf, "
6d3351
+            virBufferAddBuffer(&childrenBuf, &driverBuf);
6d3351
+            virBufferAddLit(&childrenBuf, "/>\n");
6d3351
+        }
6d3351
+    }
6d3351
+
6d3351
     if (!virBufferUse(&childrenBuf)) {
6d3351
         virBufferAddLit(buf, "/>\n");
6d3351
     } else {
6d3351
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
6d3351
index 603d35bd50..f1f9208b91 100644
6d3351
--- a/src/conf/domain_conf.h
6d3351
+++ b/src/conf/domain_conf.h
6d3351
@@ -1609,6 +1609,7 @@ struct _virDomainMemballoonDef {
6d3351
     virDomainDeviceInfo info;
6d3351
     int period; /* seconds between collections */
6d3351
     int autodeflate; /* enum virTristateSwitch */
6d3351
+    virDomainVirtioOptionsPtr virtio;
6d3351
 };
6d3351
 
6d3351
 struct _virDomainNVRAMDef {
6d3351
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
6d3351
index 3357bc6d1b..b16a9847fe 100644
6d3351
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
6d3351
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
6d3351
@@ -73,6 +73,7 @@
6d3351
     </video>
6d3351
     <memballoon model='virtio'>
6d3351
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
6d3351
+      <driver iommu='on' ats='on'/>
6d3351
     </memballoon>
6d3351
     <rng model='virtio'>
6d3351
       <backend model='random'>/dev/random</backend>
6d3351
-- 
6d3351
2.13.1
6d3351