[PATCH V3 2/3] qemu: Introduce vgamem attribute for video model

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

 



From: Zeng Junliang <zengjunliang@xxxxxxxxxx>

QEMU suopports to specifie the size of the framebuffer portion of
the "ram" region for vga, vmvga and qxl through the qemu command
line parameter "vgamem_mb".
This patch introduces vgamem attribute for video model, makes the
"vgamem_mb" value configured in libvirt xml. Also, add test cases
and descriptions for it.

Libvirt xml configuration sample(based on VGA):
<video>
  <model type='vga' vgamem='16384' heads='1'/>
</video>

The resulting qemu command line change is the addition of:
-vga std -global VGA.vgamem_mb=16
or
-device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x2

If 'vgamem' is not configured by user, a default value will be assigned
by libvirt. Assume that user wants to start a VM without 'vgamem'
configuration in xml, if QEMU lacks the ability of vgamem, libvirt will
only report a warning rather than make starting failed even though libvirt
has assigned a default value to vgamem. It could avoid a regression.

It's less confusing to introduce the new vgamem attribute.
Prior to the change:
model       libvirt-attribute(xml)      qemu-attribute

qxl         vram                        vram_size
qxl         none                        vgamem_mb
vga         vram                        QEMU has no attribute named vram*
vga         none                        vgamem_mb
vmvga       vram                        QEMU has no attribute named vram*
vmvga       none                        vgamem_mb

After the change:
model       libvirt attribute(xml)      QEMU attribute

qxl         vram                        vram_size
qxl         vgamem                      vgamem_mb
vga         vram                        QEMU has no attribute named vram*
vga         vgamem                      vgamem_mb
vmvga       vram                        QEMU has no attribute named vram*
vmvga       vgamem                      vgamem_mb

Signed-off-by: Zeng Junliang <zengjunliang@xxxxxxxxxx>
Signed-off-by: Wang Rui <moon.wangrui@xxxxxxxxxx>
---
 docs/formatdomain.html.in                          |  35 ++++---
 docs/schemas/domaincommon.rng                      |   5 +
 src/conf/domain_conf.c                             |  52 +++++++++-
 src/conf/domain_conf.h                             |   2 +
 src/libvirt_private.syms                           |   1 +
 src/qemu/qemu_capabilities.c                       |  15 +++
 src/qemu/qemu_capabilities.h                       |   3 +
 src/qemu/qemu_command.c                            | 105 ++++++++++++++++-----
 tests/qemucapabilitiesdata/caps_1.2.2-1.caps       |   3 +
 tests/qemucapabilitiesdata/caps_1.3.1-1.caps       |   3 +
 tests/qemucapabilitiesdata/caps_1.4.2-1.caps       |   3 +
 tests/qemucapabilitiesdata/caps_1.5.3-1.caps       |   3 +
 tests/qemucapabilitiesdata/caps_1.6.0-1.caps       |   3 +
 tests/qemucapabilitiesdata/caps_1.6.50-1.caps      |   3 +
 tests/qemuhelptest.c                               |  10 +-
 .../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml |   2 +-
 ...emuxml2argv-graphics-spice-agent-file-xfer.args |   5 +-
 ...qemuxml2argv-graphics-spice-agent-file-xfer.xml |   4 +-
 .../qemuxml2argv-graphics-spice-compression.args   |   4 +-
 .../qemuxml2argv-graphics-spice-compression.xml    |   4 +-
 .../qemuxml2argv-graphics-spice-listen-network.xml |   4 +-
 .../qemuxml2argv-graphics-spice-qxl-vga.args       |   4 +-
 .../qemuxml2argv-graphics-spice-qxl-vga.xml        |   4 +-
 .../qemuxml2argv-graphics-spice-sasl.args          |   3 +-
 .../qemuxml2argv-graphics-spice-sasl.xml           |   2 +-
 .../qemuxml2argv-graphics-spice-timeout.xml        |   2 +-
 .../qemuxml2argv-graphics-spice.args               |   5 +-
 .../qemuxml2argv-graphics-spice.xml                |   4 +-
 .../qemuxml2argv-graphics-vnc-std-vga.args         |   4 +
 .../qemuxml2argv-graphics-vnc-std-vga.xml          |  36 +++++++
 .../qemuxml2argv-graphics-vnc-vmware-svga.args     |   4 +
 .../qemuxml2argv-graphics-vnc-vmware-svga.xml      |  36 +++++++
 .../qemuxml2argv-net-bandwidth.xml                 |   2 +-
 .../qemuxml2argv-pcihole64-q35.args                |   3 +-
 .../qemuxml2argv-pcihole64-q35.xml                 |   2 +-
 tests/qemuxml2argvdata/qemuxml2argv-q35.args       |   3 +-
 tests/qemuxml2argvdata/qemuxml2argv-q35.xml        |   2 +-
 .../qemuxml2argv-serial-spiceport.args             |   4 +-
 .../qemuxml2argv-serial-spiceport.xml              |   2 +-
 .../qemuxml2argv-video-device-pciaddr-default.args |   9 +-
 .../qemuxml2argv-video-device-pciaddr-default.xml  |   6 +-
 tests/qemuxml2argvtest.c                           |  22 ++++-
 .../qemuxml2xmlout-graphics-spice-timeout.xml      |   2 +-
 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml    |   2 +-
 tests/qemuxml2xmltest.c                            |   2 +
 45 files changed, 357 insertions(+), 77 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3012e3c..a0d15c4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4419,7 +4419,7 @@ qemu-kvm -net nic,model=? /dev/null
   ...
   &lt;devices&gt;
     &lt;video&gt;
