As suggested by Cole, this patch uses the domain capabilities to
validate the supported video model types. This allows us to remove the
model type validation from qemu_process.c and qemu_domain.c and
consolidates it all in a single place that will automatically adjust
when new domain capabilities are added.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/conf/domain_capabilities.c | 17 +++++++++++++-
src/qemu/qemu_domain.c | 23 ++----------------
src/qemu/qemu_process.c | 43 ----------------------------------
3 files changed, 18 insertions(+), 65 deletions(-)
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 43a778a505..f55a6ebf5b 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -686,6 +686,19 @@ virDomainCapsDeviceRNGDefValidate(virDomainCapsPtr const caps,
return 0;
}
+static int
+virDomainCapsDeviceVideoDefValidate(virDomainCapsPtr const caps,
+ const virDomainVideoDefPtr dev)
+{
+ if (ENUM_VALUE_MISSING(caps->video.modelType, dev->type)) {
+ ENUM_VALUE_ERROR("video model",
+ virDomainVideoTypeToString(dev->type));
+ return -1;
+ }
+
+ return 0;
+}
+
int
virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps,
@@ -698,6 +711,9 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps,
case VIR_DOMAIN_DEVICE_RNG:
ret = virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng);
break;
+ case VIR_DOMAIN_DEVICE_VIDEO:
+ ret = virDomainCapsDeviceVideoDefValidate(caps, dev->data.video);
+ break;
case VIR_DOMAIN_DEVICE_DISK:
case VIR_DOMAIN_DEVICE_REDIRDEV:
@@ -706,7 +722,6 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps,
case VIR_DOMAIN_DEVICE_CHR:
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_HOSTDEV:
- case VIR_DOMAIN_DEVICE_VIDEO:
case VIR_DOMAIN_DEVICE_MEMORY:
case VIR_DOMAIN_DEVICE_VSOCK:
case VIR_DOMAIN_DEVICE_INPUT:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8bd5891e53..7ec6c0a748 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5707,28 +5707,9 @@ static int
qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video,
virQEMUCapsPtr qemuCaps)
{
- switch ((virDomainVideoType) video->type) {
- case VIR_DOMAIN_VIDEO_TYPE_NONE:
+ /* there's no properties to validate for NONE video devices */
+ if (video->type == VIR_DOMAIN_VIDEO_TYPE_NONE)
return 0;
- case VIR_DOMAIN_VIDEO_TYPE_XEN:
- case VIR_DOMAIN_VIDEO_TYPE_VBOX:
- case VIR_DOMAIN_VIDEO_TYPE_PARALLELS:
- case VIR_DOMAIN_VIDEO_TYPE_GOP:
- case VIR_DOMAIN_VIDEO_TYPE_DEFAULT:
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("video type '%s' is not supported with
QEMU"),
- virDomainVideoTypeToString(video->type));
- return -1;
- case VIR_DOMAIN_VIDEO_TYPE_VGA:
- case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
- case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
- case VIR_DOMAIN_VIDEO_TYPE_QXL:
- case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
- case VIR_DOMAIN_VIDEO_TYPE_BOCHS:
- case VIR_DOMAIN_VIDEO_TYPE_RAMFB:
- case VIR_DOMAIN_VIDEO_TYPE_LAST:
- break;
- }
if (!video->primary &&
video->type != VIR_DOMAIN_VIDEO_TYPE_QXL &&
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5ef3e37fc2..c066f5eb82 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5241,46 +5241,6 @@ qemuProcessStartValidateGraphics(virDomainObjPtr vm)
}
-static int
-qemuProcessStartValidateVideo(virDomainObjPtr vm,
- virQEMUCapsPtr qemuCaps)
-{
- size_t i;
- virDomainVideoDefPtr video;
-
- 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_VGA &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_VIRTIO &&
- video->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_BOCHS &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY)) ||
- (video->type == VIR_DOMAIN_VIDEO_TYPE_RAMFB &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_RAMFB))) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("this QEMU does not support '%s' video
device"),
- virDomainVideoTypeToString(video->type));
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-
static int
qemuProcessStartValidateIOThreads(virDomainObjPtr vm,
virQEMUCapsPtr qemuCaps)
@@ -5465,9 +5425,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
if (qemuProcessStartValidateGraphics(vm) < 0)
return -1;
- if (qemuProcessStartValidateVideo(vm, qemuCaps) < 0)
- return -1;
-
if (qemuProcessStartValidateIOThreads(vm, qemuCaps) < 0)
return -1;
--
2.21.0