From nobody Tue Feb 10 18:58:59 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=1680631858; cv=none; d=zohomail.com; s=zohoarc; b=TKBxkR/jTveqIKNLh0cGuXv2IDB7N3ejOKXp+pSIrot6YYAchbQoVi8FzLA/YoF+ovalwQJ6gxZjoDK8EFfXHYo/0cQo5uG0WbCXwrGSlwaohcoUASsKtGRPelHlVITqcwXQq83iFE1BpfErswj0KkkMk11Exlmy5Nzq16XPVf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680631858; 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=7xtOYg+SuN1cIgR80YGa+KgVl8qeEChQWaakg/pBLUI=; b=gD9rT+ZGvX6Swq0ziEeyTE3oBmusoPRgTeSsb4E+UzokwWPBeydBG7X0x0xdbvzqBBpGlhE1g+yRRhIwn7oMddGUWXAv37q8U3I8XHoWgtkeGMdsXMULBA6pf8sBc8dtH4g47t20cLT0T1YsE7+YzF9Jy/1Kb+Qvntzyw/MeL0Y= 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 1680631858726114.01639271572446; Tue, 4 Apr 2023 11:10: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-442-Bib-va2kPxSI2FDfwMiwNQ-1; Tue, 04 Apr 2023 14:10:53 -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 650C58828CA; Tue, 4 Apr 2023 18:10:31 +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 43F522166B26; Tue, 4 Apr 2023 18:10:31 +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 016E51946597; Tue, 4 Apr 2023 18:10:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 40AE41946595 for ; Tue, 4 Apr 2023 18:10:30 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E237D492C14; Tue, 4 Apr 2023 18:10:29 +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 DB00B492C13 for ; Tue, 4 Apr 2023 18:10:29 +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 C075A101A531 for ; Tue, 4 Apr 2023 18:10:29 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-i3Pbq9HpM7G_1mDX6SezIw-1; Tue, 04 Apr 2023 14:10:28 -0400 Received: from fews1.riseup.net (fews1-pn.riseup.net [10.0.1.83]) (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 mx0.riseup.net (Postfix) with ESMTPS id 4PrbQp6kjYz9s8c for ; Tue, 4 Apr 2023 18:10:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4PrbQn5KXzz5wGf; Tue, 4 Apr 2023 18:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680631857; 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=7xtOYg+SuN1cIgR80YGa+KgVl8qeEChQWaakg/pBLUI=; b=VQG4jE9gIvisFDVq3t3nckSewIMYwoCKHG52qLpQkeBIO3RkxqJqzW+DbOgxirmz6oV2Q7 Qqs1FZXNcm4FOWA6zvDVIUoHsUzcIX4W0ALQIAJT6OaFywHbRtYODS5r1zRJnXYI07E9oh PVsbaaXkCROF2V9qN8rl5vSdDrYZP6Y= X-MC-Unique: Bib-va2kPxSI2FDfwMiwNQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: i3Pbq9HpM7G_1mDX6SezIw-1 X-Riseup-User-ID: 4EFB748F502BF0148A9EDBEF45E75364EFEDF7F6634435696D0ACF3CB035DCCE From: skran To: libvir-list@redhat.com Subject: [PATCH] Conf: Move validation of Graphics Transport and StorageNetwork Socket out of parser Date: Tue, 4 Apr 2023 23:40:12 +0530 Message-Id: <20230404181012.47708-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.9 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: skran 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: 1680631860589100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Thank you for the corrections. I understand it now. [1] I have made the Graphics Transport validation function static and moved= its call out of the parser, to virDomainGraphicsDefListensValidate() in do= main_validate.h. Is this a correct implementation?, it does pass the tests. I have removed the *graphics def parameter from ParseXML function as it bec= ame unused after moving the validation out of the Parser. [2] I can't find a way to implement virDomainStorageNetHostSocketValidate()= as static. Could you please point as to which function within domain_valid= ate.h could be used to call this validation function? similar to virDomainG= raphicsDefListensValidate() for [1]. [3] How do I obtain char *transport within the validation function without = parameter passing? It's used only to report this error in the below snippet=20 virReportError(VIR_ERR_XML_ERROR, _("transport '%1$s' does not support socket attribut= e"), transport); Do I use virXMLPropString(hostnode, "transport") after passing xmlNodePtr h= ostnode as a parameter? How do I obtain these in domain_validate.h. Thank you for your help!=20 Signed-off-by: K Shiva --- src/conf/domain_conf.c | 9 ++--- src/conf/domain_validate.c | 68 ++++++++++++++++++++------------------ src/conf/domain_validate.h | 4 --- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1e0ac737bb..746bb4efdf 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5836,7 +5836,7 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode, =20 host->socket =3D virXMLPropString(hostnode, "socket"); =20 - // Socket Validation + /* Socket Validation */ if (virDomainStorageNetHostSocketValidate(host, transport) < 0) goto cleanup; =20 @@ -10975,7 +10975,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_* @@ -10987,7 +10986,6 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, */ static int virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDef *def, - virDomainGraphicsDef *graphics, xmlNodePtr node, xmlNodePtr parent, unsigned int flags) @@ -11009,9 +11007,6 @@ virDomainGraphicsListenDefParseXML(virDomainGraphic= sListenDef *def, VIR_XML_PROP_REQUIRED, &def->type) < 0) goto error; =20 - if (virDomainGraphicsListenDefValidate(def, graphics) =3D=3D -1) - goto error; - if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { if (address && addressCompat && STRNEQ(address, addressCompat)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -11114,7 +11109,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 10f8242c84..a84dbe8bc9 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2627,6 +2627,39 @@ virDomainAudioDefValidate(const virDomainDef *def, return 0; } =20 +static int +virDomainGraphicsListenDefValidate(const virDomainGraphicsListenDef *def, + const virDomainGraphicsDef *graphics) +{ + const char *graphicsType =3D virDomainGraphicsTypeToString(graphics->t= ype); + + 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); + return -1; + } + 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); + return -1; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; + } + return 0; +} + static int virDomainGraphicsDefListensValidate(const virDomainGraphicsDef *def) { @@ -2640,6 +2673,8 @@ virDomainGraphicsDefListensValidate(const virDomainGr= aphicsDef *def) "listen type 'network'")); return -1; } + if (virDomainGraphicsListenDefValidate(&def->listens[i], def) < 0) + return -1; } =20 return 0; @@ -2669,39 +2704,6 @@ virDomainGraphicsDefValidate(const virDomainDef *def, return 0; } =20 -int -virDomainGraphicsListenDefValidate(const virDomainGraphicsListenDef *def, - const virDomainGraphicsDef *graphics) -{ - const char *graphicsType =3D virDomainGraphicsTypeToString(graphics->t= ype); - - 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); - return -1; - } - 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); - return -1; - } - break; - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: - break; - } - return 0; -} - static int virDomainIOMMUDefValidate(const virDomainIOMMUDef *iommu) { diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index baeae4b2a3..7772a62e18 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -48,9 +48,5 @@ int virDomainDiskDefSourceLUNValidate(const virStorageSou= rce *src); int virDomainDefOSValidate(const virDomainDef *def, virDomainXMLOption *xmlopt); =20 -int -virDomainGraphicsListenDefValidate(const virDomainGraphicsListenDef *def, - const virDomainGraphicsDef *graphics); - int virDomainStorageNetHostSocketValidate(const virStorageNetHostDef *host, const char *transport); --=20 2.40.0