-      &lt;model type='vga' heads='1'&gt;
+      &lt;model type='vga' vgamem='16384' heads='1'&gt;
         &lt;acceleration accel3d='yes' accel2d='yes'/&gt;
       &lt;/model&gt;
     &lt;/video&gt;
@@ -4434,16 +4434,17 @@ qemu-kvm -net nic,model=? /dev/null
         is set but there is a <code>graphics</code> in domain xml, then libvirt
         will add a default <code>video</code> according to the guest type.
         For a guest of type "kvm", the default <code>video</code> for it is:
-        <code>type</code> with value "cirrus", and <code>heads</code> with
-        value "1". By default, the first 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 multiple video device.
-        The non-primary must be type of "qxl". The optional attribute
+        <code>type</code> with value "cirrus", <code>vgamem</code>
+        (<span class="since">since 1.2.8</span>) with value "16384"
+        and <code>heads</code> with value "1". By default, the first 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 multiple 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" or "vram" are not supplied a default value is used.
+        If "ram", "vram" or "vgamem" are not supplied a default value is used.
       </dd>
 
       <dt><code>model</code></dt>
@@ -4452,10 +4453,20 @@ qemu-kvm -net nic,model=? /dev/null
         attribute which takes the value "vga", "cirrus", "vmvga", "xen",
         "vbox", or "qxl" (<span class="since">since 0.8.6</span>)
         depending on the hypervisor features available.
-        You can also provide the amount of video memory in kibibytes
-        (blocks of 1024 bytes) using
-        <code>vram</code> and the number of screen with <code>heads</code>.
-        For type of kvm <code>vram</code> attribute is only valid for "qxl".
+        <p>
+        <code>vram</code> attribute specifies the amount of video memory
+        in kibibytes (blocks of 1024 bytes). For type of kvm, it is only
+        valid for type of "qxl".
+        </p>
+        <p>
+        <code>vgamem</code> attribute <span class="since">since 1.2.8,
+        QEMU and KVM only</span> specifies the size of the framebuffer
+        portion of the "ram" region. And it is only valid for type of
+        "vga", "vmvga" and "qxl".
+        </p>
+        <p>
+        <code>heads</code> attribute specifies the number of screen.
+        </p>
       </dd>
 
       <dt><code>acceleration</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 033f2f6..b2cc218 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2786,6 +2786,11 @@
               <ref name="unsignedInt"/>
             </attribute>
           </optional>
+           <optional>
+            <attribute name="vgamem">
+              <ref name="unsignedInt"/>
+            </attribute>
+          </optional>
           <optional>
             <attribute name="heads">
               <ref name="unsignedInt"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5c762fa..7097570 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9639,6 +9639,21 @@ virDomainVideoDefaultType(const virDomainDef *def)
     }
 }
 
