From nobody Wed Feb 11 07:08:26 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=1680541753; cv=none; d=zohomail.com; s=zohoarc; b=TRBOAexvxCYlSY0RJPwxetN0+HbiikBxp8LwnX/wu34/G6GDIulwG9XBu8FfUz0L28K2fh1ZHZrGrvUqzFns+TXTBleW0xWueYwlrkYGCLtsed3zJi1d7q8VkC4tgsQ8twRbch29zLpm3yLjFsXkLoPF8ED/lczB88AuxcrKdLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680541753; 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=ts0GKu1W0G3oqze505fQ8W7Jzk1xG06nE9NPLEH13k8=; b=GaxFVrJ8oLr/0Nzc0EuatN4tfBAuYPXgu/m6KKt8o5HKwFmsc8fL2ZXl2fORTE1g3IWUDmEw2JJloKX6kAnzlv96hXqV70ZbBIcRVROpaS8aCH0VdWVWzwXY+mrNfJuX1c6Y/NftVTfMrTEXpzGL2SC7aH0by9Aa235qcUY/0f0= 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 1680541753486151.68716436415116; Mon, 3 Apr 2023 10:09:13 -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-16-WWZaLWsJO_uitqkqwyPaUQ-1; Mon, 03 Apr 2023 13:09:09 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1CBE1858F0E; Mon, 3 Apr 2023 17:09:07 +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 8F328C15BA0; Mon, 3 Apr 2023 17:09:06 +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 6A3DF19465B1; Mon, 3 Apr 2023 17:09:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8A95819465A8 for ; Mon, 3 Apr 2023 17:09:05 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 785E71415117; Mon, 3 Apr 2023 17:09:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70702140EBF4 for ; Mon, 3 Apr 2023 17:09:05 +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 4F4373C0F391 for ; Mon, 3 Apr 2023 17:09:05 +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-528-XAiAwI3FN0yzcN_ofFGasA-1; Mon, 03 Apr 2023 13:09:00 -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 4Pqy6L4423z9tDL for ; Mon, 3 Apr 2023 17:08:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4Pqy6K2fZgz5vjc; Mon, 3 Apr 2023 17:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680541752; 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=ts0GKu1W0G3oqze505fQ8W7Jzk1xG06nE9NPLEH13k8=; b=FTKk59bRcP85a/57TFbfYGwcKRXJzOM8dntgkKVZQ1z/7BT/zr9RmI/SnGWyLYLESYUPEj u3K4DL0g+gxMSWJ9147ua/Yf0Itb5jAd/7vLUN+4PM0gRwQt0W8uHe0JNVkwjr3lslqEiF cMchDMuJx/z9XMxfxHnEP6CNdYz2TnA= X-MC-Unique: WWZaLWsJO_uitqkqwyPaUQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: XAiAwI3FN0yzcN_ofFGasA-1 X-Riseup-User-ID: 5A7DF458A994095D7D43467D6126094822484F5E57AD8B47EB92DB7776378A82 From: skran To: libvir-list@redhat.com Subject: [PATCH] Conf: Move validation of Graphics Transport and StorageNetwork Socket out of parser Date: Mon, 3 Apr 2023 22:38:04 +0530 Message-Id: <20230403170804.99953-1-shiva_kr@riseup.net> MIME-Version: 1.0 Signed-off-by: K Shiva 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.7 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.8 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: 1680541753933100001 Content-Type: text/plain; charset="utf-8"; x-default="true" I have implemented your corrections successfully. Thank you. Signed-off-by: K Shiva --- src/conf/domain_conf.c | 42 +++------------------------- src/conf/domain_validate.c | 56 ++++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 7 +++++ 3 files changed, 67 insertions(+), 38 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 70e4d52ee6..1e0ac737bb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5836,20 +5836,9 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode, =20 host->socket =3D virXMLPropString(hostnode, "socket"); =20 - if (host->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_UNIX && - host->socket =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing socket for unix transport")); + // Socket Validation + if (virDomainStorageNetHostSocketValidate(host, transport) < 0) goto cleanup; - } - - if (host->transport !=3D VIR_STORAGE_NET_HOST_TRANS_UNIX && - host->socket !=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, - _("transport '%1$s' does not support socket attribu= te"), - transport); - goto cleanup; - } =20 if (host->transport !=3D VIR_STORAGE_NET_HOST_TRANS_UNIX) { if (!(host->name =3D virXMLPropString(hostnode, "name"))) { @@ -11004,7 +10993,6 @@ virDomainGraphicsListenDefParseXML(virDomainGraphic= sListenDef *def, 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,30 +11009,8 @@ 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 (virDomainGraphicsListenDefValidate(def, graphics) =3D=3D -1) + goto error; =20 if (def->type =3D=3D VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { if (address && addressCompat && STRNEQ(address, addressCompat)) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 9265fef4f9..10f8242c84 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2669,6 +2669,39 @@ 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) { @@ -2898,3 +2931,26 @@ virDomainDeviceDefValidate(const virDomainDeviceDef = *dev, =20 return 0; } + +int +virDomainStorageNetHostSocketValidate(const virStorageNetHostDef *host, + const char* transport) +{ + if (host->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_UNIX && + host->socket =3D=3D NULL) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("missing socket for unix transport")); + return -1; + } + + if (host->transport !=3D VIR_STORAGE_NET_HOST_TRANS_UNIX && + host->socket !=3D NULL) { + virReportError(VIR_ERR_XML_ERROR, + _("transport '%1$s' does not support socket attribu= te"), + transport); + return -1; + } + + + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index fc441cef5b..baeae4b2a3 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -47,3 +47,10 @@ int virDomainDiskDefSourceLUNValidate(const virStorageSo= urce *src); =20 int virDomainDefOSValidate(const virDomainDef *def, virDomainXMLOption *xmlopt); + +int +virDomainGraphicsListenDefValidate(const virDomainGraphicsListenDef *def, + const virDomainGraphicsDef *graphics); + +int virDomainStorageNetHostSocketValidate(const virStorageNetHostDef *host, + const char *transport); --=20 2.40.0