From nobody Thu Dec 18 14:13:48 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=1743773374; cv=none; d=zohomail.com; s=zohoarc; b=hjOKd7JdyjRT+f0fVOBGY6d+xXS6D4hWIhsSmR9eIIXuXB0x1qttVLY8Ov6awUtfQPKD52N3uumzWst59zao/Caxt+LYgc3JqtOhi8/ct2DF1EQj6+kD5tKEOady5Y87399huYGySPotMc2E2iCbs2Nce8YktoxSEIpg4lc7cSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773374; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=EbstR1+xa8CiMjH8PhNKFZcejp09cSe9pvllZmLPyhQ=; b=k39qHvN/UXBBBqIUYjy7rO7gp7WV1yxGnVbxtBJV+mJ74m5wSEVOhJGZydl1i8PiMWV3RcE0B9b5pI7gkq4YC6BF/7DdZ0XZcnpgxnb3C+/o9B2+b3otAIjKciDQYz2zLh7AtwW9TAhWY1IkvqYYjLgILVELeW5BvdtLFcAsvQI= 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 1743773374200544.1984781786241; Fri, 4 Apr 2025 06:29:34 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 38B301468; Fri, 4 Apr 2025 09:29:33 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1110114A9; Fri, 4 Apr 2025 09:28:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CAA4611B5; Fri, 4 Apr 2025 09:28:09 -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 3C174B90 for ; Fri, 4 Apr 2025 09:28:08 -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-575-4XDNejBSMTWXf1q0vezpDg-1; Fri, 04 Apr 2025 09:28:06 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 EA57A18001F7 for ; Fri, 4 Apr 2025 13:28:05 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.3.236]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3EC221955BC2 for ; Fri, 4 Apr 2025 13:28:05 +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=1743773287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yjc75x06pK5PD5p/ZA03/W4D8NSWaMaYDvXXAiTl1SI=; b=bvOTPTl0RS7tZXD3QOONO8vKxX9365XF6HcpcgiUnBiigmXu4mAOHG0cI3etoohCgA/7da ZBobLvpTZGOQd8ldcCoXotaEe0uaK8Lp9e8vn8LPSvQViUPN2ZZaBZkmKDrxMA9XGZzWPV A3MBt+cigthbmOq4fxS5E+VmhkEviLk= X-MC-Unique: 4XDNejBSMTWXf1q0vezpDg-1 X-Mimecast-MFC-AGG-ID: 4XDNejBSMTWXf1q0vezpDg_1743773286 To: devel@lists.libvirt.org Subject: [PATCH 2/8] doRemoteOpen: Move RPC talk to a separate function Date: Fri, 4 Apr 2025 15:27:54 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: hBoHlyopev2S_mYQFm_3lbEFbwmxzbQJSV29DqHHnU4_1743773286 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GRIATNSOAPEQ2LD6Q7IDPZEL7FGEMCI6 X-Message-ID-Hash: GRIATNSOAPEQ2LD6Q7IDPZEL7FGEMCI6 X-MailFrom: mprivozn@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 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: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1743773374866019100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik When opening a connection, the client does some RPC talk (most notably REMOTE_PROC_CONNECT_OPEN, and in some cases REMOTE_PROC_CONNECT_GET_URI even). Now, calling RPC means that local variables must be created. Having them in doRemoteOpen() increases its stack size which goes against our effort in bringing the size down (see one of previous commits). Move that part of the code into a separate function. This brings the stack size of doRemoteOpen() even further: from 1320 bytes to 1272. Signed-off-by: Michal Privoznik --- src/remote/remote_driver.c | 65 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 681594e406..3ecef7d73f 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -742,6 +742,42 @@ remoteConnectFormatURI(virURI *uri, } =20 =20 +static int +remoteCallOpen(virConnectPtr conn, + struct private_data *priv, + const char *name, + unsigned int flags) +{ + remote_connect_open_args args =3D { (char**) &name, flags }; + + VIR_DEBUG("Trying to open URI '%s'", name); + if (call(conn, priv, 0, REMOTE_PROC_CONNECT_OPEN, + (xdrproc_t) xdr_remote_connect_open_args, (char *) &args, + (xdrproc_t) xdr_void, (char *) NULL) =3D=3D -1) + return -1; + + /* Now try and find out what URI the daemon used */ + if (conn->uri =3D=3D NULL) { + remote_connect_get_uri_ret uriret =3D { 0 }; + + VIR_DEBUG("Trying to query remote URI"); + if (call(conn, priv, 0, + REMOTE_PROC_CONNECT_GET_URI, + (xdrproc_t) xdr_void, (char *) NULL, + (xdrproc_t) xdr_remote_connect_get_uri_ret, (char *) &uri= ret) < 0) + return -1; + + VIR_DEBUG("Auto-probed URI is %s", uriret.uri); + conn->uri =3D virURIParse(uriret.uri); + VIR_FREE(uriret.uri); + if (!conn->uri) + return -1; + } + + return 0; +} + + /* helper macro to ease extraction of arguments from the URI */ #define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR) \ if (STRCASEEQ(var->name, ARG_NAME)) { \ @@ -1241,33 +1277,8 @@ doRemoteOpen(virConnectPtr conn, } =20 /* Finally we can call the remote side's open function. */ - { - remote_connect_open_args args =3D { &name, flags }; - - VIR_DEBUG("Trying to open URI '%s'", name); - if (call(conn, priv, 0, REMOTE_PROC_CONNECT_OPEN, - (xdrproc_t) xdr_remote_connect_open_args, (char *) &args, - (xdrproc_t) xdr_void, (char *) NULL) =3D=3D -1) - goto error; - } - - /* Now try and find out what URI the daemon used */ - if (conn->uri =3D=3D NULL) { - remote_connect_get_uri_ret uriret =3D { 0 }; - - VIR_DEBUG("Trying to query remote URI"); - if (call(conn, priv, 0, - REMOTE_PROC_CONNECT_GET_URI, - (xdrproc_t) xdr_void, (char *) NULL, - (xdrproc_t) xdr_remote_connect_get_uri_ret, (char *) &uri= ret) < 0) - goto error; - - VIR_DEBUG("Auto-probed URI is %s", uriret.uri); - conn->uri =3D virURIParse(uriret.uri); - VIR_FREE(uriret.uri); - if (!conn->uri) - goto error; - } + if (remoteCallOpen(conn, priv, name, flags) < 0) + goto error; =20 /* Set up events */ if (!(priv->eventState =3D virObjectEventStateNew())) --=20 2.49.0