+int
+virDomainVideoDefaultVgamem(int type)
+{
+    switch (type) {
+    case VIR_DOMAIN_VIDEO_TYPE_VGA:
+    case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+    case VIR_DOMAIN_VIDEO_TYPE_QXL:
+        /* QEMU use 16M as default value for vga/vmvga/qxl device*/
+        return 16 * 1024;
+
+    default:
+        return 0;
+    }
+}
+
 static virDomainVideoAccelDefPtr
 virDomainVideoAccelDefParseXML(xmlNodePtr node)
 {
@@ -9694,6 +9709,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     char *type = NULL;
     char *heads = NULL;
     char *vram = NULL;
+    char *vgamem = NULL;
     char *ram = NULL;
     char *primary = NULL;
 
@@ -9703,11 +9719,12 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     cur = node->children;
     while (cur != NULL) {
         if (cur->type == XML_ELEMENT_NODE) {
-            if (!type && !vram && !ram && !heads &&
+            if (!type && !vram && !ram && !heads && !vgamem &&
                 xmlStrEqual(cur->name, BAD_CAST "model")) {
                 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) {
@@ -9754,13 +9771,31 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     if (vram) {
         if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) {
             virReportError(VIR_ERR_XML_ERROR,
-                           _("cannot parse video ram '%s'"), vram);
+                           _("cannot parse video vram '%s'"), vram);
             goto error;
         }
     } else {
         def->vram = virDomainVideoDefaultRAM(dom, def->type);
     }
 
+    if (vgamem) {
+        if (def->type != VIR_DOMAIN_VIDEO_TYPE_VGA &&
+            def->type != VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
+            def->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Unsupported vgamem attribute for %s device"),
+                             virDomainVideoTypeToString(def->type));
+            goto error;
+        }
+        if (virStrToLong_ui(vgamem, NULL, 10, &def->vgamem) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse video vgamem '%s'"), vgamem);
+            goto error;
+        }
+    } else {
+        def->vgamem = virDomainVideoDefaultVgamem(def->type);
+    }
+
     if (heads) {
         if (virStrToLong_ui(heads, NULL, 10, &def->heads) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -9777,6 +9812,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     VIR_FREE(type);
     VIR_FREE(ram);
     VIR_FREE(vram);
+    VIR_FREE(vgamem);
     VIR_FREE(heads);
 
     return def;
@@ -9786,6 +9822,7 @@ virDomainVideoDefParseXML(xmlNodePtr node,
     VIR_FREE(type);
     VIR_FREE(ram);
     VIR_FREE(vram);
+    VIR_FREE(vgamem);
     VIR_FREE(heads);
     return NULL;
 }
@@ -12996,6 +13033,7 @@ virDomainDefParseXML(xmlDocPtr xml,
             VIR_FREE(video);
             goto error;
         }
+        video->vgamem = virDomainVideoDefaultVgamem(video->type);
         video->vram = virDomainVideoDefaultRAM(def, video->type);
         video->heads = 1;
         if (VIR_ALLOC_N(def->videos, 1) < 0) {
@@ -13891,6 +13929,14 @@ 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"),
@@ -16937,6 +16983,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)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ff7d640..d1ef6ec 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1244,6 +1244,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;
@@ -2492,6 +2493,7 @@ virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);
 
 int virDomainVideoDefaultType(const virDomainDef *def);
 int virDomainVideoDefaultRAM(const virDomainDef *def, int type);
+int virDomainVideoDefaultVgamem(int type);
 
 int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
                                  bool active,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 08111d4..e481d92 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -416,6 +416,7 @@ virDomainVcpuPinFindByVcpu;
 virDomainVcpuPinIsDuplicate;
 virDomainVideoDefaultRAM;
 virDomainVideoDefaultType;
+virDomainVideoDefaultVgamem;
 virDomainVideoDefFree;
 virDomainVideoTypeFromString;
 virDomainVideoTypeToString;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 360cc67..146d67c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -265,6 +265,10 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "numa",
               "memory-backend-file",
               "usb-audio",
+              "vga-vgamem",
+
+              "qxl-vgamem", /* 175 */
+              "vmware-vgamem",
     );
 
 
@@ -1073,6 +1077,14 @@ virQEMUCapsComputeCmdFlags(const char *help,
             virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_QXL);
         if ((p = strstr(p, "|none")) && p < nl)
             virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_NONE);
+        /* It seems that QEMU supports to be communicated with
+         * qmp command since 1.2.0. When qemuCaps->usedQMP is
+         * true, these logical code will be invalid. Does it need here? */
+        if (version >= 1002000) {
+            virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_VGAMEM_MB);
+            virQEMUCapsSet(qemuCaps, QEMU_CAPS_QXL_VGAMEM_MB);
+            virQEMUCapsSet(qemuCaps, QEMU_CAPS_VMWARE_VGAMEM_MB);
+        }
     }
     if (strstr(help, "-spice"))
         virQEMUCapsSet(qemuCaps, QEMU_CAPS_SPICE);
