]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Support ram bar size for qxl devices
authorAlon Levy <alevy@redhat.com>
Fri, 18 Jan 2013 18:36:36 +0000 (20:36 +0200)
committerEric Blake <eblake@redhat.com>
Tue, 22 Jan 2013 17:40:45 +0000 (10:40 -0700)
Adds a "ram" attribute globally to the video.model element, that changes
the resulting qemu command line only if video.type == "qxl".

<video>
  <model type='qxl' ram='65536' vram='65536' heads='1'/>
</video>

That attribute gets a default value of 64*1024. The schema is unchanged
for other video element types.

The resulting qemu command line change is the addition of

-global qxl-vga.ram_size=<ram>*1024

or

-global qxl.ram_size=<ram>*1024

For the main and secondary qxl devices respectively.

The default for the qxl ram bar is 64*1024 kilobytes (the same as the
default qxl vram bar size).

12 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
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args

index bb0b199c177e91e369c552ffa568f106fb3e9aa5..7ad8aea790c9db16006da3cb305cdc754b4ef1ac 100644 (file)
@@ -3565,7 +3565,11 @@ qemu-kvm -net nic,model=? /dev/null
         video device in domain xml is the primary one, but the optional
         attribute <code>primary</code> (<span class="since">since 1.0.2</span>)
         with value 'yes' can be used to mark the primary in cases of mutiple
