diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 48b1a7f534..1a7eeaefbe 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4679,7 +4679,7 @@ qemu-kvm -net nic,model=? /dev/null ... <devices> <video> - <model type='vga' vram='8192' heads='1'> + <model type='vga' vram='16384' heads='1'> <acceleration accel3d='yes' accel2d='yes'/> </model> </video> @@ -4689,33 +4689,51 @@ qemu-kvm -net nic,model=? /dev/null
video
- The video element is the container for describing - video devices. For backwards compatibility, if no video - is set but there is a graphics in domain xml, then libvirt - will add a default video according to the guest type. - For a guest of type "kvm", the default video for it is: - type with value "cirrus", vram with value - "9216", and heads with value "1". By default, the first - video device in domain xml is the primary one, but the optional - attribute primary (since 1.0.2) - 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 ram (since - 1.0.2) is allowed for "qxl" type only and specifies - the size of the primary bar, while vram specifies the - secondary bar size. If "ram" or "vram" are not supplied a default - value is used. +

+ The video element is the container for describing + video devices. For backwards compatibility, if no video + is set but there is a graphics in domain xml, then + libvirt will add a default video according to the guest + type. +

+

+ For a guest of type "kvm", the default video is: + type with value "cirrus", vram with value + "16384" and heads with value "1". By default, the first + video device in domain xml is the primary one, but the optional + attribute primary (since 1.0.2) + with value 'yes' can be used to mark the primary in cases of multiple + video device. The non-primary must be type of "qxl". +

model
- The model element has a mandatory type - attribute which takes the value "vga", "cirrus", "vmvga", "xen", - "vbox", or "qxl" (since 0.8.6) - depending on the hypervisor features available. - You can also provide the amount of video memory in kibibytes - (blocks of 1024 bytes) using - vram and the number of screen with heads. +

+ The model element has a mandatory type + attribute which takes the value "vga", "cirrus", "vmvga", "xen", + "vbox", or "qxl" (since 0.8.6) depending + on the hypervisor features available. +

+

+ You can provide the amount of video memory in kibibytes (blocks of + 1024 bytes) using vram. This is supported only for guest + type of "libxl", "parallels", "qemu", "vbox", "vmx" and "xen". If no + value is provided the default is used. If the size is not a power of + two it will be rounded to closest one. +

+

+ The number of screen can be set using heads. This is + supported only for guests type of "parallels", "kvm", "vbox" and "vmx". +

+

+ For guest type of kvm the optional attribute ram + (since 1.0.2) is allowed for "qxl" type + only and specifies the size of the primary bar, while the optional + attribute vram 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. +

acceleration
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 68eef5446e..f187ee78d2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3189,6 +3189,12 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, } } + if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) { + virDomainVideoDefPtr video = dev->data.video; + video->ram = VIR_ROUND_UP_POWER_OF_TWO(video->ram); + video->vram = VIR_ROUND_UP_POWER_OF_TWO(video->vram); + } + return 0; } @@ -10147,16 +10153,15 @@ virSysinfoParseXML(xmlNodePtr node, goto cleanup; } -int +unsigned int virDomainVideoDefaultRAM(const virDomainDef *def, - int type) + const virDomainVideoType type) { /* Defer setting default vram to the Xen drivers */ if (def->virtType == VIR_DOMAIN_VIRT_XEN) return 0; switch (type) { - /* Weird, QEMU defaults to 9 MB ??! */ case VIR_DOMAIN_VIDEO_TYPE_VGA: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: case VIR_DOMAIN_VIDEO_TYPE_VMVGA: @@ -10165,7 +10170,7 @@ virDomainVideoDefaultRAM(const virDomainDef *def, else if (def->virtType == VIR_DOMAIN_VIRT_VMWARE) return 4 * 1024; else - return 9 * 1024; + return 16 * 1024; break; case VIR_DOMAIN_VIDEO_TYPE_XEN: @@ -10326,7 +10331,7 @@ 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 { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0a609df3c4..ffe1be6570 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2628,7 +2628,8 @@ int virDomainFSIndexByName(virDomainDefPtr def, const char *name); virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i); int virDomainVideoDefaultType(const virDomainDef *def); -int virDomainVideoDefaultRAM(const virDomainDef *def, int type); +unsigned int virDomainVideoDefaultRAM(const virDomainDef *def, + const virDomainVideoType type); int virDomainObjListNumOfDomains(virDomainObjListPtr doms, bool active, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index cbdef9c36e..8c89b0cf3f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4902,11 +4902,15 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def, goto error; } - /* QEMU accepts bytes for ram_size. */ - virBufferAsprintf(&buf, ",ram_size=%u", video->ram * 1024); + if (video->ram) { + /* 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); + if (video->vram) { + /* QEMU accepts bytes for vram_size. */ + virBufferAsprintf(&buf, ",vram_size=%u", video->vram * 1024); + } } if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0) @@ -9213,8 +9217,8 @@ qemuBuildCommandLine(virConnectPtr conn, virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { const char *dev = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL_VGA) ? "qxl-vga" : "qxl"); - int ram = def->videos[0]->ram; - int vram = def->videos[0]->vram; + unsigned int ram = def->videos[0]->ram; + unsigned int vram = def->videos[0]->vram; if (vram > (UINT_MAX / 1024)) { virReportError(VIR_ERR_OVERFLOW, diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 7334142eeb..c9f4159ea4 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -358,7 +358,7 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, case VIR_DOMAIN_VIDEO_TYPE_VGA: case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: case VIR_DOMAIN_VIDEO_TYPE_VMVGA: - dev->data.video->vram = 9 * 1024; + dev->data.video->vram = 16 * 1024; break; case VIR_DOMAIN_VIDEO_TYPE_XEN: diff --git a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml index ec1c6e8f7e..d848677720 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml @@ -91,7 +91,7 @@