mirror of
				https://github.com/libvirt/libvirt.git
				synced 2025-02-25 18:55:26 -06:00 
			
		
		
		
	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 <crobinso@redhat.com> Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
		
				
					committed by
					
						
						Cole Robinson
					
				
			
			
				
	
			
			
			
						parent
						
							d5e9f47e76
						
					
				
				
					commit
					425310d1c8
				
			@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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 &&
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user