From 425310d1c83e2e7e9b5dee8a65c0b8d8151a7b6e Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Fri, 18 Oct 2019 10:30:14 -0500 Subject: [PATCH] qemu: validate vhost-user video backend in qemu_domain.c 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. Reviewed-by: Cole Robinson Signed-off-by: Jonathon Jongsma --- 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 d6d10b722c..6d9bf688ce 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5707,7 +5707,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: @@ -5798,6 +5799,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; } @@ -7259,7 +7269,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 4cf4069d50..9e175d17c9 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5219,14 +5219,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 &&