@@ -3034,6 +3046,9 @@ virQEMUCapsInitQMPBasic(virQEMUCapsPtr qemuCaps)
     virQEMUCapsSet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE);
     virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_SHARE_POLICY);
     virQEMUCapsSet(qemuCaps, QEMU_CAPS_HOST_PCI_MULTIDOMAIN);
+    virQEMUCapsSet(qemuCaps, QEMU_CAPS_VGA_VGAMEM_MB);
+    virQEMUCapsSet(qemuCaps, QEMU_CAPS_QXL_VGAMEM_MB);
+    virQEMUCapsSet(qemuCaps, QEMU_CAPS_VMWARE_VGAMEM_MB);
 }
 
 /* Capabilities that are architecture depending
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2911759..cdf6920 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -213,6 +213,9 @@ typedef enum {
     QEMU_CAPS_NUMA               = 171, /* newer -numa handling with disjoint cpu ranges */
     QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */
     QEMU_CAPS_OBJECT_USB_AUDIO   = 173, /* usb-audio device support */
+    QEMU_CAPS_VGA_VGAMEM_MB      = 174, /* -global VGA.vgamem_mb */
+    QEMU_CAPS_QXL_VGAMEM_MB      = 175, /* -global qxl-vga.vgamem_mb */
+    QEMU_CAPS_VMWARE_VGAMEM_MB   = 176, /* -global vmware-svga.vgamem_mb */
 
     QEMU_CAPS_LAST,                   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c3f860e..c15099a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4827,6 +4827,14 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
         virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024);
     }
 
+    /* 1. Ignore cirrus-vga as guests would not use it anyway.
+     * 2. QEMU accepts MByte for vgamem_mb and ensure its value
+     * a power of two and range: 1 MB -> 256 MB */
+    if (video->type != VIR_DOMAIN_VIDEO_TYPE_CIRRUS &&
+        video->vgamem > 1024) {
+        virBufferAsprintf(&buf, ",vgamem_mb=%u", video->vgamem / 1024);
+    }
+
     if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
         goto error;
 
@@ -8766,36 +8774,86 @@ qemuBuildCommandLine(virConnectPtr conn,
 
                 virCommandAddArgList(cmd, "-vga", vgastr, NULL);
 
-                if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
-                    (def->videos[0]->vram || def->videos[0]->ram) &&
-                    virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-                    const char *dev = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA)
-                                       ? "qxl-vga" : "qxl");
+                if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
+                    const char *dev = NULL;
+                    bool vgamemSupport = true;
                     int ram = def->videos[0]->ram;
                     int vram = def->videos[0]->vram;
+                    int vgamem = def->videos[0]->vgamem;
+                    switch (primaryVideoType) {
+                    case VIR_DOMAIN_VIDEO_TYPE_VGA:
+                        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA))
+                            dev = "VGA";
+                        if (dev && vgamem &&
+                            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM_MB)) {
+                            vgamemSupport = false;
+                            VIR_WARN("This QEMU does not support vgamem "
+                                     "attribute, ignore it");
+                        }
+                        break;
+                    case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
+                        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA))
+                            dev = "vmware-svga";
+                        if (dev && vgamem &&
+                            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_VGAMEM_MB)) {
+                            vgamemSupport = false;
+                            VIR_WARN("This QEMU does not support vgamem "
+                                     "attribute, ignore it");
+                        }
+                        break;
+                    case VIR_DOMAIN_VIDEO_TYPE_QXL:
+                        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA))
+                            dev = "qxl-vga";
+                        else
+                            dev  = "qxl";
+                        if (dev && vgamem &&
+                            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGAMEM_MB)) {
+                            vgamemSupport = false;
+                            VIR_WARN("This QEMU does not support vgamem "
+                                     "attribute, ignore it");
+                        }
 
