From nobody Sun Feb 8 10:48:53 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1585258350; cv=none; d=zohomail.com; s=zohoarc; b=TkukKtHYDduf8v2JR5zcUsxgGt7Kmo94nIplQCQ7lNWO6zN5IYj5tjCwwPibiInpWbg+D3pBpjLjBEUi2qViadtTP0JOhhNvtH4Ej99AO4xvS1NfyKvX/DuagiSv4/b1owShe7jqILisAhJdYLDMCOTEeAtkcGDsCrjUufXoqn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585258350; h=Content-Type:Content-Transfer-Encoding:Cc: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=YGjnXZzbmmmpIbifzyouFNoalER9CPcl1L5zIaBF92E=; b=R3wt5sbBR9GM42dWIP2VY+hz0cUaGIqmHgGQPX6xdRIVqtY8M+8tuj8u4DyJ+XIbuAFzYcwbnFJgo9fR4vug8vfrghjqbFhbjlCBp6acAv0sT5QchLBvOaZlIMqY8K8w5e4/3OKBStNr7A/8l9Wuk2d5GA590/wJG/iHuHSYCnI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585258350484652.9814270728766; Thu, 26 Mar 2020 14:32:30 -0700 (PDT) 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-482-7Nh17gAtNNeuJpP72hgcvg-1; Thu, 26 Mar 2020 17:32:27 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 927F818C35A3; Thu, 26 Mar 2020 21:32:21 +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 6048310027AF; Thu, 26 Mar 2020 21:32:21 +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 0889B18089C8; Thu, 26 Mar 2020 21:32:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02QLVupS010277 for ; Thu, 26 Mar 2020 17:31:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 839A81055419; Thu, 26 Mar 2020 21:31:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EADD105541B for ; Thu, 26 Mar 2020 21:31:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 617EE101A55A for ; Thu, 26 Mar 2020 21:31:56 +0000 (UTC) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-bQtFsRAJNaWWBnPvDu0i7g-1; Thu, 26 Mar 2020 17:31:54 -0400 Received: by mail-qk1-f193.google.com with SMTP id x3so8679639qki.4; Thu, 26 Mar 2020 14:31:53 -0700 (PDT) Received: from rekt.redhat.com ([2804:431:c7c6:e1ce:90c:c960:468:c347]) by smtp.gmail.com with ESMTPSA id x37sm2357719qtc.90.2020.03.26.14.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 14:31:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585258349; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=YGjnXZzbmmmpIbifzyouFNoalER9CPcl1L5zIaBF92E=; b=H64lfjnecn+yUmjQfTUlH3XmEWtwBGUk81YUNpqPqcP9+n7kQfo+J5L0INVnB78NMZX/Dr ZuMtPD36eb/Zij754WEGRkK5UGyaf0tqsBHXTZZQU9s3VKjerpdO5R413uUxZ0bRpHoOLx n/yGfPpvUfu5eOdv6HXlzRO6UCXhNgE= X-MC-Unique: 7Nh17gAtNNeuJpP72hgcvg-1 X-MC-Unique: bQtFsRAJNaWWBnPvDu0i7g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IuLEzyJlMvIERfBpLrheZ9w90ZsdO8YAaAQ7IZA2GKs=; b=LJqbjuH1Oo/15CdnBn5Q8lsut8pvFWQaec/Oh3I+826JRlsQN2fOKI1egQQlF/dNDV 7vfA4KsAJTAq2t8KoI4L2NXn2i1HKipn2F11V/qQidTDuheYywiU8WwkaR0wm0g0wzu0 SxwBiJbIJ8NhLybOFz19A/ujUWdlHX9kuW/DkH9I5Ao93a8j7Bw3s9oj5zLa4UMuGn3y bQl9/vKTD52iN6axto5VuQrb8ov6LSs1awHZ0q9cVR+fBTa9uxp9LWadVl2vPP+c62gl P2pJCcpY8zjLLIeryfjfMka+GBBitdrqnMHCQfEaN3YAjCtzCO76lTnXf/EkWRXOFWn3 At1Q== X-Gm-Message-State: ANhLgQ13whJddQ1ifpktOk1RPobcI16Sk+KRy0gY6WWQDmYw3BwLhWG6 xybllu30oOnAhSe/xmLThbJ3wAOc X-Google-Smtp-Source: ADFU+vvjHhxEH8AiEMjd4pNmfV94p12yfNq7LNbi2Z5gCyUGPuF7UZ3821NUlTOiaOFktnN/BveWWQ== X-Received: by 2002:a37:aa54:: with SMTP id t81mr11267234qke.234.1585258313082; Thu, 26 Mar 2020 14:31:53 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 08/15] qemu: move qemuDomainDeviceDefValidateVideo() to qemu_validate.c Date: Thu, 26 Mar 2020 18:31:18 -0300 Message-Id: <20200326213125.2306013-9-danielhb413@gmail.com> In-Reply-To: <20200326213125.2306013-1-danielhb413@gmail.com> References: <20200326213125.2306013-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02QLVupS010277 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , pkrempa@redhat.com, crobinso@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.84 on 10.5.11.22 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" Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 98 +--------------------------------------- src/qemu/qemu_validate.c | 96 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_validate.h | 2 + 3 files changed, 99 insertions(+), 97 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 25b889b2d6..6fa2326edc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5245,102 +5245,6 @@ qemuDomainValidateActualNetDef(const virDomainNetDe= f *net, } =20 =20 -static int -qemuDomainDeviceDefValidateVideo(const virDomainVideoDef *video, - virQEMUCapsPtr qemuCaps) -{ - /* there's no properties to validate for NONE video devices */ - if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) - return 0; - - if (!video->primary && - video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && - video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("video type '%s' is only valid as primary " - "video device"), - virDomainVideoTypeToString(video->type)); - return -1; - } - - if (video->accel && video->accel->accel2d =3D=3D VIR_TRISTATE_SWITCH_O= N) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("qemu does not support the accel2d setting")); - return -1; - } - - if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { - if (video->vram > (UINT_MAX / 1024)) { - virReportError(VIR_ERR_OVERFLOW, - _("value for 'vram' must be less than '%u'"), - UINT_MAX / 1024); - return -1; - } - if (video->ram > (UINT_MAX / 1024)) { - virReportError(VIR_ERR_OVERFLOW, - _("value for 'ram' must be less than '%u'"), - UINT_MAX / 1024); - return -1; - } - if (video->vgamem) { - if (video->vgamem < 1024) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("value for 'vgamem' must be at least 1 Mi= B " - "(1024 KiB)")); - return -1; - } - - if (video->vgamem !=3D VIR_ROUND_UP_POWER_OF_TWO(video->vgamem= )) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("value for 'vgamem' must be power of two"= )); - return -1; - } - } - } - - if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VGA && - video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && - video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && - video->type !=3D VIR_DOMAIN_VIDEO_TYPE_BOCHS) { - if (video->res) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("model resolution is not supported")); - return -1; - } - } - - if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VGA || - video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VMVGA) { - if (video->vram && video->vram < 1024) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("value for 'vram' must be at least " - "1 MiB (1024 KiB)")); - return -1; - } - } - - if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { - if (video->type =3D=3D 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' vide= o device")); - return -1; - } - } else if (video->accel) { - if (video->accel->accel3d =3D=3D VIR_TRISTATE_SWITCH_ON && - (video->type !=3D 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; - } - } - - return 0; -} - - int qemuDomainValidateStorageSource(virStorageSourcePtr src, virQEMUCapsPtr qemuCaps) @@ -7073,7 +6977,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, break; =20 case VIR_DOMAIN_DEVICE_VIDEO: - ret =3D qemuDomainDeviceDefValidateVideo(dev->data.video, qemuCaps= ); + ret =3D qemuValidateDomainDeviceDefVideo(dev->data.video, qemuCaps= ); break; =20 case VIR_DOMAIN_DEVICE_DISK: diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 62ecca3c84..0caec1fce3 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1719,3 +1719,99 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHo= stdevDef *hostdev, =20 return 0; } + + +int +qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video, + virQEMUCapsPtr qemuCaps) +{ + /* there's no properties to validate for NONE video devices */ + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) + return 0; + + if (!video->primary && + video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && + video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("video type '%s' is only valid as primary " + "video device"), + virDomainVideoTypeToString(video->type)); + return -1; + } + + if (video->accel && video->accel->accel2d =3D=3D VIR_TRISTATE_SWITCH_O= N) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("qemu does not support the accel2d setting")); + return -1; + } + + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { + if (video->vram > (UINT_MAX / 1024)) { + virReportError(VIR_ERR_OVERFLOW, + _("value for 'vram' must be less than '%u'"), + UINT_MAX / 1024); + return -1; + } + if (video->ram > (UINT_MAX / 1024)) { + virReportError(VIR_ERR_OVERFLOW, + _("value for 'ram' must be less than '%u'"), + UINT_MAX / 1024); + return -1; + } + if (video->vgamem) { + if (video->vgamem < 1024) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("value for 'vgamem' must be at least 1 Mi= B " + "(1024 KiB)")); + return -1; + } + + if (video->vgamem !=3D VIR_ROUND_UP_POWER_OF_TWO(video->vgamem= )) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("value for 'vgamem' must be power of two"= )); + return -1; + } + } + } + + if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VGA && + video->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL && + video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO && + video->type !=3D VIR_DOMAIN_VIDEO_TYPE_BOCHS) { + if (video->res) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("model resolution is not supported")); + return -1; + } + } + + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VGA || + video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_VMVGA) { + if (video->vram && video->vram < 1024) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("value for 'vram' must be at least " + "1 MiB (1024 KiB)")); + return -1; + } + } + + if (video->backend =3D=3D VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) { + if (video->type =3D=3D 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' vide= o device")); + return -1; + } + } else if (video->accel) { + if (video->accel->accel3d =3D=3D VIR_TRISTATE_SWITCH_ON && + (video->type !=3D 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; + } + } + + return 0; +} diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h index ca1449c27f..387c6ce556 100644 --- a/src/qemu/qemu_validate.h +++ b/src/qemu/qemu_validate.h @@ -44,3 +44,5 @@ int qemuValidateDomainWatchdogDef(const virDomainWatchdog= Def *dev, int qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev, const virDomainDef *def, virQEMUCapsPtr qemuCaps); +int qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video, + virQEMUCapsPtr qemuCaps); --=20 2.25.1