From nobody Sat Feb 7 21:20:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1607466076; cv=none; d=zohomail.com; s=zohoarc; b=nSM28J20JFOgJ4Y6aaqgKmKhnCVr9tTr4UN4CxYcmUFk1bnHXQ5j33H8v67QKdxuaHZF2rySiQ9y+b3+FG8aJJrLAu/YiRWov+IpJCHOOkHc9Mm4zfmK0uZNP+HAab53f9GdVVLZm+10ETcztpF5pSvkfCjd5DqH4eDQ2sjdUsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466076; 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=892a/Gkqqd+rYjHM6rXBie7/gKh3cNZpzJFLmXc5IAE=; b=YEK6AzUiFu1lSy9acE/sHZDNFoOQ+YVsUyc+czW51K0wq8IaIFM2rXSg+M1mlPIAE00OpSATxn1YG06gIoy1hFQ9j9FJCJJpj/TZyDUOXonEF/NLB8h+ZIjt0vHw6LklbiUcmxzTtLsXGLVKt45KAfEKuIdj6OIlbrfpTLasBvg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466076866542.4678899130842; Tue, 8 Dec 2020 14:21:16 -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-95-OkoBh6dDM8OlAl30_dDjhQ-1; Tue, 08 Dec 2020 17:21:12 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FDF4802B49; Tue, 8 Dec 2020 22:21:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A5745C1BD; Tue, 8 Dec 2020 22:21:05 +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 D8F694E590; Tue, 8 Dec 2020 22:21:04 +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 0B8ML1i2017263 for ; Tue, 8 Dec 2020 17:21:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 05C46112D42C; Tue, 8 Dec 2020 22:21:01 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00076112D422 for ; Tue, 8 Dec 2020 22:20:58 +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 38A92811E85 for ; Tue, 8 Dec 2020 22:20:58 +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-486-rTVXA8wCOA294vVHdy2UsA-1; Tue, 08 Dec 2020 17:20:56 -0500 Received: by mail-qk1-f193.google.com with SMTP id 143so191202qke.10 for ; Tue, 08 Dec 2020 14:20:55 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.20.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:20:54 -0800 (PST) X-MC-Unique: OkoBh6dDM8OlAl30_dDjhQ-1 X-MC-Unique: rTVXA8wCOA294vVHdy2UsA-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=892a/Gkqqd+rYjHM6rXBie7/gKh3cNZpzJFLmXc5IAE=; b=EZ4XJJmgQc0LD0iaLGQoDtt5uJ6Tz8EV8+D++GCfHm5yizJjDb++tOppO3Y8bYTHO9 gCy2Kh3xHnah7aMMuHpjqqyYUxofUsNXB/l+Ka41Ef4TJ23Jcsf6DWh/rySrSJthaZkN stbdQ9pOlTsMVN2aXpgj67Y5YJQ/lRw4B6eZAT38TjSk58l/OoWhcmQXA3ugbn6BSrc+ TNBpy7W5E8taZLrub6O/EzPWx/pV13IicRk8svAWRy6QT80iu6wFKio/Ct3bxxPyqxHJ bKqzanXi+JUz+IZfW+SHbeYXqe/BKPMhOZyM7Y3wy4TFQX4dFOqxxRSLtCXTf3HUzeph nYww== X-Gm-Message-State: AOAM5333bi2W+S7nscr95HfsnfLuLLLJQYcaIBRBHkK/jEmmIgr0Rbef XLSG+7qPd7FlY3mlxIitI1ABwaxT/xI= X-Google-Smtp-Source: ABdhPJwd5+7uvQrQtNC80vZE+CE+iC580egcD0LI2PLQgJSVne8+gHlXRKsDSNNdq8tol9tJ5ZqbEA== X-Received: by 2002:a05:620a:624:: with SMTP id 4mr32223917qkv.351.1607466055332; Tue, 08 Dec 2020 14:20:55 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 03/14] domain_conf.c: move virDomainVideoDefValidate() to domain_validate.c Date: Tue, 8 Dec 2020 19:20:19 -0300 Message-Id: <20201208222030.1302229-4-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.16 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 Content-Type: text/plain; charset="utf-8" We'll add more video validations into the function in the next patch. Let's move it beforehand to domain_validate.c. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 57 -------------------------------------- src/conf/domain_validate.c | 57 ++++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 2 ++ 3 files changed, 59 insertions(+), 57 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a8bd54a368..d80bc8495e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6612,63 +6612,6 @@ virDomainHostdevDefValidate(const virDomainHostdevDe= f *hostdev) } =20 =20 -static int -virDomainVideoDefValidate(const virDomainVideoDef *video, - const virDomainDef *def) -{ - size_t i; - - if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing video model and cannot determine default= ")); - return -1; - } - - /* it doesn't make sense to pair video device type 'none' with any oth= er - * types, there can be only a single video device in such case - */ - for (i =3D 0; i < def->nvideos; i++) { - if (def->videos[i]->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE && - def->nvideos > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("a 'none' video type must be the only video d= evice " - "defined for the domain")); - return -1; - } - } - - switch (video->backend) { - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER: - if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("'vhostuser' driver is only supported with 'v= irtio' device")); - return -1; - } - break; - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT: - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU: - if (video->accel && video->accel->rendernode) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported rendernode accel attribute witho= ut 'vhostuser'")); - return -1; - } - break; - case VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST: - default: - virReportEnumRangeError(virDomainInputType, video->backend); - return -1; - } - - if (video->res && (video->res->x =3D=3D 0 || video->res->y =3D=3D 0)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("video resolution values must be greater than 0")= ); - return -1; - } - - return 0; -} - - static int virDomainMemoryDefValidate(const virDomainMemoryDef *mem, const virDomainDef *def) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index eb2ef6c7fb..c81fd296b9 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -73,3 +73,60 @@ virDomainDefVideoValidate(const virDomainDef *def) =20 return 0; } + + +int +virDomainVideoDefValidate(const virDomainVideoDef *video, + const virDomainDef *def) +{ + size_t i; + + if (video->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing video model and cannot determine default= ")); + return -1; + } + + /* it doesn't make sense to pair video device type 'none' with any oth= er + * types, there can be only a single video device in such case + */ + for (i =3D 0; i < def->nvideos; i++) { + if (def->videos[i]->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE && + def->nvideos > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("a 'none' video type must be the only video d= evice " + "defined for the domain")); + return -1; + } + } + + switch (video->backend) { + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER: + if (video->type !=3D VIR_DOMAIN_VIDEO_TYPE_VIRTIO) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("'vhostuser' driver is only supported with 'v= irtio' device")); + return -1; + } + break; + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_QEMU: + if (video->accel && video->accel->rendernode) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported rendernode accel attribute witho= ut 'vhostuser'")); + return -1; + } + break; + case VIR_DOMAIN_VIDEO_BACKEND_TYPE_LAST: + default: + virReportEnumRangeError(virDomainInputType, video->backend); + return -1; + } + + if (video->res && (video->res->x =3D=3D 0 || video->res->y =3D=3D 0)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("video resolution values must be greater than 0")= ); + return -1; + } + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index df4f35c1dd..ed170391f8 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -26,3 +26,5 @@ =20 int virDomainDefBootValidate(const virDomainDef *def); int virDomainDefVideoValidate(const virDomainDef *def); +int virDomainVideoDefValidate(const virDomainVideoDef *video, + const virDomainDef *def); --=20 2.26.2