-                    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 (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");
+                            virCommandAddArgFormat(cmd, "%s.ram_size=%u",
+                                                   dev, ram * 1024);
+                        }
+                        if (vram) {
+                            virCommandAddArg(cmd, "-global");
+                            virCommandAddArgFormat(cmd, "%s.vram_size=%u",
+                                                   dev, vram * 1024);
+                        }
+
+                        break;
                     }
 
-                    if (ram) {
-                        virCommandAddArg(cmd, "-global");
-                        virCommandAddArgFormat(cmd, "%s.ram_size=%u",
-                                               dev, ram * 1024);
+                    /* When vgamem less than 1024 kibibytes, we ignore it here
+                     * and use qemu default value.*/
+                    if (vgamem < 1024) {
+                        vgamemSupport = false;
+                        VIR_WARN("The configuration value for vgamem is invalid, "
+                                 "ignore it and use qemu default value");
                     }
-                    if (vram) {
+
+                    if (dev && vgamemSupport) {
+                        /* QEMU accepts MByte for vgamem_mb and ensure its value
+                         * a power of two and range: 1 MB -> 256 MB */
                         virCommandAddArg(cmd, "-global");
-                        virCommandAddArgFormat(cmd, "%s.vram_size=%u",
-                                               dev, vram * 1024);
+                        virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
+                                               dev, vgamem / 1024);
                     }
                 }
             }
@@ -11766,6 +11824,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
             vid->type = VIR_DOMAIN_VIDEO_TYPE_XEN;
         else
             vid->type = video;
+        vid->vgamem = virDomainVideoDefaultVgamem(vid->type);
         vid->vram = vid->type == VIR_DOMAIN_VIDEO_TYPE_QXL ?
                        virDomainVideoDefaultRAM(def, vid->type) : 0;
         vid->ram = vid->type == VIR_DOMAIN_VIDEO_TYPE_QXL ?
diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
index c8a379a..1a61667 100644
--- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps
@@ -116,4 +116,7 @@
     <flag name='usb-kbd'/>
     <flag name='host-pci-multidomain'/>
     <flag name='usb-audio'/>
+    <flag name='vga-vgamem'/>
+    <flag name='qxl-vgamem'/>
+    <flag name='vmware-vgamem'/>
   </qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
index 4b7651e..9f67949 100644
--- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps
@@ -129,4 +129,7 @@
     <flag name='usb-kbd'/>
     <flag name='host-pci-multidomain'/>
     <flag name='usb-audio'/>
+    <flag name='vga-vgamem'/>
+    <flag name='qxl-vgamem'/>
+    <flag name='vmware-vgamem'/>
   </qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
index d146bf9..a813b56 100644
--- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps
@@ -130,4 +130,7 @@
     <flag name='usb-kbd'/>
     <flag name='host-pci-multidomain'/>
     <flag name='usb-audio'/>
+    <flag name='vga-vgamem'/>
+    <flag name='qxl-vgamem'/>
+    <flag name='vmware-vgamem'/>
   </qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
index 5fa30aa..7ec2d49 100644
--- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps
@@ -138,4 +138,7 @@
     <flag name='usb-kbd'/>
     <flag name='host-pci-multidomain'/>
     <flag name='usb-audio'/>
+    <flag name='vga-vgamem'/>
+    <flag name='qxl-vgamem'/>
+    <flag name='vmware-vgamem'/>
   </qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
index f364bbf..7b2628d 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps
@@ -145,4 +145,7 @@
     <flag name='host-pci-multidomain'/>
     <flag name='msg-timestamp'/>
     <flag name='usb-audio'/>
+    <flag name='vga-vgamem'/>
+    <flag name='qxl-vgamem'/>
+    <flag name='vmware-vgamem'/>
   </qemuCaps>
diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
index 10ce1b5..b661a93 100644
--- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
+++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps
@@ -144,4 +144,7 @@
     <flag name='msg-timestamp'/>
     <flag name='numa'/>
     <flag name='usb-audio'/>
+    <flag name='vga-vgamem'/>
+    <flag name='qxl-vgamem'/>
+    <flag name='vmware-vgamem'/>
   </qemuCaps>
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 366e36d..523f47e 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -953,7 +953,10 @@ mymain(void)
             QEMU_CAPS_DEVICE_USB_STORAGE,
             QEMU_CAPS_DEVICE_USB_KBD,
             QEMU_CAPS_USB_STORAGE_REMOVABLE,
