render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 6abf3f12df5173dc12af69827fbee98811f83959 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <6abf3f12df5173dc12af69827fbee98811f83959@dist-git>
3e5111
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
3e5111
Date: Fri, 9 Jun 2017 12:49:06 +0200
3e5111
Subject: [PATCH] Add virtio-related options to video
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 f5384fb4029a59624e728a2e0d37e6a62efbdc52)
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                          | 12 ++++++++++
3e5111
 docs/schemas/domaincommon.rng                      |  5 ++++
3e5111
 src/conf/domain_conf.c                             | 27 ++++++++++++++++++++--
3e5111
 src/conf/domain_conf.h                             |  1 +
3e5111
 .../qemuxml2argv-virtio-options.xml                |  1 +
3e5111
 5 files changed, 44 insertions(+), 2 deletions(-)
3e5111
3e5111
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
3e5111
index 2e5c669c4a..6be015f866 100644
3e5111
--- a/docs/formatdomain.html.in
3e5111
+++ b/docs/formatdomain.html.in
3e5111
@@ -6133,6 +6133,18 @@ qemu-kvm -net nic,model=? /dev/null
3e5111
         The optional address sub-element can be used to
3e5111
         tie the video device to a particular PCI slot.
3e5111
       
3e5111
+
3e5111
+      
driver
3e5111
+      
3e5111
+        The subelement driver can be used to tune the device:
3e5111
+        
3e5111
+          
virtio options
3e5111
+          
3e5111
+          Virtio-specific options can also be
3e5111
+          set. (Since 3.5.0)
3e5111
+          
3e5111
+        
3e5111
+      
3e5111
     
3e5111
 
3e5111
     

Consoles, serial, parallel & channel devices

3e5111
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
3e5111
index 7e80275029..ee49d6eb58 100644
3e5111
--- a/docs/schemas/domaincommon.rng
3e5111
+++ b/docs/schemas/domaincommon.rng
3e5111
@@ -3165,6 +3165,11 @@
3e5111
   <define name="video">
3e5111
     <element name="video">
3e5111
       <optional>
3e5111
+        <element name="driver">
3e5111
+          <ref name="virtioOptions"/>
3e5111
+        </element>
3e5111
+      </optional>
3e5111
+      <optional>
3e5111
         <element name="model">
3e5111
           <choice>
3e5111
             <attribute name="type">
3e5111
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
3e5111
index 059c006b69..a0de639e51 100644
3e5111
--- a/src/conf/domain_conf.c
3e5111
+++ b/src/conf/domain_conf.c
3e5111
@@ -2339,6 +2339,7 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
3e5111
     virDomainDeviceInfoClear(&def->info);
3e5111
 
3e5111
     VIR_FREE(def->accel);
3e5111
+    VIR_FREE(def->virtio);
3e5111
     VIR_FREE(def);
3e5111
 }
3e5111
 
3e5111
@@ -13499,11 +13500,13 @@ virDomainVideoAccelDefParseXML(xmlNodePtr node)
3e5111
 
3e5111
 static virDomainVideoDefPtr
3e5111
 virDomainVideoDefParseXML(xmlNodePtr node,
3e5111
+                          xmlXPathContextPtr ctxt,
3e5111
                           const virDomainDef *dom,
3e5111
                           unsigned int flags)
