Now we have everything prepared so that @model doesn't have to be rewritten. The correct model can be chosen right from the beginning. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/qemu/qemu_command.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c9e152324d..22cc383f33 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4164,6 +4164,12 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, { const char *model = NULL; bool primaryVga = false; + virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; + + *virtio = false; + + if (video->accel) + accel3d = video->accel->accel3d; *virtio = false; @@ -4197,7 +4203,11 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, model = "qxl-vga"; break; case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - model = "virtio-vga"; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && + accel3d == VIR_TRISTATE_SWITCH_ON) + model = "virtio-vga-gl"; + else + model = "virtio-vga"; break; case VIR_DOMAIN_VIDEO_TYPE_BOCHS: model = "bochs-display"; @@ -4220,7 +4230,11 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, model = "qxl"; break; case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: - model = "virtio-gpu"; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) && + accel3d == VIR_TRISTATE_SWITCH_ON) + model = "virtio-gpu-gl"; + else + model = "virtio-gpu"; *virtio = true; break; case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: @@ -4268,21 +4282,12 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, return NULL; if (virtio) { - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) && - accel3d == VIR_TRISTATE_SWITCH_ON && - STREQ(model, "virtio-gpu")) - model = "virtio-gpu-gl"; - if (qemuBuildVirtioDevStr(&buf, model, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { return NULL; } } else { virBufferAsprintf(&buf, "%s", model); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && - accel3d == VIR_TRISTATE_SWITCH_ON && - STREQ(model, "virtio-vga")) - virBufferAddLit(&buf, "-gl"); } virBufferAsprintf(&buf, ",id=%s", video->info.alias); -- 2.31.1