-            QEMU_CAPS_OBJECT_USB_AUDIO);
+            QEMU_CAPS_OBJECT_USB_AUDIO,
+            QEMU_CAPS_VGA_VGAMEM_MB,
+            QEMU_CAPS_QXL_VGAMEM_MB,
+            QEMU_CAPS_VMWARE_VGAMEM_MB);
     DO_TEST("qemu-kvm-1.2.0", 1002000, 1, 0,
             QEMU_CAPS_VNC_COLON,
             QEMU_CAPS_NO_REBOOT,
@@ -1068,7 +1071,10 @@ mymain(void)
             QEMU_CAPS_DEVICE_USB_STORAGE,
             QEMU_CAPS_DEVICE_USB_KBD,
             QEMU_CAPS_USB_STORAGE_REMOVABLE,
-            QEMU_CAPS_OBJECT_USB_AUDIO);
+            QEMU_CAPS_OBJECT_USB_AUDIO,
+            QEMU_CAPS_VGA_VGAMEM_MB,
+            QEMU_CAPS_QXL_VGAMEM_MB,
+            QEMU_CAPS_VMWARE_VGAMEM_MB);
 
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
index cb6c774..85dde76 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
@@ -27,7 +27,7 @@
     <input type='keyboard' bus='ps2'/>
     <graphics type='sdl' display=':0.1' xauth='/root/.Xauthority'/>
     <video>
-      <model type='vga' heads='1'/>
+      <model type='vga' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.args
index 66f22bc..c4089ce 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.args
@@ -4,6 +4,7 @@ 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,\
 disable-agent-file-xfer -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.vram_size=33554432 -global qxl-vga.vgamem_mb=16 \
+-device qxl,id=video1,ram_size=67108864,\
+vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.xml
index 3a3e366..2574feb 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-agent-file-xfer.xml
@@ -30,10 +30,10 @@
       <filetransfer enable='no'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='65536' heads='1'/>
+      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
index 59f064b..9c87509 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args
@@ -7,5 +7,7 @@ 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.vgamem_mb=16 \
+-device qxl,id=video1,ram_size=67108864,\
+vram_size=33554432,vgamem_mb=16,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 6c913b4..8163020 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml
@@ -33,10 +33,10 @@
       <streaming mode='filter'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-listen-network.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-listen-network.xml
index 34971fe..c0ad87c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-listen-network.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-listen-network.xml
@@ -35,10 +35,10 @@
       <channel mode='secure' name='usbredir'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
     </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..8a294ed 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args
@@ -4,5 +4,7 @@ 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.vgamem_mb=16 \
+-device qxl,id=video1,ram_size=67108864,\
+vram_size=67108864,vgamem_mb=16,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 acf3019..a12206b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml
@@ -30,10 +30,10 @@
       <channel name='inputs' mode='insecure'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='65536' heads='1'/>
+      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args
index 8847bce..614fada 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.args
@@ -6,4 +6,5 @@ SASL_CONF_PATH=/root/.sasl2 QEMU_AUDIO_DRV=spice \
 -spice port=5903,tls-port=5904,sasl,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=default \
 -vga qxl -global qxl.ram_size=67108864 -global \
-qxl.vram_size=18874368 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+qxl.vram_size=18874368 -global qxl.vgamem_mb=16 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.xml
index eb630fa..2181f8e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-sasl.xml
@@ -28,7 +28,7 @@
       <listen type='address' address='127.0.0.1'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
index b5940f4..deab263 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.xml
@@ -77,7 +77,7 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </sound>
     <video>
-      <model type='vga' heads='1'/>
+      <model type='vga' vgamem='16384' heads='1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </video>
     <memballoon model='virtio'>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
index 8430d9c..93bb0dc 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
@@ -8,6 +8,7 @@ image-compression=auto_glz,jpeg-wan-compression=auto,\
 zlib-glz-wan-compression=auto,\
 playback-compression=on,streaming-video=filter,disable-copy-paste,\
 disable-agent-file-xfer -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.vram_size=18874368 -global qxl.vgamem_mb=16 \
+-device qxl,id=video1,ram_size=67108864,\
+vram_size=33554432,vgamem_mb=16,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 8f58149..9396056 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
@@ -37,10 +37,10 @@
       <filetransfer enable='no'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <video>
