qemu: validate virtio-gpu with vhost-user

Check qemu capability, and accept 3d acceleration. 3d acceleration
support is checked when looking for a suitable vhost-user helper.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Marc-André Lureau 2019-09-23 14:44:31 +04:00 committed by Cole Robinson
parent 6396a478f4
commit c3d0831745
2 changed files with 34 additions and 26 deletions

View File

@ -5266,34 +5266,43 @@ qemuProcessStartValidateVideo(virDomainObjPtr vm,
for (i = 0; i < vm->def->nvideos; i++) {
video = vm->def->videos[i];
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))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("this QEMU does not support '%s' video device"),
virDomainVideoTypeToString(video->type));
return -1;
}
if (video->accel) {
if (video->accel->accel3d == VIR_TRISTATE_SWITCH_ON &&
(video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO ||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL))) {
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 &&
!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))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("%s 3d acceleration is not supported"),
_("this QEMU does not support '%s' video device"),
virDomainVideoTypeToString(video->type));
return -1;
}
if (video->accel) {
if (video->accel->accel3d == VIR_TRISTATE_SWITCH_ON &&
(video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO ||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL))) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("%s 3d acceleration is not supported"),
virDomainVideoTypeToString(video->type));
return -1;
}
}
}
}

View File

@ -2892,8 +2892,7 @@ mymain(void)
DO_TEST("virtio-options", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_KEYBOARD,
QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET,
QEMU_CAPS_VIRTIO_INPUT_HOST,
QEMU_CAPS_DEVICE_VIRTIO_GPU,
QEMU_CAPS_VIRTIO_GPU_VIRGL,
QEMU_CAPS_DEVICE_VHOST_USER_GPU,
QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM,
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,