From nobody Mon Feb 9 17:58:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570829286; cv=none; d=zoho.com; s=zohoarc; b=jO2HA+mpGILtQ1yjjnLzR2cMz1jpx0ZcA8IFTmq2zcB4IGXCy7E7RCDA8rnwEj4cVkCz85r56kebuqvjObCkFX6vEdH5ySBRAKRihH9vNZ5bofFotM4WnaK59uTA6QYyGgNoVvtq6MqZFnkAh5pe2blvnZ/f3oc+AAKujvNQLpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570829286; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tXrYS+cOYrYgrUXW3mhbJzERBvBDX1c8M/9MqLFvvCw=; b=MdXepOMBmu0U/kADgpOb2/MkH9vTtAzDDMcvR1PPJsEdQdQo8yF1ZVtCjUUkNTiiF42fyjd6NTKGOxxuj04WdKy3TIKjpG6cIzDa4hui7umKhxkp9NrFNoI2EzwW7d9dgzBpjrjN3bBuPiOSRkh/VsYNUo2T80x2iE311GKp+T8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 157082928646513.181674773363284; Fri, 11 Oct 2019 14:28:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8A70CCFE6; Fri, 11 Oct 2019 21:28:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C37445D713; Fri, 11 Oct 2019 21:28:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7E98D180BA96; Fri, 11 Oct 2019 21:28:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9BLRxMW007307 for ; Fri, 11 Oct 2019 17:27:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 93657601B7; Fri, 11 Oct 2019 21:27:59 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-118-45.phx2.redhat.com [10.3.118.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58A38600CC; Fri, 11 Oct 2019 21:27:59 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Fri, 11 Oct 2019 16:27:51 -0500 Message-Id: <20191011212752.27139-6-jjongsma@redhat.com> In-Reply-To: <20191011212752.27139-1-jjongsma@redhat.com> References: <20191011212752.27139-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 5/6] qemu: unify domain caps validation for video devices X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 11 Oct 2019 21:28:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" As suggested by Cole, this patch uses the domain capabilities to validate the supported video model types. By using the domain capabilities, the validation will automatically adjust when new enum members are added. Signed-off-by: Jonathon Jongsma --- src/conf/domain_capabilities.c | 17 ++++++++++++- src/qemu/qemu_domain.c | 45 ---------------------------------- 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index fe93388cce..baf33b4722 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -686,6 +686,19 @@ virDomainCapsDeviceRNGDefValidate(virDomainCapsPtr con= st caps, return 0; } =20 +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; +} + =20 int virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps, @@ -698,6 +711,9 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const c= aps, case VIR_DOMAIN_DEVICE_RNG: ret =3D virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng); break; + case VIR_DOMAIN_DEVICE_VIDEO: + ret =3D virDomainCapsDeviceVideoDefValidate(caps, dev->data.video); + break; =20 case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_REDIRDEV: @@ -706,7 +722,6 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const c= aps, 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 def90a0f7d..bb34638427 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5717,51 +5717,6 @@ qemuDomainDeviceDefValidateVideo(const virDomainVide= oDef *video, return -1; } } else { - switch ((virDomainVideoType) video->type) { - case 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 QE= MU"), - 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->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VGA && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) || - (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_CIRRUS && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_CIRRUS_VGA)) || - (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VMVGA && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMWARE_SVGA)) || - (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QXL)) || - (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU)) || - (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - video->info.type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_GPU_CCW)) || - (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_BOCHS && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_BOCHS_DISPLAY)) || - (video->type =3D=3D 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; - } - if (!video->primary && video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list