From nobody Wed Feb 11 03:27:22 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=1680715730; cv=none; d=zohomail.com; s=zohoarc; b=SkctCPWPapB8OjkRSdB1ha1VHSFVua6oRciwhJizspi2A+vwRgUvGzZO+IIK9pL4w8CWhBiSyv8EKkziBtL++y+0hUIF53fLOgGZlwJKJKRYYssW/HFQezpihkZb0ruRdoz3ZRUbPKy8dQgC7sTPUxhv9N+L/YWBS1qc/lXVnmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680715730; 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=oVhPjBPCu1d0ERZ1dN3qSeteabGBJhEVL7mvRcYLSnY=; b=FQ4+J3N2zkv2YIIlCDcaLFmVA7uYjKx73CkCCY6rlhletow5zPubYDQyeT7Ahc+syAOeWV8MeAGj3dGPEcCdakuSuessexVLjy4R6UYD7itwr6tt0SOslMk/gISBSLrwm3m92AGak3EdVYYSaxe1GvMyEpedsIioMSkrt5LKD+w= 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 1680715730963365.3873148130515; Wed, 5 Apr 2023 10:28:50 -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-418-09OWLVZOPkuGTPYknhSgJA-1; Wed, 05 Apr 2023 13:28:45 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7126A281723A; Wed, 5 Apr 2023 17:28:42 +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 163CB140EBF4; Wed, 5 Apr 2023 17:28:42 +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 9EAF3194658F; Wed, 5 Apr 2023 17:28:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AA8AD1946587 for ; Wed, 5 Apr 2023 17:28:40 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9A6852027062; Wed, 5 Apr 2023 17:28:40 +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 92BD32027061 for ; Wed, 5 Apr 2023 17:28:40 +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-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74EBA185A790 for ; Wed, 5 Apr 2023 17:28:40 +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_128_GCM_SHA256) id us-mta-402-qB2Mn7w4MdugXver8y-qcw-1; Wed, 05 Apr 2023 13:28:38 -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 4PsBS561kxzDrW6 for ; Wed, 5 Apr 2023 17:28:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4PsBS44Y82z1y8c; Wed, 5 Apr 2023 17:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680715730; 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=oVhPjBPCu1d0ERZ1dN3qSeteabGBJhEVL7mvRcYLSnY=; b=F9zaFxwezWhGt4viKdXE0IlM0HvVU5hWz7CVAaWU15tLRFJagSNyNltgNKpYphBsJPW8GP /Bn64WVB4WB8n46Lfj0ZKmX4HLrqKVnvZBPly0eH98sNf3PJ9aeRW8FCvIq8JI0CLmIPa/ Jq7cIH+toEjg1WdU/1c1wbgEc4jLTvs= X-MC-Unique: 09OWLVZOPkuGTPYknhSgJA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: qB2Mn7w4MdugXver8y-qcw-1 X-Riseup-User-ID: 4D7EFF188FCA13EB7ACCDEB521DB8089EF213BC7BAA56DBC672448FB6E9F1580 From: K Shiva To: libvir-list@redhat.com Subject: [PATCH v2] Conf: Move validation of virDomainGraphicsListenDef out of Parser Date: Wed, 5 Apr 2023 22:58:17 +0530 Message-Id: <20230405172817.51328-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.4 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.7 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: 1680715731970100001 Content-Type: text/plain; charset="utf-8"; x-default="true" From: skran 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 v2 of: https://listman.redhat.com/archives/libvir-list/2023-April/239205.html diff to v1: - Made virDomainGraphicsListenDefValidate() static, called by virDomainGraphicsDefListensValidate() - Removed unused Parameter (*graphics) out of Parse Function definition i.e virDomainGraphicsListenParseXML()=20 - Corrected code format 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