]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu-command: introduce new vgamem attribute for QXL video device
authorPavel Hrdina <phrdina@redhat.com>
Thu, 20 Nov 2014 18:52:00 +0000 (19:52 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 24 Nov 2014 21:20:13 +0000 (22:20 +0100)
Add attribute to set vgamem_mb parameter of QXL device for QEMU. This
value sets the size of VGA framebuffer for QXL device. Default value in
QEMU is 8MB so reuse it also in libvirt to not break things.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1076098

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
16 files changed:
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/conf/domain_conf.h
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
tests/qemuxml2argvdata/qemuxml2argv-q35.xml
tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-device-vgamem.args
tests/qemuxml2argvdata/qemuxml2argv-video-qxl-sec-device-vgamem.args
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml

index 1a7eeaefbef9b53823c9d63193dbea96110c64fa..9c1d0f406ed6976e4acd0be63b40930d15391661 100644 (file)
@@ -4732,7 +4732,10 @@ qemu-kvm -net nic,model=? /dev/null
           only and specifies the size of the primary bar, while the optional
           attribute <code>vram</code> specifies the secondary bar size.
           If "ram" or "vram" are not supplied a default value is used. The ram
-          should also be rounded to power of two as vram.
+          should also be rounded to power of two as vram. There is also optional
+          attribute <code>vgamem</code> (<span class="since">since 1.2.11 (QEMU
+          only)</span>) to set the size of VGA framebuffer for fallback mode of
+          QXL device.
         </p>
       </dd>
 
index ae5c253a63457153bdefaf6a945ce07c1fe2c00b..cd354854eeaf695d66bc450965ed6787910a3f38 100644 (file)
                   <ref name="unsignedInt"/>
                 </attribute>
               </optional>
+              <optional>
+                <attribute name="vgamem">
+                  <ref name="unsignedInt"/>
+                </attribute>
+              </optional>
             </group>
           </choice>
           <optional>
index f187ee78d22691ae24c21d58625ce16c9c0285b0..870cca0530871f4a851096813638a71c5b2014a2 100644 (file)
@@ -10272,6 +10272,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     char *heads = NULL;
     char *vram = NULL;
     char *ram = NULL;
+    char *vgamem = NULL;
     char *primary = NULL;
 
     if (VIR_ALLOC(def) < 0)
@@ -10285,6 +10286,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
                 type = virXMLPropString(cur, "type");
                 ram = virXMLPropString(cur, "ram");
                 vram = virXMLPropString(cur, "vram");
+                vgamem = virXMLPropString(cur, "vgamem");
                 heads = virXMLPropString(cur, "heads");
 
                 if ((primary = virXMLPropString(cur, "primary")) != NULL) {
@@ -10338,6 +10340,19 @@ virDomainVideoDefParseXML(xmlNodePtr node,
         def->vram = virDomainVideoDefaultRAM(dom, def->type);
     }
 
+    if (vgamem) {
+        if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("vgamem attribute only supported for type of qxl"));
+            goto error;
+        }
+        if (virStrToLong_ui(vgamem, NULL, 10, &def->vgamem) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse video vgamem '%s'"), vgamem);
+            goto error;
+        }
+    }
+
     if (heads) {
         if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -10354,6 +10369,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     VIR_FREE(type);
     VIR_FREE(ram);
     VIR_FREE(vram);
+    VIR_FREE(vgamem);
     VIR_FREE(heads);
 
     return def;
@@ -10363,6 +10379,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     VIR_FREE(type);
     VIR_FREE(ram);
     VIR_FREE(vram);
+    VIR_FREE(vgamem);
     VIR_FREE(heads);
     return NULL;
 }
@@ -14739,6 +14756,13 @@ virDomainVideoDefCheckABIStability(virDomainVideoDefPtr src,
         return false;
     }
 
+    if (src->vgamem != dst->vgamem) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       _("Target video card vgamem %u does not match source %u"),
+                       dst->vgamem, src->vgamem);
+        return false;
+    }
+
     if (src->heads != dst->heads) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("Target video card heads %u does not match source %u"),
