qemuBuildDeviceVideoStr: Don't overwrite @model

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@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Michal Privoznik 2021-06-11 14:49:06 +02:00
parent 96414611ef
commit 55ea45acc9

View File

@ -4164,9 +4164,13 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
{ {
const char *model = NULL; const char *model = NULL;
bool primaryVga = false; bool primaryVga = false;
virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT;
*virtio = false; *virtio = false;
if (video->accel)
accel3d = video->accel->accel3d;
if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps)) if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
primaryVga = true; primaryVga = true;
@ -4197,6 +4201,10 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
model = "qxl-vga"; model = "qxl-vga";
break; break;
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) &&
accel3d == VIR_TRISTATE_SWITCH_ON)
model = "virtio-vga-gl";
else
model = "virtio-vga"; model = "virtio-vga";
break; break;
case VIR_DOMAIN_VIDEO_TYPE_BOCHS: case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
@ -4220,6 +4228,10 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
model = "qxl"; model = "qxl";
break; break;
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) &&
accel3d == VIR_TRISTATE_SWITCH_ON)
model = "virtio-gpu-gl";
else
model = "virtio-gpu"; model = "virtio-gpu";
*virtio = true; *virtio = true;
break; break;
@ -4268,21 +4280,12 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
return NULL; return NULL;
if (virtio) { 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, if (qemuBuildVirtioDevStr(&buf, model, qemuCaps,
VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { VIR_DOMAIN_DEVICE_VIDEO, video) < 0) {
return NULL; return NULL;
} }
} else { } else {
virBufferAsprintf(&buf, "%s", model); 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); virBufferAsprintf(&buf, ",id=%s", video->info.alias);