From nobody Tue Feb 10 23:13:28 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=1680785496; cv=none; d=zohomail.com; s=zohoarc; b=F9JW4V9ZqNbW6t17cW7VKNRxCUSltI2V+vk8bhJA6xFYd3VLyFuXJVsb6HhJ2P6O0oQo3REBhsxBNXgRtWhPhfPUIdgfg5JtjqRWPm7ViBZNQq0X6SbxjYFNdn9xt3CakFtPMWBBYmS2v8Lx6caQl1D6umjzxG9RZ8+BzoP/GXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680785496; 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=ulYHPuivWjfrIEzBphJzQYMD2wJBRugSwHiWOb6vr/o=; b=hCT5c5s4EYjNPYGSbh7NL1XeZG4eC/09ztmB9maGpVIK8gAnXm3pNpO7AnVE18Va5UDaIDDoF4mEDf5vrpvKOCIUbSJnt3QlKzpITGREcBA8Cm656WsMJWRWWZz9l9edu9VfiPKlU6HdJId9tuLOrKsRa1DLWPoXzjHveBJirrw= 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 1680785496307280.39347415678264; Thu, 6 Apr 2023 05:51:36 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-78-rYPEbb5qM_mmsLlfIQzAHg-1; Thu, 06 Apr 2023 08:51:33 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4A953C0D87D; Thu, 6 Apr 2023 12:51:29 +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 C78EC492C14; Thu, 6 Apr 2023 12:51:27 +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 7D713194658F; Thu, 6 Apr 2023 12:51:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 258041946587 for ; Thu, 6 Apr 2023 12:51:21 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id E53F018EC6; Thu, 6 Apr 2023 12:51:20 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE1CA18EC7 for ; Thu, 6 Apr 2023 12:51:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 BAC7C1875052 for ; Thu, 6 Apr 2023 12:51:20 +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-453-VJUc4rjlPjOTH4XbF7_fpA-1; Thu, 06 Apr 2023 08:51:18 -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 mx1.riseup.net (Postfix) with ESMTPS id 4PshFd3BFQzDqP6 for ; Thu, 6 Apr 2023 12:51:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews1.riseup.net (Postfix) with ESMTPSA id 4PshFc1Jh4z5wFB; Thu, 6 Apr 2023 12:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680785495; 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=ulYHPuivWjfrIEzBphJzQYMD2wJBRugSwHiWOb6vr/o=; b=ddKLPcCBsJ3WSUSQOKZZWQ20uwqL9qSEN5vHaGoLQzRYbXdtqetvEpbMgvQslavfK1Aa8P RxqwzThEbwIQTaUd8L2xcLWVzSyKMUwM6ugQDiWGG6USJLyQ9C6dRBtVZ4cIXeRSJI6AdN 4B/ILziHZXM7jsAUUPXdfG0YNHjtp2Q= X-MC-Unique: rYPEbb5qM_mmsLlfIQzAHg-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: VJUc4rjlPjOTH4XbF7_fpA-1 X-Riseup-User-ID: 4F6DBCDF5D72B6125E41B16608CFE90B7FD5E748B5B9EA5A6F69BB13273E5849 From: K Shiva To: libvir-list@redhat.com Subject: [libvirt PATCH v3] Conf: Move validation of virDomainGraphicsListenDef out of Parser Date: Thu, 6 Apr 2023 18:21:00 +0530 Message-Id: <20230406125100.16668-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.5 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 Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: 1680785496904100003 Content-Type: text/plain; charset="utf-8"; x-default="true" In an effort to separate the validation steps from the Parse stage, a part of the validation of virDomainGraphicsListenDef has been moved to domain_validate.h. Signed-off-by: K Shiva --- This is a v3 of: https://listman.redhat.com/archives/libvir-list/2023-April/239265.html diff to v2: - Cleaned patch as to be directly applied onto master branch src/conf/domain_conf.c | 30 +----------------------------- src/conf/domain_validate.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 29 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..9a1a8ee156 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; --=20 2.40.0