-      <model type='qxl' ram='65536' vram='32768' heads='1'/>
+      <model type='qxl' ram='65536' vram='32768' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.args
new file mode 100644
index 0000000..540e3b1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefaults -monitor unix:/tmp/test-monitor,\
+server,nowait -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -vnc 127.0.0.1:3 \
+-vga std -global VGA.vgamem_mb=16
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.xml
new file mode 100644
index 0000000..660a440
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+    <video>
+      <model type='vga' vgamem='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.args
new file mode 100644
index 0000000..4a7e70f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.args
@@ -0,0 +1,4 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefaults -monitor unix:/tmp/test-monitor,\
+server,nowait -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -vnc 127.0.0.1:3 \
+-vga vmware -global vmware-svga.vgamem_mb=16
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.xml
new file mode 100644
index 0000000..6efdb2d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.xml
@@ -0,0 +1,36 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <currentMemory unit='KiB'>219100</currentMemory>
+  <vcpu placement='static'>1</vcpu>
+  <os>
+    <type arch='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='usb' index='0'/>
+    <controller type='ide' index='0'/>
+    <controller type='pci' index='0' model='pci-root'/>
+    <input type='mouse' bus='ps2'/>
+    <input type='keyboard' bus='ps2'/>
+    <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'>
+      <listen type='address' address='127.0.0.1'/>
+    </graphics>
+    <video>
+      <model type='vmvga' vgamem='16384' heads='1'/>
+    </video>
+    <memballoon model='none'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
index 19155ac..9f82580 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml
@@ -66,7 +66,7 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </sound>
     <video>
-      <model type='vga' heads='1'/>
+      <model type='vga' vgamem='16384' heads='1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </video>
     <memballoon model='virtio'>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
index 6855cd2..8c5f01a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.args
@@ -6,4 +6,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
 -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
--vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368
+-vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 \
+-global qxl.vgamem_mb=16
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
index ee151be..68f78a4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcihole64-q35.xml
@@ -26,7 +26,7 @@
     <controller type='pci' index='2' model='pci-bridge'/>
     <controller type='sata' index='0'/>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35.args b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
index 8cc5874..f74bc01 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35.args
@@ -5,4 +5,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 \
 -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-sata0-0-0 \
 -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
--vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368
+-vga qxl -global qxl.ram_size=67108864 -global qxl.vram_size=18874368 \
+-global qxl.vgamem_mb=16
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35.xml
index edaf6cb..478d23f 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35.xml
@@ -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='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
index 8c631b1..3632421 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
@@ -8,6 +8,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
 -device isa-serial,chardev=charserial0,id=serial0 \
 -device usb-tablet,id=input0 \
 -spice port=5903,tls-port=5904,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \
--device \
-qxl-vga,id=video0,ram_size=67107840,vram_size=67107840,bus=pci.0,addr=0x2 \
+-device qxl-vga,id=video0,ram_size=67107840,\
+vram_size=67107840,vgamem_mb=16,bus=pci.0,addr=0x2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml
index 36af468..47fabe9 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml
@@ -37,7 +37,7 @@
       <listen type='address' address='127.0.0.1'/>
     </graphics>
     <video>
-      <model type='qxl' ram='65535' vram='65535' heads='1'/>
+      <model type='qxl' ram='65535' vram='65535' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'/>
   </devices>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args
index 4abd7c2..4dbbbfd 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args
@@ -3,7 +3,10 @@ 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,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 qxl-vga,id=video0,ram_size=67108864,\
+vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x3 \
+-device qxl,id=video1,ram_size=67108864,\
+vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x4 \
+-device qxl,id=video2,ram_size=67108864,\
+vram_size=67108864,vgamem_mb=16,bus=pci.0,addr=0x5 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.xml b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.xml
index 120e7f4..c3f5bcc 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.xml
@@ -29,13 +29,13 @@
       <listen type='address' address='127.0.0.1'/>
     </graphics>
     <video>
-      <model type='qxl' vram='65536' heads='1'/>
+      <model type='qxl' vram='65536' vgamem='16384' heads='1'/>
     </video>
     <video>
-      <model type='qxl' vram='65536' heads='1' primary='yes'/>
+      <model type='qxl' vram='65536' vgamem='16384' heads='1' primary='yes'/>
     </video>
     <video>
