From nobody Tue Dec 16 08:34:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1749040391; cv=none; d=zohomail.com; s=zohoarc; b=Es5B+yQfAJ58B/wz3hE61TyM1LlQ0h8o5QqM9HQadmuGoM2qUtc/sDm1jB3Jx5jmkKWUrHwwGvWqe4kgIsLpdsmN9AFnCMayteDo+UAhx3VrSt40zVznxFYGZ0r7AZVIWt0tJjy3Sx3bPVhqUcnilAA1U90FqoV+GZqzZYgCEbc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749040391; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=e6FlyblRjnBD1T1ZlVijwK2zxqYtZyjikcNyjMgWtjk=; b=BdSGH3Dw2PrIuvEW2JICsJ6Vtk9qVpxhjOaz2sRRhthNeXXCQnKZKoa99bQPZ/UjrlTtTJebLfON/FSBelrYGtzYBa8sldiUfnGeIuLfVcdFDeq6WbvIs+izjTaJ5bACbBzlug4eJ6jow7gc4RtPsb3al7EWtbgosyZzIZudUzY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1749040391526102.01266833232432; Wed, 4 Jun 2025 05:33:11 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7F899143A; Wed, 4 Jun 2025 08:33:10 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C209E128C; Wed, 4 Jun 2025 08:32:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8A0451210; Wed, 4 Jun 2025 08:32:25 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 127A7CA6 for ; Wed, 4 Jun 2025 08:32:25 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-22-6fWmeJIGP9CLe5UFLDOK7g-1; Wed, 04 Jun 2025 08:32:23 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 45CB718002BF for ; Wed, 4 Jun 2025 12:32:22 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3112919560B1; Wed, 4 Jun 2025 12:32:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1749040344; h=from:from: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: in-reply-to:in-reply-to:references:references; bh=9DCHnCCwgwp5AC0MzJLRuLyvqhI0bpH/SQ0DAbM1TGs=; b=G33FXe+noBTMJ8C4hWaFUqO3ZYpzpqWVb+cXELaX5e0kXWjUPTEOSOPMe/sHG5VL9EUc9j +ZFTJSNmHYu2jZOxsqUq28w84FnmxzkMBZyFFsO4UzEx1pvL4uRuXqm/7ECwu/d948NO4k /E+VAxgf8ENPx7QJfBJPg9JeisHe/xU= X-MC-Unique: 6fWmeJIGP9CLe5UFLDOK7g-1 X-Mimecast-MFC-AGG-ID: 6fWmeJIGP9CLe5UFLDOK7g_1749040342 To: devel@lists.libvirt.org Subject: [PATCH v2 1/4] conf: VNC graphics parse refactor Date: Wed, 4 Jun 2025 14:24:12 +0200 Message-ID: <20250604123215.34281-2-kshcheti@redhat.com> In-Reply-To: <20250604123215.34281-1-kshcheti@redhat.com> References: <20250604123215.34281-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: K4m_dsIF7pCJt3xPvZplVmtnP84Nc8SB2oM4AKs_CAo_1749040342 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6CYIDNAWLHDSRDPQJQNHZOBFZLS4WQPE X-Message-ID-Hash: 6CYIDNAWLHDSRDPQJQNHZOBFZLS4WQPE X-MailFrom: kshcheti@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Kirill Shchetiniuk X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1749040393708116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Previously, the VNC graphics definition parsing were implemented by string parsing, the virDomainGraphicsDefParseXMLVNC was refactored to use the appropriate virXMLProp* utility functions. Overall parsing logic was not changed and results the same output as before. Signed-off-by: Kirill Shchetiniuk --- src/conf/domain_conf.c | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b3b0bd7329..c16aa279fb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11815,46 +11815,46 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphics= Def *def, xmlXPathContextPtr ctxt, unsigned int flags) { - g_autofree char *port =3D virXMLPropString(node, "port"); - g_autofree char *websocketGenerated =3D virXMLPropString(node, "websoc= ketGenerated"); - g_autofree char *autoport =3D virXMLPropString(node, "autoport"); xmlNodePtr audioNode; + virTristateBool autoport; + virTristateBool websocketGenerated; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) return -1; =20 - if (port) { - if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vnc port %1$s"), port); - return -1; - } + if (virXMLPropInt(node, "port", 10, VIR_XML_PROP_NONE, + &def->data.vnc.port, 0) < 0) + return -1; + + if (def->data.vnc.port =3D=3D -1) { /* Legacy compat syntax, used -1 for auto-port */ - if (def->data.vnc.port =3D=3D -1) { - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) - def->data.vnc.port =3D 0; - def->data.vnc.autoport =3D true; - } - } else { - def->data.vnc.port =3D 0; def->data.vnc.autoport =3D true; } =20 - if (autoport) { - ignore_value(virStringParseYesNo(autoport, &def->data.vnc.autoport= )); - - if (def->data.vnc.autoport && flags & VIR_DOMAIN_DEF_PARSE_INACTIV= E) - def->data.vnc.port =3D 0; + if (def->data.vnc.port =3D=3D 0) { + /* No port specified */ + def->data.vnc.autoport =3D true; } =20 + if (virXMLPropTristateBool(node, "autoport", VIR_XML_PROP_NONE, + &autoport) < 0) + return -1; + + virTristateBoolToBool(autoport, &def->data.vnc.autoport); + + if (def->data.vnc.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + def->data.vnc.port =3D 0; + if (virXMLPropInt(node, "websocket", 10, VIR_XML_PROP_NONE, &def->data.vnc.websocket, 0) < 0) return -1; =20 - if (websocketGenerated) - ignore_value(virStringParseYesNo(websocketGenerated, - &def->data.vnc.websocketGenerated)); + if (virXMLPropTristateBool(node, "websocketGenerated", VIR_XML_PROP_NO= NE, + &websocketGenerated) < 0) + return -1; + + virTristateBoolToBool(websocketGenerated, &def->data.vnc.websocketGene= rated); =20 if (virXMLPropEnum(node, "sharePolicy", virDomainGraphicsVNCSharePolicyTypeFromString, --=20 2.49.0