From nobody Mon Feb 9 10:50:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1605512643; cv=none; d=zohomail.com; s=zohoarc; b=GwUbY7BXe80O36K99fls+Wr1fqHzPou4noGxAOmbKEycRL0saww/xe5v180FVONDsyc8pybdLPPrwSTC9+lCCcIQFP/k96jtA5r9r527avJ9nP8UroFIUI3hQZyzQmqGk0GGEEGJ3ZecO5Vc9+BTL/pQ8CuPOag71w0nWxYioTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605512643; 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=1JIlLJS77cRxbmWfMMwzfD/2sSSxVB/1z9XTG60py+Y=; b=khQiLayU8ka/AYWxd2GfxOhmBva5Y6uVtTdh8pvpOt+aP+KSFE7uM/GLL3rRfGhtJSpbwdzpkRTKi4NgsAuf9KpSnppdhacDKtLGWPCQhMmEDZbaQOBYbg3tGIzPkjtAk0AJP7ihxJeG8Njo3TCJn5SwoKuFDfrB0ChT2CWl1g0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1605512643582852.8291594077798; Sun, 15 Nov 2020 23:44:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-8z_p-UafOcmuPwr8FaAjxA-1; Mon, 16 Nov 2020 02:43:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E9DA188C12E; Mon, 16 Nov 2020 07:43:54 +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 E0A705D9CC; Mon, 16 Nov 2020 07:43:53 +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 BD6BA181A06D; Mon, 16 Nov 2020 07:43:52 +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 0AG7hpT8032554 for ; Mon, 16 Nov 2020 02:43:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id 680875B4BB; Mon, 16 Nov 2020 07:43:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD9D45B4A9 for ; Mon, 16 Nov 2020 07:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605512642; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1JIlLJS77cRxbmWfMMwzfD/2sSSxVB/1z9XTG60py+Y=; b=DEntI0jtewt9349fB5cXfMtRspTu2KMamGdh237B+vyPLyaCY/lV6jZNX/iOD8qt0h/5ZS nQHLoMRMfQv83Kt/tXaS5LSHboyyCSNM+7+IYftuAd+iEUghaSes76oQT7jeq8mlj/hAPF lmAFzjphqYwGOZ2Zd9x60SMy1Qed22U= X-MC-Unique: 8z_p-UafOcmuPwr8FaAjxA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/5] qemu: Validate video model Date: Mon, 16 Nov 2020 08:43:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The aim is to eliminate virDomainCapsDeviceDefValidate(). And in order to do so, the domain video model has to be validated in qemuValidateDomainDeviceDefVideo(). Signed-off-by: Michal Privoznik --- src/conf/domain_capabilities.c | 19 +-------- src/qemu/qemu_validate.c | 42 +++++++++++++++++++ .../default-video-type-x86_64-caps-test-0.err | 2 +- .../video-invalid-multiple-devices.err | 2 +- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index b886ba7090..0e0e6d1600 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -640,22 +640,8 @@ virDomainCapsFormat(const virDomainCaps *caps) } while (0) =20 =20 -static int -virDomainCapsDeviceVideoDefValidate(const virDomainCaps *caps, - const virDomainVideoDef *dev) -{ - if (ENUM_VALUE_MISSING(caps->video.modelType, dev->type)) { - ENUM_VALUE_ERROR("video model", - virDomainVideoTypeToString(dev->type)); - return -1; - } - - return 0; -} - - int -virDomainCapsDeviceDefValidate(const virDomainCaps *caps, +virDomainCapsDeviceDefValidate(const virDomainCaps *caps G_GNUC_UNUSED, const virDomainDeviceDef *dev, const virDomainDef *def G_GNUC_UNUSED) { @@ -663,9 +649,6 @@ virDomainCapsDeviceDefValidate(const virDomainCaps *cap= s, =20 switch ((virDomainDeviceType) dev->type) { case VIR_DOMAIN_DEVICE_VIDEO: - ret =3D virDomainCapsDeviceVideoDefValidate(caps, dev->data.video); - break; - case VIR_DOMAIN_DEVICE_AUDIO: /* TODO: add validation */ break; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index c18865367e..4defdb02cf 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2203,10 +2203,52 @@ static int qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video, virQEMUCapsPtr qemuCaps) { + virQEMUCapsFlags cap =3D QEMU_CAPS_LAST; + /* there's no properties to validate for NONE video devices */ if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) return 0; =20 + switch ((virDomainVideoType) video->type) { + case VIR_DOMAIN_VIDEO_TYPE_VGA: + cap =3D QEMU_CAPS_DEVICE_VGA; + break; + case VIR_DOMAIN_VIDEO_TYPE_CIRRUS: + cap =3D QEMU_CAPS_DEVICE_CIRRUS_VGA; + break; + case VIR_DOMAIN_VIDEO_TYPE_VMVGA: + cap =3D QEMU_CAPS_DEVICE_VMWARE_SVGA; + break; + case VIR_DOMAIN_VIDEO_TYPE_QXL: + cap =3D QEMU_CAPS_DEVICE_QXL; + break; + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + cap =3D QEMU_CAPS_DEVICE_VIRTIO_GPU; + break; + case VIR_DOMAIN_VIDEO_TYPE_BOCHS: + cap =3D QEMU_CAPS_DEVICE_BOCHS_DISPLAY; + break; + case VIR_DOMAIN_VIDEO_TYPE_RAMFB: + cap =3D QEMU_CAPS_DEVICE_RAMFB; + break; + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + 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_NONE: + case VIR_DOMAIN_VIDEO_TYPE_LAST: + /* nada */ + break; + } + + if (!virQEMUCapsGet(qemuCaps, cap)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("domain configuration does not support video mode= l '%s'"), + virDomainVideoTypeToString(video->type)); + return -1; + } + if (!video->primary && video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { diff --git a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.e= rr b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err index 82576471b7..f7b6b57926 100644 --- a/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err +++ b/tests/qemuxml2argvdata/default-video-type-x86_64-caps-test-0.err @@ -1 +1 @@ -unsupported configuration: domain configuration does not support 'video mo= del' value 'default' +unsupported configuration: domain configuration does not support video mod= el 'default' diff --git a/tests/qemuxml2argvdata/video-invalid-multiple-devices.err b/te= sts/qemuxml2argvdata/video-invalid-multiple-devices.err index 7fc20b2370..5c1e557021 100644 --- a/tests/qemuxml2argvdata/video-invalid-multiple-devices.err +++ b/tests/qemuxml2argvdata/video-invalid-multiple-devices.err @@ -1 +1 @@ -unsupported configuration: domain configuration does not support 'video mo= del' value 'qxl' +unsupported configuration: domain configuration does not support video mod= el 'qxl' --=20 2.26.2