[PATCHv2 11/15] Add virtio-related options to rng devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=1283251
---
 docs/formatdomain.html.in                                | 11 +++++++++++
 docs/schemas/domaincommon.rng                            |  5 +++++
 src/conf/domain_conf.c                                   | 16 ++++++++++++++++
 src/conf/domain_conf.h                                   |  1 +
 tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml   |  1 +
 .../qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml |  1 +
 6 files changed, 35 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index ef30079..a546cbb 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -7064,6 +7064,17 @@ qemu-kvm -net nic,model=? /dev/null
           </dd>
         </dl>
       </dd>
+      <dt><code>driver</code></dt>
+      <dd>
+        The subelement <code>driver</code> can be used to tune the device:
+        <dl>
+          <dt>virtio options</dt>
+          <dd>
+          <a href="#elementsVirtio">Virtio-specific options</a> can also be
+          set. (<span class="since">Since 3.5.0</span>)
+          </dd>
+        </dl>
+      </dd>
 
     </dl>
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3608f84..3909a56 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4966,6 +4966,11 @@
       <interleave>
         <ref name="rng-backend"/>
         <optional>
+          <element name="driver">
+            <ref name="virtioOptions"/>
+          </element>
+        </optional>
+        <optional>
           <ref name="rng-rate"/>
         </optional>
         <optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e1b785a..f92fecc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12902,6 +12902,9 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlopt,
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
         goto error;
 
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
+        goto error;
+
  cleanup:
     VIR_FREE(model);
     VIR_FREE(backend);
@@ -23093,6 +23096,7 @@ virDomainRNGDefFormat(virBufferPtr buf,
 {
     const char *model = virDomainRNGModelTypeToString(def->model);
     const char *backend = virDomainRNGBackendTypeToString(def->backend);
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
 
     virBufferAsprintf(buf, "<rng model='%s'>\n", model);
     virBufferAdjustIndent(buf, 2);
@@ -23121,6 +23125,17 @@ virDomainRNGDefFormat(virBufferPtr buf,
         break;
     }
 
+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
+    if (virBufferCheckError(&driverBuf) < 0)
+        return -1;
+
+    if (virBufferUse(&driverBuf)) {
+        virBufferTrim(&driverBuf, " ", -1);
+        virBufferAddLit(buf, "<driver ");
+        virBufferAddBuffer(buf, &driverBuf);
+        virBufferAddLit(buf, "/>\n");
+    }
+
     if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
         if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
             return -1;
@@ -23149,6 +23164,7 @@ virDomainRNGDefFree(virDomainRNGDefPtr def)
     }
 
     virDomainDeviceInfoClear(&def->info);
+    VIR_FREE(def->virtio);
     VIR_FREE(def);
 }
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b9ca8a0..f1887ac 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2027,6 +2027,7 @@ struct _virDomainRNGDef {
     } source;
 
     virDomainDeviceInfo info;
+    virDomainVirtioOptionsPtr virtio;
 };
 
 typedef enum {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
index 4fc17d2..e852894 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
@@ -92,6 +92,7 @@
     </memballoon>
     <rng model='virtio'>
       <backend model='random'>/dev/random</backend>
+      <driver iommu_platform='on' ats='on'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
     </rng>
   </devices>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
index 4fc17d2..e852894 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
@@ -92,6 +92,7 @@
     </memballoon>
     <rng model='virtio'>
       <backend model='random'>/dev/random</backend>
+      <driver iommu_platform='on' ats='on'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
     </rng>
   </devices>
-- 
2.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux