[[PATCHv2]] Add support for qxl.revision in domain XML

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

 



QXL devices have an associated 'revision' which is raised when
new features have been introduced which would break migration
to older versions. This commit makes it possible to set this
revision as QEMU sometimes support newer QXL revisions than what
it defaults to.
---
 docs/formatdomain.html.in                            |  4 +++-
 docs/schemas/domaincommon.rng                        |  5 +++++
 src/conf/domain_conf.c                               | 20 ++++++++++++++++++++
 src/conf/domain_conf.h                               |  1 +
 src/qemu/qemu_command.c                              |  8 ++++++++
 .../qemuxml2argv-graphics-spice-compression.args     |  3 ++-
 .../qemuxml2argv-graphics-spice-compression.xml      |  4 ++--
 .../qemuxml2argv-graphics-spice-qxl-vga.args         |  3 ++-
 .../qemuxml2argv-graphics-spice-qxl-vga.xml          |  4 ++--
 .../qemuxml2argv-graphics-spice.args                 |  3 ++-
 .../qemuxml2argvdata/qemuxml2argv-graphics-spice.xml |  4 ++--
 11 files changed, 49 insertions(+), 10 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index a9003d7..bcdd90f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3584,7 +3584,9 @@ qemu-kvm -net nic,model=? /dev/null
         1.0.2</span>) is allowed for "qxl" type only and specifies
         the size of the primary bar, while <code>vram</code> specifies the
         secondary bar size.  If "ram" or "vram" are not supplied a default
-        value is used.
+        value is used. The optional attribute <code>revision</code> (<span
+        class="since">since 1.0.3</span>) specifies the revision of
+        the QXL device, newer revisions provide more functionality.
       </dd>
 
       <dt><code>model</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 63be4aa..57128ab 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2283,6 +2283,11 @@
                   <ref name="unsignedInt"/>
                 </attribute>
               </optional>
+              <optional>
+                <attribute name="revision">
+                  <ref name="unsignedInt"/>
+                </attribute>
+              </optional>
             </group>
           </choice>
           <optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0c75838..f4f273c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7646,6 +7646,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
     char *vram = NULL;
     char *ram = NULL;
     char *primary = NULL;
+    char *revision = NULL;
 
     if (VIR_ALLOC(def) < 0) {
         virReportOOMError();
@@ -7661,6 +7662,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
                 ram = virXMLPropString(cur, "ram");
                 vram = virXMLPropString(cur, "vram");
                 heads = virXMLPropString(cur, "heads");
+                revision = virXMLPropString(cur, "revision");
 
                 if ((primary = virXMLPropString(cur, "primary")) != NULL) {
                     if (STREQ(primary, "yes"))
@@ -7713,6 +7715,19 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
         def->vram = virDomainVideoDefaultRAM(dom, def->type);
     }
 
+    if (revision) {
+        if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("revision attribute only supported for type of qxl"));
+            goto error;
+        }
+        if (virStrToLong_ui(revision, NULL, 10, &def->revision) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse video revision '%s'"), revision);
+            goto error;
+        }
+    }
+
     if (heads) {
         if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -7730,6 +7745,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
     VIR_FREE(ram);
     VIR_FREE(vram);
     VIR_FREE(heads);
+    VIR_FREE(revision);
 
     return def;
 
@@ -7739,6 +7755,8 @@ error:
     VIR_FREE(ram);
     VIR_FREE(vram);
     VIR_FREE(heads);
+    VIR_FREE(revision);
+
     return NULL;
 }
 
@@ -13632,6 +13650,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
         virBufferAsprintf(buf, " heads='%u'", def->heads);
     if (def->primary)
         virBufferAddLit(buf, " primary='yes'");
+    if (def->revision)
+        virBufferAsprintf(buf, " revision='%u'", def->revision);
     if (def->accel) {
         virBufferAddLit(buf, ">\n");
         virDomainVideoAccelDefFormat(buf, def->accel);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4ffa4aa..1d7951b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1174,6 +1174,7 @@ struct _virDomainVideoDef {
     unsigned int ram;  /* kibibytes (multiples of 1024) */
     unsigned int vram; /* kibibytes (multiples of 1024) */
     unsigned int heads;
+    unsigned int revision;
     bool primary;
     virDomainVideoAccelDefPtr accel;
     virDomainDeviceInfo info;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dee493f..5164bd5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3567,6 +3567,9 @@ qemuBuildDeviceVideoStr(virDomainVideoDefPtr video,
 
         /* QEMU accepts bytes for vram_size. */
         virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
+
+        if (video->revision != 0)
+            virBufferAsprintf(&buf, ",revision=%u", video->revision);
     }
 
     if (qemuBuildDeviceAddressStr(&buf, &video->info, qemuCaps) < 0)
@@ -6612,6 +6615,11 @@ qemuBuildCommandLine(virConnectPtr conn,
                         virCommandAddArgFormat(cmd, "%s.vram_size=%u",
                                                dev, vram * 1024);
                     }
+                    if (def->videos[0]->revision) {
+                        virCommandAddArg(cmd, "-global");
+                        virCommandAddArgFormat(cmd, "%s.revision=%u",
+                                               dev, def->videos[0]->revision);
+                    }
                 }
             }
 
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
index 59f064b..05f5579 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
@@ -7,5 +7,6 @@ image-compression=auto_glz,jpeg-wan-compression=auto,\
 zlib-glz-wan-compression=auto,\
 playback-compression=on,streaming-video=filter -vga \
 qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 \
--device qxl,id=video1,ram_size=67108864,vram_size=33554432,bus=pci.0,addr=0x4 \
+-global qxl.revision=4 \
+-device qxl,id=video1,ram_size=67108864,vram_size=33554432,revision=4,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
index a8c4ad8..2dc5776 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
@@ -31,10 +31,10 @@
       <streaming mode='filter'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' heads='1' revision='4'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' heads='1' revision='4'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
index ef499e6..0b08038 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
@@ -4,5 +4,6 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \
 /dev/HostVG/QEMUGuest1 -spice port=5903,tls-port=5904,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs -vga \
 qxl -global qxl-vga.ram_size=67108864 -global qxl-vga.vram_size=33554432 \
--device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x4 \
+-global qxl-vga.revision=4 \
+-device qxl,id=video1,ram_size=67108864,vram_size=67108864,revision=4,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
index 563d371..3cd0c42 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
@@ -28,10 +28,10 @@
       <channel name='inputs' mode='insecure'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' heads='1' revision='4'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='65536' heads='1'/>
+      <model type='qxl' ram='65536' vram='65536' heads='1' revision='4'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
index d7cfae0..082eaf7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
@@ -6,5 +6,6 @@ x509-dir=/etc/pki/libvirt-spice,tls-channel=default,tls-channel=main,plaintext-c
 image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
 playback-compression=on,streaming-video=filter,disable-copy-paste -vga \
 qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 \
--device qxl,id=video1,ram_size=67108864,vram_size=33554432,bus=pci.0,addr=0x4 \
+-global qxl.revision=4 \
+-device qxl,id=video1,ram_size=67108864,vram_size=33554432,revision=4,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
index 9a36660..e99dbc8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
@@ -34,10 +34,10 @@
       <clipboard copypaste='no'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' heads='1' revision='4'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' heads='1' revision='4'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
-- 
1.8.1.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]