提交 425310d1 编写于 作者: J Jonathon Jongsma 提交者: Cole Robinson

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: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NJonathon Jongsma <jjongsma@redhat.com>
上级 d5e9f47e
...@@ -5707,7 +5707,8 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev, ...@@ -5707,7 +5707,8 @@ qemuDomainDeviceDefValidateHostdev(const virDomainHostdevDef *hostdev,
static int static int
qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video) qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video,
virQEMUCapsPtr qemuCaps)
{ {
switch ((virDomainVideoType) video->type) { switch ((virDomainVideoType) video->type) {
case VIR_DOMAIN_VIDEO_TYPE_NONE: case VIR_DOMAIN_VIDEO_TYPE_NONE:
...@@ -5798,6 +5799,15 @@ qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video) ...@@ -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; return 0;
} }
...@@ -7259,7 +7269,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, ...@@ -7259,7 +7269,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
break; break;
case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_VIDEO:
ret = qemuDomainDeviceDefValidateVideo(dev->data.video); ret = qemuDomainDeviceDefValidateVideo(dev->data.video, qemuCaps);
break; break;
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
......
...@@ -5219,14 +5219,7 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm, ...@@ -5219,14 +5219,7 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
for (i = 0; i < vm->def->nvideos; i++) { for (i = 0; i < vm->def->nvideos; i++) {
video = vm->def->videos[i]; video = vm->def->videos[i];
if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { 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->type == VIR_DOMAIN_VIDEO_TYPE_VGA && if ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) ||
(video->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS && (video->type == VIR_DOMAIN_VIDEO_TYPE_CIRRUS &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册