-        video device. The non-primary must be type of "qxl".
+        video device. The non-primary must be type of "qxl". The optional
+        attribute <code>ram</code> (<span class="since">since
+        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" is not supplied a default value is used.
       </dd>
 
       <dt><code>model</code></dt>
index 67ae864b39ded43923124f93bd0470422fbe18ce..7f3320e45fe9ad3ff53a4a7591d84659d277f591 100644 (file)
   </define>
   <!--
      A video adapter description, allowing configuration of device
-     model, number of virtual heads, and video ram size
+     model, number of virtual heads, video ram size, and for qxl
+     both ram bar sizes.
    -->
   <define name="video">
     <element name="video">
       <optional>
         <element name="model">
-          <attribute name="type">
-            <choice>
-              <value>vga</value>
-              <value>cirrus</value>
-              <value>vmvga</value>
-              <value>xen</value>
-              <value>vbox</value>
-              <value>qxl</value>
-            </choice>
-          </attribute>
+          <choice>
+            <attribute name="type">
+              <choice>
+                <value>vga</value>
+                <value>cirrus</value>
+                <value>vmvga</value>
+                <value>xen</value>
+                <value>vbox</value>
+              </choice>
+            </attribute>
+            <group>
+              <attribute name="type">
+                <value>qxl</value>
+              </attribute>
+              <optional>
+                <attribute name="ram">
+                  <ref name="unsignedInt"/>
+                </attribute>
+              </optional>
+            </group>
+          </choice>
           <optional>
             <attribute name="vram">
               <ref name="unsignedInt"/>
index ad6a14a4e7e55eb57e3602aab97ab18d7f131351..edbd450eb391d8f121b4bd796fa29552449f5a22 100644 (file)
@@ -7391,6 +7391,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
     char *type = NULL;
     char *heads = NULL;
     char *vram = NULL;
+    char *ram = NULL;
     char *primary = NULL;
 
     if (VIR_ALLOC(def) < 0) {
@@ -7401,9 +7402,10 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if (!type && !vram && !heads &&
+            if (!type && !vram && !ram && !heads &&
                 xmlStrEqual(cur->name, BAD_CAST "model")) {
                 type = virXMLPropString(cur, "type");
+                ram = virXMLPropString(cur, "ram");
                 vram = virXMLPropString(cur, "vram");
                 heads = virXMLPropString(cur, "heads");
 
@@ -7431,9 +7433,24 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
         }
     }
 
+    if (ram) {
+        if (def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                           _("ram attribute only supported for type of qxl"));
+            goto error;
+        }
+        if (virStrToLong_ui(ram, NULL, 10, &def->ram) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse video ram '%s'"), ram);
+            goto error;
+        }
+    } else if (def->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
+        def->ram = virDomainVideoDefaultRAM(dom, def->type);
+    }
+
     if (vram) {
         if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
+            virReportError(VIR_ERR_XML_ERROR,
                            _("cannot parse video ram '%s'"), vram);
             goto error;
         }
@@ -7455,6 +7472,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node,
         goto error;
 
     VIR_FREE(type);
+    VIR_FREE(ram);
     VIR_FREE(vram);
     VIR_FREE(heads);
 
@@ -13384,6 +13402,8 @@ virDomainVideoDefFormat(virBufferPtr buf,
     virBufferAddLit(buf, "    <video>\n");
     virBufferAsprintf(buf, "      <model type='%s'",
                       model);
+    if (def->ram)
+        virBufferAsprintf(buf, " ram='%u'", def->ram);
     if (def->vram)
         virBufferAsprintf(buf, " vram='%u'", def->vram);
     if (def->heads)
index 9770ffb393715b36dde1f6672379570007f1942c..abbfe86d14b0a84e6ca1a0550d6aa8515294ee05 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * domain_conf.h: domain XML processing
  *
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-2013 Red Hat, Inc.
  * Copyright (C) 2006-2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -1157,7 +1157,8 @@ struct _virDomainVideoAccelDef {
 
 struct _virDomainVideoDef {
     int type;
-    unsigned int vram;
+    unsigned int ram;  /* kibibytes (multiples of 1024) */
+    unsigned int vram; /* kibibytes (multiples of 1024) */
     unsigned int heads;
     bool primary;
     virDomainVideoAccelDefPtr accel;
index 981c69205adb8999159b23236fe16018548250df..712b54ecaea5d1a0482860ceae00a6daca332c06 100644 (file)
@@ -3558,11 +3558,20 @@ qemuBuildDeviceVideoStr(virDomainVideoDefPtr video,
 
     if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
         if (video->vram > (UINT_MAX / 1024)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+            virReportError(VIR_ERR_OVERFLOW,
                            _("value for 'vram' must be less than '%u'"),
                            UINT_MAX / 1024);
             goto error;
         }
+        if (video->ram > (UINT_MAX / 1024)) {
+            virReportError(VIR_ERR_OVERFLOW,
+                           _("value for 'ram' must be less than '%u'"),
+                           UINT_MAX / 1024);
+            goto error;
+        }
+
+        /* QEMU accepts bytes for ram_size. */
+        virBufferAsprintf(&buf, ",ram_size=%u", video->ram * 1024);
 
         /* QEMU accepts bytes for vram_size. */
         virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
@@ -6568,24 +6577,36 @@ qemuBuildCommandLine(virConnectPtr conn,
 
                 virCommandAddArgList(cmd, "-vga", vgastr, NULL);
 
-                if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL) {
-                    if (def->videos[0]->vram &&
-                        qemuCapsGet(caps, QEMU_CAPS_DEVICE)) {
-                        if (def->videos[0]->vram > (UINT_MAX / 1024)) {
-                            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                                           _("value for 'vram' must be less than '%u'"),
-                                           UINT_MAX / 1024);
-                            goto error;
-                        }
+                if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
+                    (def->videos[0]->vram || def->videos[0]->ram) &&
+                    qemuCapsGet(caps, QEMU_CAPS_DEVICE)) {
+                    const char *dev = (qemuCapsGet(caps, QEMU_CAPS_DEVICE_QXL_VGA)
+                                       ? "qxl-vga" : "qxl");
+                    int ram = def->videos[0]->ram;
+                    int vram = def->videos[0]->vram;
+
+                    if (vram > (UINT_MAX / 1024)) {
+                        virReportError(VIR_ERR_OVERFLOW,
+                               _("value for 'vram' must be less than '%u'"),
+                                       UINT_MAX / 1024);
+                        goto error;
+                    }
+                    if (ram > (UINT_MAX / 1024)) {
+                        virReportError(VIR_ERR_OVERFLOW,
+                           _("value for 'ram' must be less than '%u'"),
+                                       UINT_MAX / 1024);
+                        goto error;
+                    }
 
+                    if (ram) {
                         virCommandAddArg(cmd, "-global");
-
-                        if (qemuCapsGet(caps, QEMU_CAPS_DEVICE_QXL_VGA))
-                            virCommandAddArgFormat(cmd, "qxl-vga.vram_size=%u",
-                                                   def->videos[0]->vram * 1024);
-                        else
-                            virCommandAddArgFormat(cmd, "qxl.vram_size=%u",
-                                                   def->videos[0]->vram * 1024);
+                        virCommandAddArgFormat(cmd, "%s.ram_size=%u",
+                                               dev, ram * 1024);
+                    }
+                    if (vram) {
+                        virCommandAddArg(cmd, "-global");
+                        virCommandAddArgFormat(cmd, "%s.vram_size=%u",
+                                               dev, vram * 1024);
                     }
                 }
             }
@@ -9247,6 +9268,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
         else
             vid->type = video;
         vid->vram = virDomainVideoDefaultRAM(def, vid->type);
+        vid->ram = vid->type == VIR_DOMAIN_VIDEO_TYPE_QXL ?
+                       virDomainVideoDefaultRAM(def, vid->type) : 0;
         vid->heads = 1;
 
         if (VIR_REALLOC_N(def->videos, def->nvideos+1) < 0) {
index 5c5912b54d198e8720fc9deb41c4c876f0c2d2da..59f064b00eca2f5d8572012c1b2b5c0816df8fbe 100644 (file)
@@ -3,7 +3,9 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
 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,\
-image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
+image-compression=auto_glz,jpeg-wan-compression=auto,\
+zlib-glz-wan-compression=auto,\
 playback-compression=on,streaming-video=filter -vga \
-qxl -global qxl.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
+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 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 52eb5b9e6ee7e39007a796982b1d06cbbe57833e..a8c4ad847b6e21f9dc1681d3daf825163f2ba4cc 100644 (file)
       <streaming mode='filter'/>
     </graphics>
     <video>
-      <model type='qxl' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' heads='1'/>
     </video>
     <video>
-      <model type='qxl' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index 3954c0366a94b79e54b4446168379964c0ba7443..ef499e6a60d929ce14e844783dd8b82711fbb039 100644 (file)
@@ -3,5 +3,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
 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.vram_size=33554432 -device qxl,id=video1,vram_size=67108864,bus=pci.0,addr=0x4 \
+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 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index 49cb8cca39f5ec409a7e8cdfec92772e206803c6..563d3711c36b8720329f89b9cc8989013a1a9453 100644 (file)
       <channel name='inputs' mode='insecure'/>
     </graphics>
     <video>
-      <model type='qxl' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' heads='1'/>
     </video>
     <video>
-      <model type='qxl' vram='65536' heads='1'/>
+      <model type='qxl' ram='65536' vram='65536' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index 854e72304479345579a5b013454ec5a0a45ebf90..d7cfae0648dca6e9c30aaf981735db9ca9da6144 100644 (file)
@@ -5,5 +5,6 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \
 x509-dir=/etc/pki/libvirt-spice,tls-channel=default,tls-channel=main,plaintext-channel=inputs,\
 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.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
+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 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
index d4939a466742655992f0a05a8626dc25ad9f06ba..9a366603a434fb6fed6d04e22aa04c68177f5283 100644 (file)
       <clipboard copypaste='no'/>
     </graphics>
     <video>
-      <model type='qxl' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' heads='1'/>
     </video>
     <video>
-      <model type='qxl' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
index 9ce852f695a76d4632d661cd68c274dc3b0ef6f3..4abd7c22259b1478bf34b9a09280d606aa66159e 100644 (file)
@@ -3,7 +3,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
 -usb \
 -hda /var/lib/libvirt/images/QEMUGuest1 -vnc 127.0.0.1:-5900 \
--device qxl-vga,id=video0,vram_size=67108864,bus=pci.0,addr=0x3 \
--device qxl,id=video1,vram_size=67108864,bus=pci.0,addr=0x4 \
--device qxl,id=video2,vram_size=67108864,bus=pci.0,addr=0x5 \
+-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x3 \
+-device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x4 \
+-device qxl,id=video2,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x5 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2