From nobody Tue Sep 9 23:37:04 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=1748863039; cv=none; d=zohomail.com; s=zohoarc; b=YW6fC7wI0SWk55PcsharZgm8HdOUuKoDUO6O7wJlqA1wsQPiF3yJDHkX5xrIA9J6/b0XGVpsI61qfUHf8FplJuBOxYVU3zL43z+QY4aEoLk02kvjwK6OatH3/+akg0DDaOFi4V0Z1Xwi3W3sJErHh9Q2aw3uv4KFP1xoP/WSs2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748863039; 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=xxRq6VJ7AGIq07qwGr2VaDVkW5ZCS2XSeLs4VdnB8NI=; b=Ht+DqboGFnaQurNvwPx2ufdMyY7NlUeise0nWZs4ufJwIfxwwI8sTuBfAGTl7FGHNCVCDKL88mFFBgacLk8E1Hp4DwjGwqhSX1Lux5w+g4geotpPc5nUrxvVa5p9/lz5c7j0VILvrvWOA1txjNvdkTwd0ipGNldgJgwGz05RjA4= 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 174886303957165.23349892468457; Mon, 2 Jun 2025 04:17:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 381FB13DC; Mon, 2 Jun 2025 07:17:18 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 693CF1579; Mon, 2 Jun 2025 07:15:43 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9897815BA; Mon, 2 Jun 2025 07:15:37 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 EC0D614BE for ; Mon, 2 Jun 2025 07:15:30 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-OSE_7D0PMvOa0TNeWN7Tcw-1; Mon, 02 Jun 2025 07:15:29 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72C5A1955DAB for ; Mon, 2 Jun 2025 11:15:28 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.com (unknown [10.43.2.246]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 68C94180049D; Mon, 2 Jun 2025 11:15:27 +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=1748862930; 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=y9hWBopJR39lO3so+W/eO8KcrWaSg0YQ8PAVyzapsVw=; b=QRuE1kQb3i6F21jFDqfw0b8Giw5A6uVBB7UGlAkUymiMWBFg1ytJZsQsa04kiigBorkv3i iwlv8mMVOcYh+iyyR0tazIttGGBKpPVEIesPDUpVtitIdmhRKP5Qm6mMs+EGg+yELnkE00 U9+JtYh4gSSN3YSthML8gYo4fla99Qk= X-MC-Unique: OSE_7D0PMvOa0TNeWN7Tcw-1 X-Mimecast-MFC-AGG-ID: OSE_7D0PMvOa0TNeWN7Tcw_1748862928 To: devel@lists.libvirt.org Subject: [PATCH 3/4] conf: RDP graphics parse refactor Date: Mon, 2 Jun 2025 12:39:42 +0200 Message-ID: <20250602111504.387917-4-kshcheti@redhat.com> In-Reply-To: <20250602111504.387917-1-kshcheti@redhat.com> References: <20250602111504.387917-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Js8S7jKhCDMfcFui8p7C8zalrTmtOCzPo2vzioZyG7c_1748862928 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VWBK6MNQ2X2YJ6T3N354A2YOARM5RUMR X-Message-ID-Hash: VWBK6MNQ2X2YJ6T3N354A2YOARM5RUMR 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: 1748863041075116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Previously, the RDP graphics definition parsing were implemented by string parsing, the virDomainGraphicsDefParseXMLRDP function was refactored to use the appropriate virXMLProp* utility functions. Overall parsing logic was not changed and results the same output as before. Moreover, 'replaceUser' and 'mutliUser' params type was changed from bool to tristate type, to avoid unnecessary type convertions. The virDomainGraphicsDefFormatRDP fucntion was also refactored according to the type changes. Signed-off-by: Kirill Shchetiniuk --- src/conf/domain_conf.c | 51 +++++++++++++++++++++------------------- src/conf/domain_conf.h | 4 ++-- src/qemu/qemu_process.c | 4 ++-- src/qemu/qemu_validate.c | 4 ++-- src/vbox/vbox_common.c | 8 +++---- 5 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 32a358d72c..201a4ded8b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11917,40 +11917,41 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphics= Def *def, xmlXPathContextPtr ctxt, unsigned int flags) { - g_autofree char *port =3D virXMLPropString(node, "port"); - g_autofree char *autoport =3D virXMLPropString(node, "autoport"); - g_autofree char *replaceUser =3D virXMLPropString(node, "replaceUser"); - g_autofree char *multiUser =3D virXMLPropString(node, "multiUser"); + virTristateBool autoport; =20 if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) return -1; =20 - if (port) { - if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse rdp port %1$s"), port); - return -1; - } - /* Legacy compat syntax, used -1 for auto-port */ - if (def->data.rdp.port =3D=3D -1) - def->data.rdp.autoport =3D true; + if (virXMLPropInt(node, "port", 10, VIR_XML_PROP_NONE, + &def->data.rdp.port, 0) < 0) + return -1; =20 - } else { - def->data.rdp.port =3D 0; + if (def->data.rdp.port =3D=3D -1) { + /* Legacy compat syntax, used -1 for auto-port */ def->data.rdp.autoport =3D true; } =20 - if (STREQ_NULLABLE(autoport, "yes")) + if (def->data.rdp.port =3D=3D 0) { + /* No port specified */ def->data.rdp.autoport =3D true; + } + + if (virXMLPropTristateBool(node, "autoport", VIR_XML_PROP_NONE, + &autoport) < 0) + return -1; + + virTristateBoolToBool(autoport, &def->data.rdp.autoport); =20 if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) def->data.rdp.port =3D 0; =20 - if (STREQ_NULLABLE(replaceUser, "yes")) - def->data.rdp.replaceUser =3D true; + if (virXMLPropTristateBool(node, "replaceUser", VIR_XML_PROP_NONE, + &def->data.rdp.replaceUser)) + return -1; =20 - if (STREQ_NULLABLE(multiUser, "yes")) - def->data.rdp.multiUser =3D true; + if (virXMLPropTristateBool(node, "multiUser", VIR_XML_PROP_NONE, + &def->data.rdp.replaceUser)) + return -1; =20 if (virDomainGraphicsAuthDefParseXML(node, &def->data.rdp.auth, def->type) < 0) @@ -26977,11 +26978,13 @@ virDomainGraphicsDefFormatRDP(virBuffer *attrBuf, if (def->data.rdp.autoport) virBufferAddLit(attrBuf, " autoport=3D'yes'"); =20 - if (def->data.rdp.replaceUser) - virBufferAddLit(attrBuf, " replaceUser=3D'yes'"); + if (def->data.rdp.replaceUser !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(attrBuf, " replaceUser=3D'%s'", + virTristateBoolTypeToString(def->data.rdp.replac= eUser)); =20 - if (def->data.rdp.multiUser) - virBufferAddLit(attrBuf, " multiUser=3D'yes'"); + if (def->data.rdp.multiUser !=3D VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(attrBuf, " multiUser=3D'%s'", + virTristateBoolTypeToString(def->data.rdp.multiU= ser)); =20 virDomainGraphicsListenDefFormatAddr(attrBuf, glisten, flags); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8df404dc42..c909cfba3f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2043,8 +2043,8 @@ struct _virDomainGraphicsDef { int port; bool portReserved; bool autoport; - bool replaceUser; - bool multiUser; + virTristateBool replaceUser; + virTristateBool multiUser; virDomainGraphicsAuthDef auth; } rdp; struct { diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 54b84922d6..02cca5fb6b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5550,12 +5550,12 @@ qemuProcessStartValidateGraphics(virDomainObj *vm) _("qemu-rdp does not support multiple liste= ns for one graphics device.")); return -1; } - if (graphics->data.rdp.multiUser) { + if (graphics->data.rdp.multiUser =3D=3D VIR_TRISTATE_BOOL_YES)= { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("qemu-rdp doesn't support the 'multiUser'= attribute.")); return -1; } - if (graphics->data.rdp.replaceUser) { + if (graphics->data.rdp.replaceUser =3D=3D VIR_TRISTATE_BOOL_YE= S) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("qemu-rdp doesn't support the 'replaceUse= r' attribute.")); return -1; diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index e45f636418..968533ccf3 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -4512,12 +4512,12 @@ qemuValidateDomainDeviceDefDBusGraphics(const virDo= mainGraphicsDef *graphics, static int qemuValidateDomainDeviceDefRDPGraphics(const virDomainGraphicsDef *graphic= s) { - if (graphics->data.rdp.replaceUser) { + if (graphics->data.rdp.replaceUser =3D=3D VIR_TRISTATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("RDP doesn't support 'replaceUser'")); return -1; } - if (graphics->data.rdp.multiUser) { + if (graphics->data.rdp.multiUser =3D=3D VIR_TRISTATE_BOOL_YES) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("RDP doesn't support 'multiUser'")); return -1; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 349ac832dc..929d452abd 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1703,13 +1703,13 @@ vboxAttachDisplay(virDomainDef *def, struct _vboxDr= iver *data, IMachine *machine =20 gVBoxAPI.UIVRDEServer.SetPorts(data, VRDEServer, def->grap= hics[i]); =20 - if (def->graphics[i]->data.rdp.replaceUser) { + if (def->graphics[i]->data.rdp.replaceUser =3D=3D VIR_TRIS= TATE_BOOL_YES) { gVBoxAPI.UIVRDEServer.SetReuseSingleConnection(VRDESer= ver, PR_TRUE= ); VIR_DEBUG("VRDP set to reuse single connection"); } =20 - if (def->graphics[i]->data.rdp.multiUser) { + if (def->graphics[i]->data.rdp.multiUser =3D=3D VIR_TRISTA= TE_BOOL_YES) { gVBoxAPI.UIVRDEServer.SetAllowMultiConnection(VRDEServ= er, PR_TRUE); VIR_DEBUG("VRDP set to allow multiple connection"); @@ -3611,12 +3611,11 @@ vboxDumpDisplay(virDomainDef *def, struct _vboxDriv= er *data, IMachine *machine) =20 gVBoxAPI.UIVRDEServer.GetAllowMultiConnection(VRDEServer, &allowMu= ltiConnection); if (allowMultiConnection) - graphics->data.rdp.multiUser =3D true; + graphics->data.rdp.multiUser =3D VIR_TRISTATE_BOOL_YES; =20 gVBoxAPI.UIVRDEServer.GetReuseSingleConnection(VRDEServer, &reuseS= ingleConnection); if (reuseSingleConnection) - graphics->data.rdp.replaceUser =3D true; + graphics->data.rdp.replaceUser =3D VIR_TRISTATE_BOOL_YES; =20 VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, graphics); } -- 2.49.0