The 'virito' argument was misleadingly implying that it's true for all virtio devices, but that's not the case. 'virtio-vga(-gl)' is a virtio device but doesn't accept the usual bus-dependant suffix. Add a comment for 'qemuDeviceVideoGetModel' and another boolean 'virtioBusSuffix' which carries the above meaning so that the 'virtio' argument can be fixed (it will be used later). Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_command.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f185e3a53c..3c468ab0a4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4291,16 +4291,28 @@ qemuBuildSoundCommandLine(virCommand *cmd, } +/** + * qemuDeviceVideoGetModel: + * @qemuCaps: qemu capabilities + * @video: video device definition + * @virtio: the returned video device is a 'virtio' device + * @virtioBusSuffix: the returned device needs to get the bus-suffix + * + * Returns the model fo the device for @video and @qemuCaps. @virtio and + * @virtioBusSuffix are filled with the corresponding flags. + */ static const char * qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, const virDomainVideoDef *video, - bool *virtio) + bool *virtio, + bool *virtioBusSuffix) { const char *model = NULL; bool primaryVga = false; virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; *virtio = false; + *virtioBusSuffix = false; if (video->accel) accel3d = video->accel->accel3d; @@ -4318,6 +4330,7 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, } else { model = "vhost-user-gpu"; *virtio = true; + *virtioBusSuffix = true; } } else { if (primaryVga) { @@ -4340,6 +4353,9 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, model = "virtio-vga-gl"; else model = "virtio-vga"; + + *virtio = true; + *virtioBusSuffix = false; break; case VIR_DOMAIN_VIDEO_TYPE_BOCHS: model = "bochs-display"; @@ -4367,7 +4383,9 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps, model = "virtio-gpu-gl"; else model = "virtio-gpu"; + *virtio = true; + *virtioBusSuffix = true; break; case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: case VIR_DOMAIN_VIDEO_TYPE_VGA: @@ -4406,14 +4424,15 @@ qemuBuildDeviceVideoStr(const virDomainDef *def, const char *model = NULL; virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; bool virtio = false; + bool virtioBusSuffix = false; if (video->accel) accel3d = video->accel->accel3d; - if (!(model = qemuDeviceVideoGetModel(qemuCaps, video, &virtio))) + if (!(model = qemuDeviceVideoGetModel(qemuCaps, video, &virtio, &virtioBusSuffix))) return NULL; - if (virtio) { + if (virtioBusSuffix) { if (qemuBuildVirtioDevStr(&buf, model, qemuCaps, VIR_DOMAIN_DEVICE_VIDEO, video) < 0) { return NULL; -- 2.31.1