-      <model type='qxl' vram='65536' heads='1'/>
+      <model type='qxl' vram='65536' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='virtio'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 62b969c..a7cbb02 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -871,6 +871,14 @@ mymain(void)
     DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC);
     DO_TEST("graphics-vnc-websocket", QEMU_CAPS_VNC, QEMU_CAPS_VNC_WEBSOCKET);
     DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC, QEMU_CAPS_VNC_SHARE_POLICY);
+    DO_TEST("graphics-vnc-std-vga",
+            QEMU_CAPS_VNC, QEMU_CAPS_DEVICE,
+            QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VGA,
+            QEMU_CAPS_VGA_VGAMEM_MB);
+    DO_TEST("graphics-vnc-vmware-svga",
+            QEMU_CAPS_VNC, QEMU_CAPS_DEVICE,
+            QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VMWARE_SVGA,
+            QEMU_CAPS_VMWARE_VGAMEM_MB);
 
     driver.config->vncSASL = 1;
     VIR_FREE(driver.config->vncSASLdir);
@@ -890,6 +898,7 @@ mymain(void)
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_NONE);
     DO_TEST("graphics-spice",
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
             QEMU_CAPS_DEVICE_QXL,
             QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
@@ -897,26 +906,32 @@ mymain(void)
     ignore_value(VIR_STRDUP(driver.config->spiceSASLdir, "/root/.sasl2"));
     DO_TEST("graphics-spice-sasl",
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
             QEMU_CAPS_DEVICE_QXL);
     VIR_FREE(driver.config->spiceSASLdir);
     driver.config->spiceSASL = 0;
     DO_TEST("graphics-spice-agentmouse",
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
             QEMU_CAPS_CHARDEV_SPICEVMC,
             QEMU_CAPS_NODEFCONFIG);
     DO_TEST("graphics-spice-compression",
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
-            QEMU_CAPS_DEVICE_QXL);
+            QEMU_CAPS_DEVICE_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB);
     DO_TEST("graphics-spice-timeout",
             QEMU_CAPS_DRIVE,
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
             QEMU_CAPS_DEVICE_QXL_VGA);
     DO_TEST("graphics-spice-qxl-vga",
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
             QEMU_CAPS_DEVICE_QXL_VGA,
             QEMU_CAPS_DEVICE_QXL);
@@ -928,6 +943,7 @@ mymain(void)
             QEMU_CAPS_CHARDEV_SPICEVMC);
     DO_TEST("graphics-spice-agent-file-xfer",
             QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
             QEMU_CAPS_DEVICE_QXL_VGA,
             QEMU_CAPS_DEVICE_QXL,
@@ -1336,7 +1352,8 @@ mymain(void)
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
             QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
-            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
+            QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB);
 
     DO_TEST("hostdev-scsi-lsi", QEMU_CAPS_DRIVE,
             QEMU_CAPS_DEVICE, QEMU_CAPS_DRIVE,
@@ -1398,6 +1415,7 @@ mymain(void)
             QEMU_CAPS_DRIVE, QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_VGA, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL,
+            QEMU_CAPS_QXL_VGAMEM_MB,
             QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
 
     DO_TEST("arm-vexpressa9-nodevs",
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
index 8a319a2..0a18e74 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml
@@ -80,7 +80,7 @@
       <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </sound>
     <video>
-      <model type='vga' heads='1'/>
+      <model type='vga' vgamem='16384' heads='1'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </video>
     <memballoon model='virtio'>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml
index 96f8eaf..aa24cc8 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml
@@ -24,7 +24,7 @@
     <controller type='pci' index='2' model='pci-bridge'/>
     <controller type='sata' index='0'/>
     <video>
-      <model type='qxl' ram='65536' vram='18432' heads='1'/>
+      <model type='qxl' ram='65536' vram='18432' vgamem='16384' heads='1'/>
     </video>
     <memballoon model='none'/>
   </devices>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5941323..720b058 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -238,6 +238,8 @@ mymain(void)
     DO_TEST("graphics-vnc-websocket");
     DO_TEST("graphics-vnc-sasl");
     DO_TEST("graphics-vnc-tls");
+    DO_TEST("graphics-vnc-std-vga");
+    DO_TEST("graphics-vnc-vmware-svga");
     DO_TEST("graphics-sdl");
     DO_TEST("graphics-sdl-fullscreen");
     DO_TEST("graphics-spice");
-- 
1.7.12.4


--
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]