3e5111
 {
3e5111
     virDomainVideoDefPtr def;
3e5111
     xmlNodePtr cur;
3e5111
+    xmlNodePtr saved = ctxt->node;
3e5111
     char *type = NULL;
3e5111
     char *heads = NULL;
3e5111
     char *vram = NULL;
3e5111
@@ -13512,6 +13515,8 @@ virDomainVideoDefParseXML(xmlNodePtr node,
3e5111
     char *vgamem = NULL;
3e5111
     char *primary = NULL;
3e5111
 
3e5111
+    ctxt->node = node;
3e5111
+
3e5111
     if (VIR_ALLOC(def) < 0)
3e5111
         return NULL;
3e5111
 
3e5111
@@ -13613,7 +13618,12 @@ virDomainVideoDefParseXML(xmlNodePtr node,
3e5111
     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
+    ctxt->node = saved;
3e5111
+
3e5111
     VIR_FREE(type);
3e5111
     VIR_FREE(ram);
3e5111
     VIR_FREE(vram);
3e5111
@@ -14412,7 +14422,7 @@ virDomainDeviceDefParse(const char *xmlStr,
3e5111
             goto error;
3e5111
         break;
3e5111
     case VIR_DOMAIN_DEVICE_VIDEO:
3e5111
-        if (!(dev->data.video = virDomainVideoDefParseXML(node, def, flags)))
3e5111
+        if (!(dev->data.video = virDomainVideoDefParseXML(node, ctxt, def, flags)))
3e5111
             goto error;
3e5111
         break;
3e5111
     case VIR_DOMAIN_DEVICE_HOSTDEV:
3e5111
@@ -18347,7 +18357,7 @@ virDomainDefParseXML(xmlDocPtr xml,
3e5111
         virDomainVideoDefPtr video;
3e5111
         ssize_t insertAt = -1;
3e5111
 
3e5111
-        if (!(video = virDomainVideoDefParseXML(nodes[i], def, flags)))
3e5111
+        if (!(video = virDomainVideoDefParseXML(nodes[i], ctxt, def, flags)))
3e5111
             goto error;
3e5111
 
3e5111
         if (video->primary) {
3e5111
@@ -19414,6 +19424,10 @@ virDomainVideoDefCheckABIStability(virDomainVideoDefPtr src,
3e5111
         }
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
@@ -23332,6 +23346,7 @@ virDomainVideoDefFormat(virBufferPtr buf,
3e5111
                         unsigned int flags)
3e5111
 {
3e5111
     const char *model = virDomainVideoTypeToString(def->type);
3e5111
+    virBuffer driverBuf = VIR_BUFFER_INITIALIZER;
3e5111
 
3e5111
     if (!model) {
3e5111
         virReportError(VIR_ERR_INTERNAL_ERROR,
3e5111
@@ -23341,6 +23356,14 @@ virDomainVideoDefFormat(virBufferPtr buf,
3e5111
 
3e5111
     virBufferAddLit(buf, "<video>\n");
3e5111
     virBufferAdjustIndent(buf, 2);
3e5111
+    virDomainVirtioOptionsFormat(&driverBuf, def->virtio);
3e5111
+    if (virBufferCheckError(&driverBuf) < 0)
3e5111
+        return -1;
3e5111
+    if (virBufferUse(&driverBuf)) {
3e5111
+        virBufferAddLit(buf, "
3e5111
+        virBufferAddBuffer(buf, &driverBuf);
3e5111
+        virBufferAddLit(buf, "/>\n");
3e5111
+    }
3e5111
     virBufferAsprintf(buf, "
3e5111
                       model);
3e5111
     if (def->ram)
3e5111
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
3e5111
index 8cb9d5d0b1..b79fb50c79 100644
3e5111
--- a/src/conf/domain_conf.h
3e5111
+++ b/src/conf/domain_conf.h
3e5111
@@ -1376,6 +1376,7 @@ struct _virDomainVideoDef {
3e5111
     bool primary;
3e5111
     virDomainVideoAccelDefPtr accel;
3e5111
     virDomainDeviceInfo info;
3e5111
+    virDomainVirtioOptionsPtr virtio;
3e5111
 };
3e5111
 
3e5111
 /* graphics console modes */
3e5111
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
index b7b95014cd..85d1145263 100644
3e5111
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml
3e5111
@@ -69,6 +69,7 @@
3e5111
     <input type='mouse' bus='ps2'/>
3e5111
     <input type='keyboard' bus='ps2'/>
3e5111
     <video>
3e5111
+      <driver iommu='on' ats='on'/>
3e5111
       <model type='virtio' heads='1' primary='yes'>
3e5111
         <acceleration accel3d='yes'/>
3e5111
       </model>
3e5111
-- 
3e5111
2.13.1
3e5111