The code that decides video card model is going to be reworked
and expanded. Separate it out into a function.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4b676fe8fc..7ca099bb39 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4195,18 +4195,11 @@ qemuBuildSoundCommandLine(virCommand *cmd,
}
-
-static char *
-qemuBuildDeviceVideoStr(const virDomainDef *def,
- virDomainVideoDef *video,
- virQEMUCaps *qemuCaps)
+static const char *
+qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
+ const virDomainVideoDef *video)
{
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
const char *model = NULL;
- virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT;
-
- if (video->accel)
- accel3d = video->accel->accel3d;
/* We try to chose the best model for primary video device by preferring
* model with VGA compatibility mode. For some video devices on some
@@ -4231,6 +4224,25 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
return NULL;
}
+ return model;
+}
+
+
+static char *
+qemuBuildDeviceVideoStr(const virDomainDef *def,
+ virDomainVideoDef *video,
+ virQEMUCaps *qemuCaps)
+{
+ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+ const char *model = NULL;
+ virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT;
+
+ if (video->accel)
+ accel3d = video->accel->accel3d;
+
+ if (!(model = qemuDeviceVideoGetModel(qemuCaps, video)))
+ return NULL;
+
if (STREQ(model, "virtio-gpu") || STREQ(model, "vhost-user-gpu"))
{
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) &&
accel3d == VIR_TRISTATE_SWITCH_ON &&
--
2.31.1