From nobody Tue Feb 10 13:23:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=riseup.net ARC-Seal: i=1; a=rsa-sha256; t=1680798238; cv=none; d=zohomail.com; s=zohoarc; b=egoVo2F92dpwgTVjMUhgat3UOgZ5o3wuXaXIMw+zhBjmPG6F+4jWdNA74zLdYFRcthnKhyXvHzT1qpAqTu4Y5trCPNugvmpuJTLFDWvQc+iBUu3XqDWvEtbjzsi5+ur1Fqedo9vTF7hL1HwzZZJ5Ve/b6161liE+mZuqg+idji4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680798238; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FWGMKVFdWpXJh6ZsGHtmWUO3OnSjNg0I4mueO/PW5yY=; b=lPJRM+0ccQPEyVgtyG2ZsZdvdOsprxCP6+4aOel7uuN57XeqiP0mxoI2zqBA0Ut7fSFXgtuVtMIdkIe52PLlsY9Z3xV95d+qSt+35NxOg80aBL+OKvtOcsk98buHm3FFCtZlDa3cSI1vVt2/u80MJeWA/TVbmo2QIHJkFUncflQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 168079823871131.929073596417766; Thu, 6 Apr 2023 09:23:58 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-474-cAEcW-7pNma-LKPGGRQyTg-1; Thu, 06 Apr 2023 12:23:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 190AF858F09; Thu, 6 Apr 2023 16:23:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D3F92166B26; Thu, 6 Apr 2023 16:23:51 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 045AC194658F; Thu, 6 Apr 2023 16:23:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 7E15D1946587 for ; Thu, 6 Apr 2023 16:23:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 29ED7C56707; Thu, 6 Apr 2023 16:23:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 21FD8C56706 for ; Thu, 6 Apr 2023 16:23:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 919A4858289 for ; Thu, 6 Apr 2023 16:23:48 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-488-eHHpTRTuMuKigyhH1KJz5w-1; Thu, 06 Apr 2023 12:23:46 -0400 Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4Psmyn5NJNzDqtg for ; Thu, 6 Apr 2023 16:23:45 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4Psmym4MdDz1yPW; Thu, 6 Apr 2023 16:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680798237; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FWGMKVFdWpXJh6ZsGHtmWUO3OnSjNg0I4mueO/PW5yY=; b=cwRRDFZknZvJWbHpE2Xm1QMOjLpMEGSTV8f3G6hQMaP928qFJuCCYmclZ02dZjTSskpOm0 xArl939P6MPk6/4PZmZyaSaY05g0Cn1lExUJptOUAlGzu7ebzDYiwz1V3L/rZJ1cBMejdk RQiB/uRCTNjp7YZ6nwjD7e2wedIk/7k= X-MC-Unique: cAEcW-7pNma-LKPGGRQyTg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: eHHpTRTuMuKigyhH1KJz5w-1 X-Riseup-User-ID: 7897F01740F39DBC397C6A9ABFF418C96A253B03E7561410C6682B335BD7B7CE From: K Shiva To: libvir-list@redhat.com Subject: [libvirt PATCH v4] Conf: Move validation of virDomainGraphicsListenDef out of Parser Date: Thu, 6 Apr 2023 21:53:32 +0530 Message-Id: <20230406162332.149923-1-shiva_kr@riseup.net> 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 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: K Shiva Kiran Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: riseup.net Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1680798239520100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: K Shiva Kiran In an effort to separate the validation steps from the Parse stage, a few validation checks of virDomainGraphicsListenDef have been moved from virDomainGraphicsListenDefParseXML() in domain_conf.c to virDomainGraphicsDefListensValidate() in domain_validate.c Signed-off-by: K Shiva Reviewed-by: Michal Privoznik --- This is a v4 of: https://listman.redhat.com/archives/libvir-list/2023-April/239286.html This commit has been squashed with v3. diff to v3: - Dropped virDomainGraphicsListenDefValidate() as per suggestion - Moved the above's code to virDomainGraphicsDefListensValidate() - Moved an existing if() condition in virDomainGraphicsDefListensValidate()=20 into the switch() statement of the freshly moved code src/conf/domain_conf.c | 30 +----------------------------- src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 70e4d52ee6..8df751cc46 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10986,7 +10986,6 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, /** * virDomainGraphicsListenDefParseXML: * @def: listen def pointer to be filled - * @graphics: graphics def pointer * @node: xml node of element * @parent: xml node of element * @flags: bit-wise or of VIR_DOMAIN_DEF_PARSE_* @@ -10998,13 +10997,11 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, */ static int virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDef *def, - virDomainGraphicsDef *graphics, xmlNodePtr node, xmlNodePtr parent, unsigned int flags) { int ret =3D -1; - const char *graphicsType =3D virDomainGraphicsTypeToString(graphics->t= ype); g_autofree char *address =3D virXMLPropString(node, "address"); g_autofree char *network =3D virXMLPropString(node, "network"); g_autofree char *socketPath =3D virXMLPropString(node, "socket"); @@ -11021,31 +11018,6 @@ virDomainGraphicsListenDefParseXML(virDomainGraphi= csListenDef *def, VIR_XML_PROP_REQUIRED, &def->type) < 0) goto error; =20 - switch (def->type) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: - if (graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && - graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("listen type 'socket' is not available for gr= aphics type '%1$s'"), - graphicsType); - goto error; - } - break; - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: - if (graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE && - graphics->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("listen type 'none' is not available for grap= hics type '%1$s'"), - graphicsType); - goto error; - } - break; - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: - break; - } - if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { if (address && addressCompat && STRNEQ(address, addressCompat)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -11148,7 +11120,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= ef *def, def->listens =3D g_new0(virDomainGraphicsListenDef, nListens); =20 for (i =3D 0; i < nListens; i++) { - if (virDomainGraphicsListenDefParseXML(&def->listens[i], def, + if (virDomainGraphicsListenDefParseXML(&def->listens[i], listenNodes[i], i =3D=3D 0 ? node : NUL= L, flags) < 0) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 9265fef4f9..988f0854a5 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2631,14 +2631,39 @@ static int virDomainGraphicsDefListensValidate(const virDomainGraphicsDef *def) { size_t i; + const char *graphicsType =3D virDomainGraphicsTypeToString(def->type); =20 for (i =3D 0; i < def->nListens; i++) { - if (def->listens[i].type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NE= TWORK && - !def->listens[i].network) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("'network' attribute is required for " - "listen type 'network'")); - return -1; + switch (def->listens[i].type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!def->listens[i].network) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'network' attribute is required for " + "listen type 'network'")); + return -1; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + if (def->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && + def->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("listen type 'socket' is not available fo= r graphics type '%1$s'"), + graphicsType); + return -1; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + if (def->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE && + def->type !=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("listen type 'none' is not available for = graphics type '%1$s'"), + graphicsType); + return -1; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } } =20 --=20 2.40.0