@@ -18119,6 +18143,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
         virBufferAsprintf(buf, " ram='%u'", def->ram);
     if (def->vram)
         virBufferAsprintf(buf, " vram='%u'", def->vram);
+    if (def->vgamem)
+        virBufferAsprintf(buf, " vgamem='%u'", def->vgamem);
     if (def->heads)
         virBufferAsprintf(buf, " heads='%u'", def->heads);
     if (def->primary)
index ffe1be657016323027258628c251f337df50a90c..d4284514e1e5816f884c60fac32c16fa6d18d0ee 100644 (file)
@@ -1293,6 +1293,7 @@ struct _virDomainVideoDef {
     int type;
     unsigned int ram;  /* kibibytes (multiples of 1024) */
     unsigned int vram; /* kibibytes (multiples of 1024) */
+    unsigned int vgamem; /* kibibytes (multiples of 1024) */
     unsigned int heads;
     bool primary;
     virDomainVideoAccelDefPtr accel;
index 1003a0d4181e9e5abd137c645568172d8d97e67c..4ed650648312e1dd12b8c3d3389d634105ff772e 100644 (file)
@@ -4911,6 +4911,12 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
             /* QEMU accepts bytes for vram_size. */
             virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
         }
+
+        if ((primary && virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VGAMEM)) ||
+            (!primary && virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGAMEM))) {
+            /* QEMU accepts mebibytes for vgamem_mb. */
+            virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vgamem / 1024);
+        }
     } else if (video->vram &&
         ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
           virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
@@ -9244,6 +9250,7 @@ qemuBuildCommandLine(virConnectPtr conn,
                     virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
                     unsigned int ram = def->videos[0]->ram;
                     unsigned int vram = def->videos[0]->vram;
+                    unsigned int vgamem = def->videos[0]->vgamem;
 
                     if (vram > (UINT_MAX / 1024)) {
                         virReportError(VIR_ERR_OVERFLOW,
@@ -9268,6 +9275,12 @@ qemuBuildCommandLine(virConnectPtr conn,
                         virCommandAddArgFormat(cmd, "%s.vram_size=%u",
                                                dev, vram * 1024);
                     }
+                    if (vgamem &&
+                        virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VGAMEM)) {
+                        virCommandAddArg(cmd, "-global");
+                        virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
+                                               dev, vgamem / 1024);
+                    }
                 }
 
                 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
@@ -12284,8 +12297,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
         else
             vid->type = video;
         vid->vram = virDomainVideoDefaultRAM(def, vid->type);
-        vid->ram = vid->type == VIR_DOMAIN_VIDEO_TYPE_QXL ?
-                       virDomainVideoDefaultRAM(def, vid->type) : 0;
+        if (vid->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            vid->ram = virDomainVideoDefaultRAM(def, vid->type);
+            vid->vgamem = 8 * 1024;
+        } else {
+            vid->ram = 0;
+            vid->vgamem = 0;
+        }
         vid->heads = 1;
 
         if (VIR_APPEND_ELEMENT(def->videos, def->nvideos, vid) < 0) {
index 01bf39b4800f16435afc19942c45de909c262fb1..334bd407d9aa2d8a67e8188de782c9ddc668fe7a 100644 (file)
@@ -1176,6 +1176,25 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
         goto cleanup;
     }
 
+    if (dev->type == VIR_DOMAIN_DEVICE_VIDEO &&
+        dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
+        if (dev->data.video->vgamem) {
+            if (dev->data.video->vgamem < 1024) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("value for 'vgamem' must be at least 1 MiB "
+                                 "(1024 KiB)"));
+                goto cleanup;
+            }
+            if (dev->data.video->vgamem != VIR_ROUND_UP_POWER_OF_TWO(dev->data.video->vgamem)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("value for 'vgamem' must be power of two"));
+                goto cleanup;
+            }
+        } else {
+            dev->data.video->vgamem = 8 * 1024;
+        }
+    }
+
     ret = 0;
 
  cleanup:
