render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From f9a338cd5d0477291a0001a527d0add941f7ea37 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <f9a338cd5d0477291a0001a527d0add941f7ea37@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Fri, 9 Jun 2017 12:49:01 +0200
3e5111
Subject: [PATCH] add virtio-related options to memballoon
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 82223f9364a9f47a39b7c66c241b82ae62f9fb4b)
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                             | 24 ++++++++++++++++++++++
3e5111
 src/conf/domain_conf.h                             |  1 +
3e5111
 .../qemuxml2argv-virtio-options.xml                |  1 +
3e5111
 5 files changed, 38 insertions(+)
3e5111
3e5111
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
3e5111
index 23546daae9..2556f383fc 100644
3e5111
--- a/docs/formatdomain.html.in
3e5111
+++ b/docs/formatdomain.html.in
3e5111
@@ -6913,6 +6913,7 @@ qemu-kvm -net nic,model=? /dev/null
3e5111
     <memballoon model='virtio'>
3e5111
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
3e5111
       <stats period='10'/>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
     </memballoon>
3e5111
   </devices>
3e5111
 </domain>
3e5111
@@ -6957,6 +6958,12 @@ qemu-kvm -net nic,model=? /dev/null
3e5111
           Since 1.1.1, requires QEMU 1.5
3e5111
         

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

Random number generator device

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