[PATCHv2 12/15] Add virtio-related options to video

[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                          | 12 +++++++++++
 docs/schemas/domaincommon.rng                      |  5 +++++
 src/conf/domain_conf.c                             | 24 ++++++++++++++++++++--
 src/conf/domain_conf.h                             |  1 +
 .../qemuxml2argv-virtio-options.xml                |  1 +
 .../qemuxml2xmlout-virtio-options.xml              |  1 +
 6 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index a546cbb..5c0f3bf 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6136,6 +6136,18 @@ qemu-kvm -net nic,model=? /dev/null
         The optional <code>address</code> sub-element can be used to
         tie the video device to a particular PCI slot.
       </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>
 
     <h4><a name="elementsConsole">Consoles, serial, parallel &amp; channel devices</a></h4>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3909a56..3df4fa4 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3219,6 +3219,11 @@
   <define name="video">
     <element name="video">
       <optional>
+        <element name="driver">
+          <ref name="virtioOptions"/>
+        </element>
+      </optional>
+      <optional>
         <element name="model">
           <choice>
             <attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f92fecc..9381551 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2338,6 +2338,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
     virDomainDeviceInfoClear(&def->info);
 
     VIR_FREE(def->accel);
+    VIR_FREE(def->virtio);
     VIR_FREE(def);
 }
 
@@ -13478,11 +13479,13 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
 
 static virDomainVideoDefPtr
 virDomainVideoDefParseXML(xmlNodePtr node,
+                          xmlXPathContextPtr ctxt,
                           const virDomainDef *dom,
                           unsigned int flags)
 {
     virDomainVideoDefPtr def;
     xmlNodePtr cur;
+    xmlNodePtr saved = ctxt->node;
     char *type = NULL;
     char *heads = NULL;
     char *vram = NULL;
@@ -13491,6 +13494,8 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     char *vgamem = NULL;
     char *primary = NULL;
 
+    ctxt->node = node;
+
     if (VIR_ALLOC(def) < 0)
         return NULL;
 
@@ -13592,7 +13597,12 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
         goto error;
 
+    if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0)
+        goto error;
+
  cleanup:
+    ctxt->node = saved;
+
     VIR_FREE(type);
     VIR_FREE(ram);
     VIR_FREE(vram);
@@ -14391,7 +14401,7 @@ virDomainDeviceDefParse(const char *xmlStr,
             goto error;
         break;
     case VIR_DOMAIN_DEVICE_VIDEO:
-        if (!(dev->data.video = virDomainVideoDefParseXML(node, def, flags)))
+        if (!(dev->data.video = virDomainVideoDefParseXML(node, ctxt, def, flags)))
             goto error;
         break;
     case VIR_DOMAIN_DEVICE_HOSTDEV:
@@ -18334,7 +18344,7 @@ virDomainDefParseXML(xmlDocPtr xml,
         virDomainVideoDefPtr video;
         ssize_t insertAt = -1;
 
-        if (!(video = virDomainVideoDefParseXML(nodes[i], def, flags)))
+        if (!(video = virDomainVideoDefParseXML(nodes[i], ctxt, def, flags)))
             goto error;
 
         if (video->primary) {
@@ -23290,6 +23300,7 @@ virDomainVideoDefFormat(virBufferPtr buf,
                         unsigned int flags)
 {
     const char *model = virDomainVideoTypeToString(def->type);
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
 
     if (!model) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -23299,6 +23310,15 @@ virDomainVideoDefFormat(virBufferPtr buf,
 
     virBufferAddLit(buf, "<video>\n");
     virBufferAdjustIndent(buf, 2);
+    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");
+    }
     virBufferAsprintf(buf, "<model type='%s'",
                       model);
     if (def->ram)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f1887ac..3ee187e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1383,6 +1383,7 @@ struct _virDomainVideoDef {
     bool primary;
     virDomainVideoAccelDefPtr accel;
     virDomainDeviceInfo info;
+    virDomainVirtioOptionsPtr virtio;
 };
 
 /* graphics console modes */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
index e852894..be702cb 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
@@ -81,6 +81,7 @@
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <video>
+      <driver iommu_platform='on' ats='on'/>
       <model type='virtio' heads='1' primary='yes'>
         <acceleration accel3d='yes'/>
       </model>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
index e852894..be702cb 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-options.xml
@@ -81,6 +81,7 @@
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <video>
+      <driver iommu_platform='on' ats='on'/>
       <model type='virtio' heads='1' primary='yes'>
         <acceleration accel3d='yes'/>
       </model>
-- 
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