index 5c9683f9cb69c3f6982efd544da7a1a8198a2671..c13327ad0bce8c740940aedac24d5ac422da5add 100644 (file)
       <streaming mode='filter'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index acf301985f5d07e5bc24142520e28ff9aab192ae..ac705f330a7c44f85903790046a9be91ad0c403c 100644 (file)
       <channel name='inputs' mode='insecure'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='65536' heads='1'/>
+      <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index 335ce69c523fdd22740f573e69680b9c495d7fdc..0c61ee5cf17c06a86f4051f40b83883811abd475 100644 (file)
       <filetransfer enable='no'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index 168b2701bb017967de71a6514dc8338ec2dbcb1c..ef9cd4fd8cbe7473c55c7185879cbe1f235b5300 100644 (file)
@@ -26,7 +26,7 @@
     <controller type='pci' index='2' model='pci-bridge'/>
     <controller type='sata' index='0'/>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>
index 02df713771f5ab391d3574e8a9aa74c2059327ce..05967a409c44be677010870f0cf2840e06c95dc7 100644 (file)
@@ -23,7 +23,7 @@
     <controller type='pci' index='1' model='dmi-to-pci-bridge'/>
     <controller type='pci' index='2' model='pci-bridge'/>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>
index 905924eaae28c40c71d7bc70dfbd10fec167a443..1127db10c09fed193e61fbc3bdd09fd591a191e1 100644 (file)
@@ -37,7 +37,7 @@
       <listen type='address' address='127.0.0.1'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='65536' heads='1'/>
+      <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index c9eb53578be319df75654af9322cb1d8d4d423d2..5398ffe0146585e9c1a5601ba014d958d7acfde6 100644 (file)
@@ -2,5 +2,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 /usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
 -hda /var/lib/libvirt/images/QEMUGuest1 \
--device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
-,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8\
+,bus=pci.0,addr=0x2 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 5fc41bbfa2e8f99e14528bcf9eaa8d87fef6fd2b..82aa0a9d23b562e38704b0d8fb403471f2a367b0 100644 (file)
@@ -2,7 +2,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 /usr/bin/qemu -S -M pc -m 1024 -smp 1 -nographic -nodefaults \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \
 -hda /var/lib/libvirt/images/QEMUGuest1 \
--device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0\
-,addr=0x2 -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0\
-,addr=0x4 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8\
+,bus=pci.0,addr=0x2 -device qxl,id=video1,ram_size=67108864,vram_size=67108864\
+,vgamem_mb=8,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 315e1f414060f580be0e19856c041564c906c389..c7b8ecf2bd9ec7547daa6a5ca2120b513978ca5b 100644 (file)
@@ -1362,13 +1362,15 @@ mymain(void)
     DO_TEST("video-qxl-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_QXL_VGA,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
     DO_TEST("video-qxl-device-vgamem", QEMU_CAPS_DEVICE,
-            QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+            QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
+            QEMU_CAPS_QXL_VGA_VGAMEM);
     DO_TEST_FAILURE("video-qxl-sec-nodevice", QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL);
     DO_TEST("video-qxl-sec-device", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_QXL_VGA,
             QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
     DO_TEST("video-qxl-sec-device-vgamem", QEMU_CAPS_DEVICE,
             QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL,
-            QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
+            QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_QXL_VGA_VGAMEM,
+            QEMU_CAPS_QXL_VGAMEM);
 
     DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_VIRTIO_RNG,
             QEMU_CAPS_OBJECT_RNG_RANDOM);
index 752c7d504a89de8287ce1422eb771ade370e6594..9dd41623ed924e2c5dd34790f1363f42aae88d98 100644 (file)
@@ -24,7 +24,7 @@
     <controller type='pci' index='2' model='pci-bridge'/>
     <controller type='sata' index='0'/>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>