The goal is to move all of the video device validation to a single place
and use domain caps to validate the supported video device models. Since
qemuDomainDeviceDefValidateVideo() is called from
qemuProcessStartValidate(), these changes should not change anny
behavior.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/qemu/qemu_domain.c | 14 ++++++++++++--
src/qemu/qemu_process.c | 9 +--------
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 39ab424873..0a6d774437 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5704,7 +5704,8 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef
*hostdev,
static int
-qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
+qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video,
+ virQEMUCapsPtr qemuCaps)
{
switch ((virDomainVideoType) video->type) {
case VIR_DOMAIN_VIDEO_TYPE_NONE:
@@ -5784,6 +5785,15 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video)
}
}
+ if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
+ if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_GPU)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("this QEMU does not support 'vhost-user' video
device"));
+ return -1;
+ }
+ }
+
return 0;
}
@@ -7245,7 +7255,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break;
case VIR_DOMAIN_DEVICE_VIDEO:
- ret = qemuDomainDeviceDefValidateVideo(dev->data.video);
+ ret = qemuDomainDeviceDefValidateVideo(dev->data.video, qemuCaps);
break;
case VIR_DOMAIN_DEVICE_DISK:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 9eaea4edfd..25465f05e2 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5251,14 +5251,7 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
for (i = 0; i < vm->def->nvideos; i++) {
video = vm->def->videos[i];
- if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
- if (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_USER_GPU)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("this QEMU does not support 'vhost-user'
video device"));
- return -1;
- }
- } else {
+ if (video->backend != VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
if ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) ||
(video->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS &&
--
2.21.0