From 71519d4638e30a7c4f59a9764a7a8e5e8f679eb3 Mon Sep 17 00:00:00 2001 From: Julio Faracco Date: Thu, 17 Oct 2019 01:30:32 -0300 Subject: [PATCH] qemu: Generate 'xres' and 'yres' for QEMU video devices This commit let QEMU command line define 'xres' and 'yres' properties if XML contains both properties from video model: based on resolution fields 'x' and 'y'. There is a conditional structure inside qemuDomainDeviceDefValidateVideo() that validates if video model supports this feature. This commit includes the necessary changes to cover resolution for 'video-qxl-resolution' test cases too. Reviewed-by: Cole Robinson Signed-off-by: Julio Faracco --- src/qemu/qemu_command.c | 5 +++++ src/qemu/qemu_domain.c | 11 +++++++++++ tests/qemuxml2argvdata/video-qxl-resolution.args | 2 +- tests/qemuxml2argvdata/video-qxl-resolution.xml | 4 +++- tests/qemuxml2xmloutdata/video-qxl-resolution.xml | 4 +++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e98195b1d7..b579b994f3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4598,6 +4598,11 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, virBufferAsprintf(&buf, ",vgamem=%uk", video->vram); } + if (video->res && video->res->x && video->res->y) { + /* QEMU accepts resolution xres and yres. */ + virBufferAsprintf(&buf, ",xres=%u,yres=%u", video->res->x, video->res->y); + } + if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0) return NULL; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 09b6c9a570..a97bf65e7f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5774,6 +5774,17 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video) } } + if (video->type != VIR_DOMAIN_VIDEO_TYPE_VGA && + video->type != VIR_DOMAIN_VIDEO_TYPE_QXL && + video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + video->type != VIR_DOMAIN_VIDEO_TYPE_BOCHS) { + if (video->res) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("model resolution is not supported")); + return -1; + } + } + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VGA || video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA) { if (video->vram && video->vram < 1024) { diff --git a/tests/qemuxml2argvdata/video-qxl-resolution.args b/tests/qemuxml2argvdata/video-qxl-resolution.args index 1dbcd660f1..ed2e4422da 100644 --- a/tests/qemuxml2argvdata/video-qxl-resolution.args +++ b/tests/qemuxml2argvdata/video-qxl-resolution.args @@ -28,5 +28,5 @@ server,nowait \ -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ -device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vgamem_mb=8,\ -bus=pci.0,addr=0x2 \ +xres=1280,yres=720,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/video-qxl-resolution.xml b/tests/qemuxml2argvdata/video-qxl-resolution.xml index 6ba2817002..1bc415f3f8 100644 --- a/tests/qemuxml2argvdata/video-qxl-resolution.xml +++ b/tests/qemuxml2argvdata/video-qxl-resolution.xml @@ -30,7 +30,9 @@