Adds a qxl-ram attribute globaly to the video.model element, that changes the resulting qemu command line only if video.type == "qxl". That attribute gets a default value of 64*1024 only if model.type is "qxl". In effect not changing any xml or argv for non qxl devices. For qxl devices a new property is set: -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 the same as the default for the qxl vram bar, 64*1024. --- I've added a qxl-ram attribute. There is no precedent for adding am attribute prefixed like this, so I'm open for any other suggestion on how to do it. docs/schemas/domaincommon.rng | 9 +++- src/conf/domain_conf.c | 19 ++++++- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 58 ++++++++++++++++++---- .../qemuxml2argv-graphics-spice-compression.args | 2 +- .../qemuxml2argv-graphics-spice-compression.xml | 4 +- .../qemuxml2argv-graphics-spice-qxl-vga.args | 2 +- .../qemuxml2argv-graphics-spice-qxl-vga.xml | 4 +- .../qemuxml2argv-graphics-spice.args | 2 +- .../qemuxml2argv-graphics-spice.xml | 4 +- .../qemuxml2argv-video-device-pciaddr-default.args | 6 +-- 11 files changed, 86 insertions(+), 25 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 67ae864..50fc834 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2251,7 +2251,9 @@ </define> <!-- A video adapter description, allowing configuration of device - model, number of virtual heads, and video ram size + model, number of virtual heads, and video ram size. + The qxl-ram property is used for qxl types only to specify the + primary bar size, letting vram specify the secondary bar size. --> <define name="video"> <element name="video"> @@ -2268,6 +2270,11 @@ </choice> </attribute> <optional> + <attribute name="qxl-ram"> + <ref name="unsignedInt"/> + </attribute> + </optional> + <optional> <attribute name="vram"> <ref name="unsignedInt"/> </attribute> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 13c14e9..a16f1b5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7391,6 +7391,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node, char *type = NULL; char *heads = NULL; char *vram = NULL; + char *qxl_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 && !qxl_ram && !heads && xmlStrEqual(cur->name, BAD_CAST "model")) { type = virXMLPropString(cur, "type"); + qxl_ram = virXMLPropString(cur, "qxl-ram"); vram = virXMLPropString(cur, "vram"); heads = virXMLPropString(cur, "heads"); @@ -7431,6 +7433,18 @@ virDomainVideoDefParseXML(const xmlNodePtr node, } } + if (qxl_ram) { + if (virStrToLong_ui(qxl_ram, NULL, 10, &def->qxl_ram) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot parse video qxl-ram '%s'"), qxl_ram); + goto error; + } + } else { + if (def->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { + def->qxl_ram = virDomainVideoDefaultRAM(dom, def->type); + } + } + if (vram) { if (virStrToLong_ui(vram, NULL, 10, &def->vram) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7455,6 +7469,7 @@ virDomainVideoDefParseXML(const xmlNodePtr node, goto error; VIR_FREE(type); + VIR_FREE(qxl_ram); VIR_FREE(vram); VIR_FREE(heads); @@ -13383,6 +13398,8 @@ virDomainVideoDefFormat(virBufferPtr buf, virBufferAddLit(buf, " <video>\n"); virBufferAsprintf(buf, " <model type='%s'", model); + if (def->qxl_ram && def->type == VIR_DOMAIN_VIDEO_TYPE_QXL) + virBufferAsprintf(buf, " qxl-ram='%u'", def->qxl_ram); if (def->vram) virBufferAsprintf(buf, " vram='%u'", def->vram); if (def->heads) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ce36003..9333d26 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1157,6 +1157,7 @@ struct _virDomainVideoAccelDef { struct _virDomainVideoDef { int type; + unsigned int qxl_ram; unsigned int vram; unsigned int heads; bool primary; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 981c692..05f656a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3563,6 +3563,15 @@ qemuBuildDeviceVideoStr(virDomainVideoDefPtr video, UINT_MAX / 1024); goto error; } + if (video->qxl_ram > (UINT_MAX / 1024)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("value for 'qxl-ram' must be less than '%u'"), + UINT_MAX / 1024); + goto error; + } + + /* QEMU accepts bytes for ram_size. */ + virBufferAsprintf(&buf, ",ram_size=%u", video->qxl_ram * 1024); /* QEMU accepts bytes for vram_size. */ virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024); @@ -6569,23 +6578,48 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArgList(cmd, "-vga", vgastr, NULL); if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL) { - if (def->videos[0]->vram && + if ((def->videos[0]->vram || def->videos[0]->qxl_ram) && qemuCapsGet(caps, QEMU_CAPS_DEVICE)) { - if (def->videos[0]->vram > (UINT_MAX / 1024)) { + int qxl_ram = def->videos[0]->qxl_ram; + int vram = def->videos[0]->vram; + if (vram > (UINT_MAX / 1024)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("value for 'vram' must be less than '%u'"), + _("value for 'vram' must be less than '%u'"), + UINT_MAX / 1024); + goto error; + } + if (qxl_ram > (UINT_MAX / 1024)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("value for 'qxl-ram' must be less than '%u'"), UINT_MAX / 1024); goto error; } - 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); + if (qemuCapsGet(caps, QEMU_CAPS_DEVICE_QXL_VGA)) { + if (qxl_ram) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, + "qxl-vga.ram_size=%u", + qxl_ram * 1024); + } + if (vram) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, + "qxl-vga.vram_size=%u", + vram * 1024); + } + } else { + if (qxl_ram) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "qxl.ram_size=%u", + qxl_ram * 1024); + } + if (vram) { + virCommandAddArg(cmd, "-global"); + virCommandAddArgFormat(cmd, "qxl.vram_size=%u", + vram * 1024); + } + } } } } @@ -9247,6 +9281,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, else vid->type = video; vid->vram = virDomainVideoDefaultRAM(def, vid->type); + vid->qxl_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) { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args index 5c5912b..2f537df 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.args @@ -5,5 +5,5 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -hda \ x509-dir=/etc/pki/libvirt-spice,\ 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 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-compression.xml index 52eb5b9..32e4cc8 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' vram='18432' heads='1'/> + <model type='qxl' qxl-ram='65536' vram='18432' heads='1'/> </video> <video> - <model type='qxl' vram='32768' heads='1'/> + <model type='qxl' qxl-ram='65536' vram='32768' 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 3954c03..007dd3f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.args @@ -3,5 +3,5 @@ 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 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-qxl-vga.xml index 49cb8cc..ab40c7b 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' vram='32768' heads='1'/> + <model type='qxl' qxl-ram='65536' vram='32768' heads='1'/> </video> <video> - <model type='qxl' vram='65536' heads='1'/> + <model type='qxl' qxl-ram='65536' vram='65536' heads='1'/> </video> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args index 854e723..030e1f2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args @@ -5,5 +5,5 @@ 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 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml index d4939a4..b540915 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' vram='18432' heads='1'/> + <model type='qxl' qxl-ram='65536' vram='18432' heads='1'/> </video> <video> - <model type='qxl' vram='32768' heads='1'/> + <model type='qxl' qxl-ram='65536' vram='32768' 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 9ce852f..4abd7c2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args @@ -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 -- 1.8.0.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list