From nobody Thu Dec 18 04:14:28 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=1743773349; cv=none; d=zohomail.com; s=zohoarc; b=NRWBOOvAbqapn9gytTHJTLFeofEFgykbDc26f+Y9MB9CEH+v0VoDXsVkL2MjYlctJGKxyt+86pEIapyAvG6E2Td7lsM8zN1rHMk8PeP+DdvFhlzmmI1X9CUPky5mpQntWlumFqmzOAnj4ptTwWGP/3UhXzDcAgUIA8/c9zER/rU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773349; 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=TFBNgw0f24Um14UOmS/N4+Y3pXPg11Rr7HU1xQ2D4Lg=; b=BceJ9MHrNOmDluN/uehiSLYyxbmocbNKhF4mxRG0jz//lVkAvhwWO7PoA9HuneYRsiuc3FI7+54ExpU6KzrkDKx/d6yaiRrDQhfjJGdlzp/hc2m09TENkq8/bBTG5+Kve0nRbCHFJ9JT4ucTgU86Wt1yQy7KTe4xnvEeeb3KIhE= 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 1743773349204929.7987039923744; Fri, 4 Apr 2025 06:29:09 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 95BDC149D; Fri, 4 Apr 2025 09:29:08 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6391915D0; Fri, 4 Apr 2025 09:28:13 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 8EE1AB90; Fri, 4 Apr 2025 09:28:07 -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 EF25611AA for ; Fri, 4 Apr 2025 09:28:06 -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-42-jY8qzxdKNIea01OecOPBNA-1; Fri, 04 Apr 2025 09:28:05 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C9E321955DAF for ; Fri, 4 Apr 2025 13:28:04 +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 207551955BC2 for ; Fri, 4 Apr 2025 13:28:03 +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=1743773286; 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=HEQU+q2cmGRu5P15ODcWNSuK52KDShmAqO2VLsbwhXc=; b=N1+MQdWTqgFQmCdCWkHj7D+NMxp+XobdC7DlgTwrMyioBebV6mG+xmztMdXHvMbBy9kUk1 K5sVjkdwqLRstUm7JncX9rsNbblUBCB6RrKHtwDFnB+bdDey9vA7waleUnVslnSbTqzY7x 5ELLH1GgXdaGhEYpfWXUiMwf6G9plzY= X-MC-Unique: jY8qzxdKNIea01OecOPBNA-1 X-Mimecast-MFC-AGG-ID: jY8qzxdKNIea01OecOPBNA_1743773284 To: devel@lists.libvirt.org Subject: [PATCH 1/8] remote_driver: Move URI arg extraction into a separate function Date: Fri, 4 Apr 2025 15:27:53 +0200 Message-ID: <90f3dc9234023976914ecefe8571bd83e59b3874.1743772965.git.mprivozn@redhat.com> 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: N1kQEBk6x6_jSNXzlwJbiZH_z7vrJV8CDxpLvl-J6nI_1743773284 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LA5CV7IHCODZL6LJ5DJLGLGJINAASI67 X-Message-ID-Hash: LA5CV7IHCODZL6LJ5DJLGLGJINAASI67 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: 1743773349987019000 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik There's a problem with glib: what we might consider functions are in fact macros and to make things worse - they do declare local variables. For instance here's the declaration of g_clear_pointer() macro: #define g_clear_pointer(pp, destroy) \ G_STMT_START \ { \ G_STATIC_ASSERT (sizeof *(pp) =3D=3D sizeof (gpointer)); \ glib_typeof ((pp)) _pp =3D (pp); \ glib_typeof (*(pp)) _ptr =3D *_pp; \ *_pp =3D NULL; \ if (_ptr) \ (destroy) (_ptr); \ } \ G_STMT_END \ Now, as of v6.2.0-rc1~267 our VIR_FREE() macro is in fact a redeclaration of g_clear_pointer(). Thus, calling VIR_FREE() increases stack size! Ideally, this wouldn't be a problem, because those variables (_pp, _ptr) live in their own block. And clever compiler can just reuse space created for one block. But then there's clang where we are hitting this exact problem in functions like doRemoteOpen() where either g_clear_pointer() is called directly, or there are macros like EXTRACT_URI_ARG_STR() which hide the call away. That's why despite our previous efforts decreasing stack size we still needed v9.8.0-rc1~208. Well, moving URI argument extraction (those calls to EXTRACT_URI_ARG_* macros) into a separate function helps us decrease stack size from 2296 bytes to 1320. Even after this there are still more possibilities for improvements, but those will be addressed in future commits. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 113 +++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 31 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 745cd34f83..681594e406 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -758,13 +758,74 @@ remoteConnectFormatURI(virURI *uri, virReportError(VIR_ERR_INVALID_ARG, \ _("Failed to parse value of URI component %1$s"= ), \ var->name); \ - goto error; \ + return -1; \ } \ ARG_VAR =3D tmp =3D=3D 0; \ var->ignore =3D 1; \ continue; \ } =20 +static int +doRemoteOpenExtractURIArgs(virConnectPtr conn, + char **name, + char **command, + char **sockname, + char **authtype, + char **sshauth, + char **netcat, + char **keyfile, + char **pkipath, + char **knownHosts, + char **knownHostsVerify, + char **tls_priority, + char **mode_str, + char **proxy_str, +#ifndef WIN32 + bool *tty, +#endif + bool *sanity, + bool *verify) +{ + size_t i; + + for (i =3D 0; i < conn->uri->paramsCount; i++) { + virURIParam *var =3D &conn->uri->params[i]; + + EXTRACT_URI_ARG_STR("name", *name); + EXTRACT_URI_ARG_STR("command", *command); + EXTRACT_URI_ARG_STR("socket", *sockname); + EXTRACT_URI_ARG_STR("auth", *authtype); + EXTRACT_URI_ARG_STR("sshauth", *sshauth); + EXTRACT_URI_ARG_STR("netcat", *netcat); + EXTRACT_URI_ARG_STR("keyfile", *keyfile); + EXTRACT_URI_ARG_STR("pkipath", *pkipath); + EXTRACT_URI_ARG_STR("known_hosts", *knownHosts); + EXTRACT_URI_ARG_STR("known_hosts_verify", *knownHostsVerify); + EXTRACT_URI_ARG_STR("tls_priority", *tls_priority); + EXTRACT_URI_ARG_STR("mode", *mode_str); + EXTRACT_URI_ARG_STR("proxy", *proxy_str); + EXTRACT_URI_ARG_BOOL("no_sanity", *sanity); + EXTRACT_URI_ARG_BOOL("no_verify", *verify); +#ifndef WIN32 + EXTRACT_URI_ARG_BOOL("no_tty", *tty); +#endif + + if (STRCASEEQ(var->name, "authfile")) { + /* Strip this param, used by virauth.c */ + var->ignore =3D 1; + continue; + } + + VIR_DEBUG("passing through variable '%s' ('%s') to remote end", + var->name, var->value); + } + + return 0; +} + +#undef EXTRACT_URI_ARG_STR +#undef EXTRACT_URI_ARG_BOOL + =20 /* * URIs that this driver needs to handle: @@ -818,7 +879,6 @@ doRemoteOpen(virConnectPtr conn, bool tty =3D true; #endif int mode; - size_t i; int proxy; =20 /* We handle *ALL* URIs here. The caller has rejected any @@ -844,35 +904,28 @@ doRemoteOpen(virConnectPtr conn, * although that won't be the case for now). */ if (conn->uri) { - for (i =3D 0; i < conn->uri->paramsCount; i++) { - virURIParam *var =3D &conn->uri->params[i]; - EXTRACT_URI_ARG_STR("name", name); - EXTRACT_URI_ARG_STR("command", command); - EXTRACT_URI_ARG_STR("socket", sockname); - EXTRACT_URI_ARG_STR("auth", authtype); - EXTRACT_URI_ARG_STR("sshauth", sshauth); - EXTRACT_URI_ARG_STR("netcat", netcat); - EXTRACT_URI_ARG_STR("keyfile", keyfile); - EXTRACT_URI_ARG_STR("pkipath", pkipath); - EXTRACT_URI_ARG_STR("known_hosts", knownHosts); - EXTRACT_URI_ARG_STR("known_hosts_verify", knownHostsVerify); - EXTRACT_URI_ARG_STR("tls_priority", tls_priority); - EXTRACT_URI_ARG_STR("mode", mode_str); - EXTRACT_URI_ARG_STR("proxy", proxy_str); - EXTRACT_URI_ARG_BOOL("no_sanity", sanity); - EXTRACT_URI_ARG_BOOL("no_verify", verify); + /* This really needs to be a separate function to keep + * the stack size at sane levels. */ + if (doRemoteOpenExtractURIArgs(conn, + &name, + &command, + &sockname, + &authtype, + &sshauth, + &netcat, + &keyfile, + &pkipath, + &knownHosts, + &knownHostsVerify, + &tls_priority, + &mode_str, + &proxy_str, #ifndef WIN32 - EXTRACT_URI_ARG_BOOL("no_tty", tty); + &tty, #endif - - if (STRCASEEQ(var->name, "authfile")) { - /* Strip this param, used by virauth.c */ - var->ignore =3D 1; - continue; - } - - VIR_DEBUG("passing through variable '%s' ('%s') to remote end", - var->name, var->value); + &sanity, + &verify) < 0) { + goto error; } =20 /* Construct the original name. */ @@ -1248,8 +1301,6 @@ doRemoteOpen(virConnectPtr conn, VIR_FREE(priv->hostname); return VIR_DRV_OPEN_ERROR; } -#undef EXTRACT_URI_ARG_STR -#undef EXTRACT_URI_ARG_BOOL =20 static struct private_data * remoteAllocPrivateData(void) --=20 2.49.0 From nobody Thu Dec 18 04:14:28 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 Reviewed-by: J=C3=A1n Tomko --- 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 From nobody Thu Dec 18 04:14:28 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=1743773392; cv=none; d=zohomail.com; s=zohoarc; b=mPZqDD7aBvvRnG+Rj6zLa/pNhQhLYMzUbXm32Kw4kAk0ohHPTx6GtKemGbnOlfwF0e3s5+RNBhg3FTLkCRSmab/mQ8mB8WBc/ysy4PzlMtA0skhlHTFMFnBqXuulfq+9REQBbehIQThBNqcUIulebnB4sYOlt2KAtV8Ttr9+6k4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773392; 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=aP2HjJgnuQ2I0m3t55/g8g0uctS6fDluirnJRZ+gJgY=; b=m8thSrZdul651eCQiUJF9QfHwx54LOxq6QvkHHtWU0nJiAFSq2oESUD3dgJZl4H253opmWsa2J1//RWuyWW/erjjWB1P1eeze264FmuLHnNWAldy7M4nAHKKaP7aPs7Gx/FaudQ4+zZ5vs/iSObA6MtQXhqJOE+rCmV545GqVYk= 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 1743773392939521.591873064804; Fri, 4 Apr 2025 06:29:52 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5D37F1510; Fri, 4 Apr 2025 09:29:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B89C214E0; Fri, 4 Apr 2025 09:28:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 482A511AA; Fri, 4 Apr 2025 09:28:10 -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 E1E80B90 for ; Fri, 4 Apr 2025 09:28:09 -0400 (EDT) Received: from mx-prod-mc-05.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-601-eF3jNFhEPLq6GkPKA6FJPQ-1; Fri, 04 Apr 2025 09:28:07 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1DFED1956089 for ; Fri, 4 Apr 2025 13:28:07 +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 5D99B1955BC2 for ; Fri, 4 Apr 2025 13:28:06 +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=1743773289; 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=dnab5u4uQNM2hco0Cohvb907j3JiufjDiXpCUlL7iD4=; b=Id9/fZP2KHXcafJLMdvd+yOmwby+FUHoZRYsTetwkGfjiPiG3NUvLtZMCT9J3anMpFsawU FFQ6X1pM0vS6H/bN26aUmFdWnNEFZky9YcPBu8Z+xvgFJu6NUTPEwDagqGLr0fnWuH8q5D H4XV6n2OPMmfR39UHTHanRJc7PKniS8= X-MC-Unique: eF3jNFhEPLq6GkPKA6FJPQ-1 X-Mimecast-MFC-AGG-ID: eF3jNFhEPLq6GkPKA6FJPQ_1743773287 To: devel@lists.libvirt.org Subject: [PATCH 3/8] doRemoteOpen: Drop needless typecast of @transport Date: Fri, 4 Apr 2025 15:27:55 +0200 Message-ID: <365175577fda810d9efafd4a2cb076cee17b5ae4.1743772965.git.mprivozn@redhat.com> 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: LOIqkcxGKk8VAn0QlQACqrAo1fp6qNQFVZlb780445Y_1743773287 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JBUNVM5TOFPUPMUZ7NYO7OWOQ23SY44I X-Message-ID-Hash: JBUNVM5TOFPUPMUZ7NYO7OWOQ23SY44I 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: 1743773394168019000 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The @transport variable is already pass into the function with proper type. There's no need to typecast it to its very same type inside the function. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/remote/remote_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 3ecef7d73f..2690c05267 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1063,7 +1063,7 @@ doRemoteOpen(virConnectPtr conn, =20 VIR_DEBUG("Connecting with transport %d", transport); =20 - switch ((remoteDriverTransport)transport) { + switch (transport) { case REMOTE_DRIVER_TRANSPORT_UNIX: case REMOTE_DRIVER_TRANSPORT_SSH: case REMOTE_DRIVER_TRANSPORT_LIBSSH: @@ -1088,7 +1088,7 @@ doRemoteOpen(virConnectPtr conn, VIR_DEBUG("Chosen UNIX socket %s", NULLSTR(sockname)); =20 /* Connect to the remote service. */ - switch ((remoteDriverTransport)transport) { + switch (transport) { case REMOTE_DRIVER_TRANSPORT_TLS: if (conf && !tls_priority && virConfGetValueString(conf, "tls_priority", &tls_priority) < 0) --=20 2.49.0 From nobody Thu Dec 18 04:14:28 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=1743773426; cv=none; d=zohomail.com; s=zohoarc; b=b1P+oOp9fxVabIPlYkMLnxVlkI0FSu2xwH3LOXCvMc14izXRG7UYvN6GTDsTrfdY6E3/4C4L9P1t/MS3utFBNYVtjV6ibaETnAnei3oJJx2higD9bqCcNTO+EO/CDPZsEenGzk//idm4b3b4O78ptBJQ8bHeuprNkPDuDD+2Pqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773426; 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=aB9pRe95ZPm/ijY4byVfDE+VGG45tmX20PbF4UtmnGc=; b=m2PfTBV0jOZs1fRhiQd/w/jEBO9UAXlsKarlVIHad1pFgy86X80xIw/diAcpn8CwL9uQ+ZJadoaSM7nFyxdOSdmhsA2+smLSaKT406BfDGJ6gv20M/nhWCGRRnmI580iojh60RYKwvT2QAY+5jcABo+iRhTE5hGa84NhMjZFpxE= 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 1743773426868631.2617709380285; Fri, 4 Apr 2025 06:30:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 31D1D165B; Fri, 4 Apr 2025 09:30:26 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4A54F15ED; Fri, 4 Apr 2025 09:28:19 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6E1F214E0; Fri, 4 Apr 2025 09:28:11 -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 8F46911AA for ; Fri, 4 Apr 2025 09:28:10 -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-138-4_vGefk_OayOdiKJH6Mw8Q-1; Fri, 04 Apr 2025 09:28:09 -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 3DC3D18001DE for ; Fri, 4 Apr 2025 13:28:08 +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 86FFE1955BC2 for ; Fri, 4 Apr 2025 13:28:07 +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=1743773290; 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=8nny36b9rSjYJCjVV/TDWYLF7hHboJEoRHNnNmM5QHo=; b=VYXnmdLOP/9j5Kok9b4BRaJAnRqvhlP1KuhSYb44gXZDsR9dfJaNZ9ypgMcnYV43afr0JW IGGoxplMmZfQHU5cfMi+/dFZ9RvhUVy5E4HYZ+V0Eao21iV67qn/m7Hav+7EuRtiTN9clj dStot8jFkjx/eF0qlfaO4jxy75bXqac= X-MC-Unique: 4_vGefk_OayOdiKJH6Mw8Q-1 X-Mimecast-MFC-AGG-ID: 4_vGefk_OayOdiKJH6Mw8Q_1743773288 To: devel@lists.libvirt.org Subject: [PATCH 4/8] vbox: Move parts of vboxSnapshotRedefine() into a separate function Date: Fri, 4 Apr 2025 15:27:56 +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: AMs7E2oiJu441l-lX9lVzyFWIWRMTyspqc7VwQUAz8g_1743773288 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PRKDOEL7SB7LQPL5XT7U5GYK6PQLUQ7U X-Message-ID-Hash: PRKDOEL7SB7LQPL5XT7U5GYK6PQLUQ7U 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: 1743773428630019000 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik There's too much happening inside of vboxSnapshotRedefine(). Not only it makes the function hard to read, but it also increases stack size of the function. Move one part into a separate function: vboxSnapshotReplaceRWDisks() Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 216 ++++++++++++++++++++++------------------- 1 file changed, 118 insertions(+), 98 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 7d157e065e..b52e0c3e6a 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4553,6 +4553,122 @@ static int vboxCloseDisksRecursively(virDomainPtr d= om, char *location) return ret; } =20 + +static int +vboxSnapshotReplaceRWDisks(struct _vboxDriver *data, + virVBoxSnapshotConfMachine *snapshotMachineDesc, + char *currentSnapshotXmlFilePath) +{ + g_auto(GStrv) realReadWriteDisksPath =3D NULL; + g_auto(GStrv) realReadOnlyDisksPath =3D NULL; + int realReadWriteDisksPathSize =3D 0; + int realReadOnlyDisksPathSize =3D 0; + int it =3D 0; + + /* + * We have created fake disks, so we have to remove them and replace t= hem with + * the read-write disks if there are any. The fake disks will be close= d during + * the machine unregistration. + */ + if (virVBoxSnapshotConfRemoveFakeDisks(snapshotMachineDesc) < 0) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to remove Fake Disks")); + return -1; + } + + realReadWriteDisksPathSize =3D virVBoxSnapshotConfGetRWDisksPathsFromL= ibvirtXML(currentSnapshotXmlFilePath, + = &realReadWriteDisksPath); + realReadOnlyDisksPathSize =3D virVBoxSnapshotConfGetRODisksPathsFromLi= bvirtXML(currentSnapshotXmlFilePath, + = &realReadOnlyDisksPath); + /* The read-only disk number is necessarily greater or equal to the + * read-write disk number */ + if (realReadOnlyDisksPathSize < realReadWriteDisksPathSize) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("The read only disk number must be greater or eq= ual to the read write disk number")); + return -1; + } + + for (it =3D 0; it < realReadWriteDisksPathSize; it++) { + virVBoxSnapshotConfHardDisk *readWriteDisk =3D NULL; + PRUnichar *locationUtf =3D NULL; + IMedium *readWriteMedium =3D NULL; + char *uuid =3D NULL; + PRUnichar *formatUtf =3D NULL; + char *format =3D NULL; + const char *parentUuid =3D NULL; + vboxIID iid; + nsresult rc; + + VBOX_IID_INITIALIZE(&iid); + VBOX_UTF8_TO_UTF16(realReadWriteDisksPath[it], &locationUtf); + rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, + locationUtf, + DeviceType_HardDisk, + AccessMode_ReadWrite, + &readWriteMedium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); + VBOX_UTF16_FREE(locationUtf); + return -1; + } + VBOX_UTF16_FREE(locationUtf); + + rc =3D gVBoxAPI.UIMedium.GetId(readWriteMedium, &iid); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the read write medium id")); + return -1; + } + gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); + vboxIIDUnalloc(&iid); + + rc =3D gVBoxAPI.UIMedium.GetFormat(readWriteMedium, &formatUtf); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the read write medium format"= )); + return -1; + } + VBOX_UTF16_TO_UTF8(formatUtf, &format); + VBOX_UTF16_FREE(formatUtf); + + readWriteDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); + + readWriteDisk->format =3D format; + readWriteDisk->uuid =3D uuid; + readWriteDisk->location =3D realReadWriteDisksPath[it]; + /* + * We get the current snapshot's read-only disk uuid in order to a= dd the + * read-write disk to the media registry as its child. The read-on= ly disk + * is already in the media registry because it is the fake disk's = parent. + */ + parentUuid =3D virVBoxSnapshotConfHardDiskUuidByLocation(snapshotM= achineDesc, + realReadOnl= yDisksPath[it]); + if (parentUuid =3D=3D NULL) { + VIR_FREE(readWriteDisk); + return -1; + } + + if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readWriteDisk, + snapshotMachineD= esc->mediaRegistry, + parentUuid) < 0)= { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to media Registry")= ); + VIR_FREE(readWriteDisk); + return -1; + } + rc =3D gVBoxAPI.UIMedium.Close(readWriteMedium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); + return -1; + } + } + + return 0; +} + + static int vboxSnapshotRedefine(virDomainPtr dom, virDomainSnapshotDef *def, @@ -4596,10 +4712,6 @@ vboxSnapshotRedefine(virDomainPtr dom, char *currentSnapshotXmlFilePath =3D NULL; PRUnichar *machineNameUtf16 =3D NULL; char *machineName =3D NULL; - g_auto(GStrv) realReadWriteDisksPath =3D NULL; - int realReadWriteDisksPathSize =3D 0; - g_auto(GStrv) realReadOnlyDisksPath =3D NULL; - int realReadOnlyDisksPathSize =3D 0; virVBoxSnapshotConfSnapshot *newSnapshotPtr =3D NULL; unsigned char snapshotUuid[VIR_UUID_BUFLEN]; virVBoxSnapshotConfHardDisk **hardDiskToOpen =3D NULL; @@ -4668,102 +4780,10 @@ vboxSnapshotRedefine(virDomainPtr dom, } =20 if (snapshotFileExists) { - /* - * We have created fake disks, so we have to remove them and repla= ce them with - * the read-write disks if there are any. The fake disks will be c= losed during - * the machine unregistration. - */ - if (virVBoxSnapshotConfRemoveFakeDisks(snapshotMachineDesc) < 0) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to remove Fake Disks")); + if (vboxSnapshotReplaceRWDisks(data, snapshotMachineDesc, + currentSnapshotXmlFilePath) < 0) goto cleanup; - } - realReadWriteDisksPathSize =3D virVBoxSnapshotConfGetRWDisksPathsF= romLibvirtXML(currentSnapshotXmlFilePath, - &realReadWrit= eDisksPath); - realReadOnlyDisksPathSize =3D virVBoxSnapshotConfGetRODisksPathsFr= omLibvirtXML(currentSnapshotXmlFilePath, - &= realReadOnlyDisksPath); - /* The read-only disk number is necessarily greater or equal to the - * read-write disk number */ - if (realReadOnlyDisksPathSize < realReadWriteDisksPathSize) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("The read only disk number must be greater o= r equal to the read write disk number")); - goto cleanup; - } - for (it =3D 0; it < realReadWriteDisksPathSize; it++) { - virVBoxSnapshotConfHardDisk *readWriteDisk =3D NULL; - PRUnichar *locationUtf =3D NULL; - IMedium *readWriteMedium =3D NULL; - char *uuid =3D NULL; - PRUnichar *formatUtf =3D NULL; - char *format =3D NULL; - const char *parentUuid =3D NULL; - vboxIID iid; - - VBOX_IID_INITIALIZE(&iid); - VBOX_UTF8_TO_UTF16(realReadWriteDisksPath[it], &locationUtf); - rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, - locationUtf, - DeviceType_HardDisk, - AccessMode_ReadWrite, - &readWriteMedium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to open HardDisk")); - VBOX_UTF16_FREE(locationUtf); - goto cleanup; - } - VBOX_UTF16_FREE(locationUtf); - - rc =3D gVBoxAPI.UIMedium.GetId(readWriteMedium, &iid); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the read write medium id"= )); - goto cleanup; - } - gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); - vboxIIDUnalloc(&iid); - - rc =3D gVBoxAPI.UIMedium.GetFormat(readWriteMedium, &formatUtf= ); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the read write medium for= mat")); - goto cleanup; - } - VBOX_UTF16_TO_UTF8(formatUtf, &format); - VBOX_UTF16_FREE(formatUtf); - - readWriteDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); - - readWriteDisk->format =3D format; - readWriteDisk->uuid =3D uuid; - readWriteDisk->location =3D realReadWriteDisksPath[it]; - /* - * We get the current snapshot's read-only disk uuid in order = to add the - * read-write disk to the media registry as its child. The rea= d-only disk - * is already in the media registry because it is the fake dis= k's parent. - */ - parentUuid =3D virVBoxSnapshotConfHardDiskUuidByLocation(snaps= hotMachineDesc, - realRea= dOnlyDisksPath[it]); - if (parentUuid =3D=3D NULL) { - VIR_FREE(readWriteDisk); - goto cleanup; - } =20 - if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readWriteDis= k, - snapshotMachineDesc->mediaRegis= try, - parentUuid) < 0) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to media Regist= ry")); - VIR_FREE(readWriteDisk); - goto cleanup; - } - rc =3D gVBoxAPI.UIMedium.Close(readWriteMedium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to close HardDisk")); - goto cleanup; - } - } /* * Now we have done this swap, we remove the snapshot xml file fro= m the * current machine location. --=20 2.49.0 From nobody Thu Dec 18 04:14:28 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=1743773464; cv=none; d=zohomail.com; s=zohoarc; b=NCzO3QgeXy+69QjvHoNu+SYxTc4vqSi6YmLvRODF6rw9fLh4n5gwD0Mh932fvXmYmGCk7ilwux/ND9jX0qReaOt4KgkJTE5wLIpwQgze6iTsZuXucAW94g/f6wKiwmr5NVwU27IcOeX/gI44BYEyipRmofSOpsT229mp/1EShjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773464; 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=pPP2wsFvq8wuKVu5ukeD0hAGzURKkotbv32rfDARdeM=; b=aXrPbjSZLPERdH1UaZE/7uwl4KBZD2U1EkKEYKpHFg2LffVEkyd7aA/+jozl6RzBTqkq0Ic/rjKfyDlUjewFcz/n0loqj7KwRNm6HY4OJh61QBuxAZijMjkFcbs0vBqF2Kxq2xs3U+/H9uGuygA+tY0eziB7D6Lpg1LSgVKPcDU= 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 1743773464915821.0196295350956; Fri, 4 Apr 2025 06:31:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D5C0015ED; Fri, 4 Apr 2025 09:31:03 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2C1B8162A; Fri, 4 Apr 2025 09:28:23 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E3A9B11D5; Fri, 4 Apr 2025 09:28:18 -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 A9B7811D5 for ; Fri, 4 Apr 2025 09:28:11 -0400 (EDT) Received: from mx-prod-mc-01.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-631-2fNyHiNFM7aYzEoiivWQWw-1; Fri, 04 Apr 2025 09:28:10 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C0A019560B7 for ; Fri, 4 Apr 2025 13:28:09 +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 A5A451955BC7 for ; Fri, 4 Apr 2025 13:28:08 +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=1743773291; 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=4gg+q4MgZP3RDM4/FaTmkVK/wez3yqiIueejwgr2J+w=; b=TxsOrnfILBD1/pBCyTExiVFvjRBuO/SE9XTiYrF9qvph+He+E8OxNSCsi6yED/hZzMUjK0 ev/Jo37CQW6Bv1GbWV31IbgkPvQo1VpLguHEidpnIUErVzOI5QTfoJUrElJkJ+J8t8qnjN 2ASS45uU9kGHMEeLJPmCQOIcpUNx/rc= X-MC-Unique: 2fNyHiNFM7aYzEoiivWQWw-1 X-Mimecast-MFC-AGG-ID: 2fNyHiNFM7aYzEoiivWQWw_1743773289 To: devel@lists.libvirt.org Subject: [PATCH 5/8] vbox: Move parts of vboxSnapshotRedefine() into a separate function Date: Fri, 4 Apr 2025 15:27:57 +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: TU9zzW3FHgxRGsOi4meoXrtluCHB8l1TntDUXvqyiuw_1743773289 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4SWDLDNIL6366H3WT7MIH2J6LZ7A5CHU X-Message-ID-Hash: 4SWDLDNIL6366H3WT7MIH2J6LZ7A5CHU 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: 1743773467234019100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik There's too much happening inside of vboxSnapshotRedefine(). Not only it makes the function hard to read, but it also increases stack size of the function. Move one part into a separate function: vboxSnapshotAddDisksToMediaRegistry() Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 215 ++++++++++++++++++++++------------------- 1 file changed, 115 insertions(+), 100 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index b52e0c3e6a..e5490304d8 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4669,6 +4669,119 @@ vboxSnapshotReplaceRWDisks(struct _vboxDriver *data, } =20 =20 +static int +vboxSnapshotAddDisksToMediaRegistry(struct _vboxDriver *data, + virDomainSnapshotDef *def, + virVBoxSnapshotConfMachine *snapshotMa= chineDesc) +{ + int it =3D 0; + + for (it =3D 0; it < def->parent.dom->ndisks; it++) { + int diskInMediaRegistry =3D 0; + IMedium *readOnlyMedium =3D NULL; + PRUnichar *locationUtf =3D NULL; + char *uuid =3D NULL; + PRUnichar *formatUtf =3D NULL; + char *format =3D NULL; + char *parentUuid =3D NULL; + virVBoxSnapshotConfHardDisk *readOnlyDisk =3D NULL; + vboxIID iid, parentiid; + IMedium *parentReadOnlyMedium =3D NULL; + nsresult rc; + + VBOX_IID_INITIALIZE(&iid); + VBOX_IID_INITIALIZE(&parentiid); + diskInMediaRegistry =3D virVBoxSnapshotConfDiskIsInMediaRegistry(s= napshotMachineDesc, + def= ->parent.dom->disks[it]->src->path); + if (diskInMediaRegistry =3D=3D -1) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to know if disk is in media registry= ")); + return -1; + } + if (diskInMediaRegistry =3D=3D 1) /* Nothing to do. */ + continue; + /* The read only disk is not in the media registry */ + + VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locatio= nUtf); + rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, + locationUtf, + DeviceType_HardDisk, + AccessMode_ReadWrite, + &readOnlyMedium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); + VBOX_UTF16_FREE(locationUtf); + return -1; + } + VBOX_UTF16_FREE(locationUtf); + + rc =3D gVBoxAPI.UIMedium.GetId(readOnlyMedium, &iid); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk id")); + return -1; + } + gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); + vboxIIDUnalloc(&iid); + + rc =3D gVBoxAPI.UIMedium.GetFormat(readOnlyMedium, &formatUtf); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk format")); + VIR_FREE(uuid); + return -1; + } + VBOX_UTF16_TO_UTF8(formatUtf, &format); + VBOX_UTF16_FREE(formatUtf); + + /* This disk is already in the media registry */ + rc =3D gVBoxAPI.UIMedium.GetParent(readOnlyMedium, &parentReadOnly= Medium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get parent hard disk")); + VIR_FREE(uuid); + return -1; + } + + rc =3D gVBoxAPI.UIMedium.GetId(parentReadOnlyMedium, &parentiid); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk id")); + VIR_FREE(uuid); + return -1; + } + gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); + vboxIIDUnalloc(&parentiid); + + rc =3D gVBoxAPI.UIMedium.Close(readOnlyMedium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); + VIR_FREE(uuid); + VIR_FREE(parentUuid); + return -1; + } + + readOnlyDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); + + readOnlyDisk->format =3D format; + readOnlyDisk->uuid =3D uuid; + readOnlyDisk->location =3D g_strdup(def->parent.dom->disks[it]->sr= c->path); + + if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readOnlyDisk, sn= apshotMachineDesc->mediaRegistry, + parentUuid) < 0)= { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to media registry")= ); + VIR_FREE(readOnlyDisk); + return -1; + } + } + + return 0; +} + + static int vboxSnapshotRedefine(virDomainPtr dom, virDomainSnapshotDef *def, @@ -4799,106 +4912,8 @@ vboxSnapshotRedefine(virDomainPtr dom, * read-only disks are in the redefined snapshot's media registry (the= disks need to * be open to query their uuid). */ - for (it =3D 0; it < def->parent.dom->ndisks; it++) { - int diskInMediaRegistry =3D 0; - IMedium *readOnlyMedium =3D NULL; - PRUnichar *locationUtf =3D NULL; - char *uuid =3D NULL; - PRUnichar *formatUtf =3D NULL; - char *format =3D NULL; - char *parentUuid =3D NULL; - virVBoxSnapshotConfHardDisk *readOnlyDisk =3D NULL; - vboxIID iid, parentiid; - IMedium *parentReadOnlyMedium =3D NULL; - - VBOX_IID_INITIALIZE(&iid); - VBOX_IID_INITIALIZE(&parentiid); - diskInMediaRegistry =3D virVBoxSnapshotConfDiskIsInMediaRegistry(s= napshotMachineDesc, - def->parent.dom->d= isks[it]->src->path); - if (diskInMediaRegistry =3D=3D -1) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to know if disk is in media registry= ")); - goto cleanup; - } - if (diskInMediaRegistry =3D=3D 1) /* Nothing to do. */ - continue; - /* The read only disk is not in the media registry */ - - VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locatio= nUtf); - rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, - locationUtf, - DeviceType_HardDisk, - AccessMode_ReadWrite, - &readOnlyMedium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to open HardDisk")); - VBOX_UTF16_FREE(locationUtf); - goto cleanup; - } - VBOX_UTF16_FREE(locationUtf); - - rc =3D gVBoxAPI.UIMedium.GetId(readOnlyMedium, &iid); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get hard disk id")); - goto cleanup; - } - gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); - vboxIIDUnalloc(&iid); - - rc =3D gVBoxAPI.UIMedium.GetFormat(readOnlyMedium, &formatUtf); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get hard disk format")); - VIR_FREE(uuid); - goto cleanup; - } - VBOX_UTF16_TO_UTF8(formatUtf, &format); - VBOX_UTF16_FREE(formatUtf); - - /* This disk is already in the media registry */ - rc =3D gVBoxAPI.UIMedium.GetParent(readOnlyMedium, &parentReadOnly= Medium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get parent hard disk")); - VIR_FREE(uuid); - goto cleanup; - } - - rc =3D gVBoxAPI.UIMedium.GetId(parentReadOnlyMedium, &parentiid); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get hard disk id")); - VIR_FREE(uuid); - goto cleanup; - } - gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); - vboxIIDUnalloc(&parentiid); - - rc =3D gVBoxAPI.UIMedium.Close(readOnlyMedium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to close HardDisk")); - VIR_FREE(uuid); - VIR_FREE(parentUuid); - goto cleanup; - } - - readOnlyDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); - - readOnlyDisk->format =3D format; - readOnlyDisk->uuid =3D uuid; - readOnlyDisk->location =3D g_strdup(def->parent.dom->disks[it]->sr= c->path); - - if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readOnlyDisk, sn= apshotMachineDesc->mediaRegistry, - parentUuid) < 0)= { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to media registry")= ); - VIR_FREE(readOnlyDisk); - goto cleanup; - } - } + if (vboxSnapshotAddDisksToMediaRegistry(data, def, snapshotMachineDesc= ) < 0) + goto cleanup; =20 /* Now, we can unregister the machine */ rc =3D gVBoxAPI.UIMachine.Unregister(machine, --=20 2.49.0 From nobody Thu Dec 18 04:14:28 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=1743773494; cv=none; d=zohomail.com; s=zohoarc; b=N590VEOpIgY1zoS5lEfAyQhuvKwTDoAxqP8e9JqcntvEO0zL7V0tXksN9lh4jv/CFeE1IhsXhZ+Df41ck2RjpWlXf7f9Ps0C2b1WJifGglGSWVb+sIYe8kcQqfhPOW9TFk2mTCqgZkU7A8WsGbWjIeCE8OkgizpPRdPQ/SD8bVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773494; 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=z14KI++fXbIyjdyO3i6arBx4MXJ9YK5buuNoxXPdq7g=; b=WpwPDU/iwjcIGlwz0og5Tiy/9KjllPOL0DuZtxxxZ3E12PGqW8iRo2syu7zMQa2zEhH6UylJJ6aMdVzrnxPYcWj8N7/Er6AllGYp+6+Pmj1OY+NhEXTwM8HefwEYkibLIqNF+pz8Mg4BiwFsrDTXAwnK6P2yhK11uD6ZO4jDVuY= 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 1743773494340730.9971918748056; Fri, 4 Apr 2025 06:31:34 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B5A05CA9; Fri, 4 Apr 2025 09:31:33 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1569F15F0; Fri, 4 Apr 2025 09:28:27 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 53B2D12BB; Fri, 4 Apr 2025 09:28:22 -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 CF58815BC for ; Fri, 4 Apr 2025 09:28:12 -0400 (EDT) Received: from mx-prod-mc-05.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-212-8koNFYXvMCm3x9H_du89Bg-1; Fri, 04 Apr 2025 09:28:11 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7A3B1195608F for ; Fri, 4 Apr 2025 13:28:10 +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 C3AB41955BC7 for ; Fri, 4 Apr 2025 13:28:09 +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=1743773292; 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=Gne21kRB94J5X1E6pL3snzP6sLJh5P14NqHLTs/YIvA=; b=FMZlh6WM53gFFRV3C0qlJxDiSbwOppV/3rFi2c2ASR/WRWXnlQAmjMt8FUUS4TWJb/G5th 87AT26SiyW/Poaf5EpNo1DUHF3ZzHA3QeV3F2SalikKYq+vq3Xp1czyExBYYY0i7gK08QQ J608aCl1rT9Rf8KOHyEXN7Ar/zA3bZg= X-MC-Unique: 8koNFYXvMCm3x9H_du89Bg-1 X-Mimecast-MFC-AGG-ID: 8koNFYXvMCm3x9H_du89Bg_1743773290 To: devel@lists.libvirt.org Subject: [PATCH 6/8] vbox: Move parts of vboxSnapshotRedefine() into a separate function Date: Fri, 4 Apr 2025 15:27:58 +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: vFSkU9qwpR_IInpzBQJgxnnfUq6MA9E3danBZ3n2mV4_1743773290 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VY6CVMUUCM7SEH2DJB52HUQ6CVMF3HLR X-Message-ID-Hash: VY6CVMUUCM7SEH2DJB52HUQ6CVMF3HLR 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: 1743773495017019000 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik There's too much happening inside of vboxSnapshotRedefine(). Not only it makes the function hard to read, but it also increases stack size of the function. Move one part into a separate function: vboxSnapshotAddRWDisks() Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 227 ++++++++++++++++++++++------------------- 1 file changed, 124 insertions(+), 103 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index e5490304d8..9ed972e52e 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4782,6 +4782,127 @@ vboxSnapshotAddDisksToMediaRegistry(struct _vboxDri= ver *data, } =20 =20 +static int +vboxSnapshotAddRWDisks(struct _vboxDriver *data, + virDomainSnapshotDef *def, + virVBoxSnapshotConfMachine *snapshotMachineDesc, + bool needToChangeStorageController) +{ + int it =3D 0; + + for (it =3D 0; it < def->ndisks; it++) { + IMedium *medium =3D NULL; + PRUnichar *locationUtf16 =3D NULL; + virVBoxSnapshotConfHardDisk *disk =3D NULL; + PRUnichar *formatUtf16 =3D NULL; + char *format =3D NULL; + char *uuid =3D NULL; + IMedium *parentDisk =3D NULL; + char *parentUuid =3D NULL; + vboxIID iid, parentiid; + nsresult rc; + + VBOX_IID_INITIALIZE(&iid); + VBOX_IID_INITIALIZE(&parentiid); + VBOX_UTF8_TO_UTF16(def->disks[it].src->path, &locationUtf16); + rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, + locationUtf16, + DeviceType_HardDisk, + AccessMode_ReadWrite, + &medium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); + return -1; + } + VBOX_UTF16_FREE(locationUtf16); + + disk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); + + rc =3D gVBoxAPI.UIMedium.GetFormat(medium, &formatUtf16); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk format")); + VIR_FREE(disk); + return -1; + } + + VBOX_UTF16_TO_UTF8(formatUtf16, &format); + disk->format =3D format; + VBOX_UTF16_FREE(formatUtf16); + + disk->location =3D g_strdup(def->disks[it].src->path); + + rc =3D gVBoxAPI.UIMedium.GetId(medium, &iid); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk uuid")); + VIR_FREE(disk); + return -1; + } + gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); + disk->uuid =3D uuid; + vboxIIDUnalloc(&iid); + + rc =3D gVBoxAPI.UIMedium.GetParent(medium, &parentDisk); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk parent")); + VIR_FREE(disk); + return -1; + } + + gVBoxAPI.UIMedium.GetId(parentDisk, &parentiid); + gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); + vboxIIDUnalloc(&parentiid); + if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(disk, + snapshotMachineD= esc->mediaRegistry, + parentUuid) < 0)= { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to the media regist= ry")); + VIR_FREE(disk); + return -1; + } + + if (needToChangeStorageController) { + /* We need to append this disk in the storage controller */ + g_auto(GStrv) searchResultTab =3D NULL; + char *tmp =3D NULL; + ssize_t resultSize =3D 0; + + resultSize =3D virStringSearch(snapshotMachineDesc->storageCon= troller, + VBOX_UUID_REGEX, + it + 1, + &searchResultTab); + if (resultSize !=3D it + 1) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID %1$s"), searchResul= tTab[it]); + return -1; + } + + tmp =3D virStringReplace(snapshotMachineDesc->storageControlle= r, + searchResultTab[it], + disk->uuid); + VIR_FREE(snapshotMachineDesc->storageController); + if (!tmp) + return -1; + snapshotMachineDesc->storageController =3D g_strdup(tmp); + + VIR_FREE(tmp); + } + /* Close disk */ + rc =3D gVBoxAPI.UIMedium.Close(medium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); + return -1; + } + } + + return 0; +} + + static int vboxSnapshotRedefine(virDomainPtr dom, virDomainSnapshotDef *def, @@ -5097,109 +5218,9 @@ vboxSnapshotRedefine(virDomainPtr dom, * If the snapshot to redefine is the current snapshot, we add rea= d-write disks in * the machine storage controllers. */ - for (it =3D 0; it < def->ndisks; it++) { - IMedium *medium =3D NULL; - PRUnichar *locationUtf16 =3D NULL; - virVBoxSnapshotConfHardDisk *disk =3D NULL; - PRUnichar *formatUtf16 =3D NULL; - char *format =3D NULL; - char *uuid =3D NULL; - IMedium *parentDisk =3D NULL; - char *parentUuid =3D NULL; - vboxIID iid, parentiid; - - VBOX_IID_INITIALIZE(&iid); - VBOX_IID_INITIALIZE(&parentiid); - VBOX_UTF8_TO_UTF16(def->disks[it].src->path, &locationUtf16); - rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, - locationUtf16, - DeviceType_HardDisk, - AccessMode_ReadWrite, - &medium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to open HardDisk")); - goto cleanup; - } - VBOX_UTF16_FREE(locationUtf16); - - disk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); - - rc =3D gVBoxAPI.UIMedium.GetFormat(medium, &formatUtf16); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk format")); - VIR_FREE(disk); - goto cleanup; - } - - VBOX_UTF16_TO_UTF8(formatUtf16, &format); - disk->format =3D format; - VBOX_UTF16_FREE(formatUtf16); - - disk->location =3D g_strdup(def->disks[it].src->path); - - rc =3D gVBoxAPI.UIMedium.GetId(medium, &iid); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk uuid")); - VIR_FREE(disk); - goto cleanup; - } - gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); - disk->uuid =3D uuid; - vboxIIDUnalloc(&iid); - - rc =3D gVBoxAPI.UIMedium.GetParent(medium, &parentDisk); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk parent")); - VIR_FREE(disk); - goto cleanup; - } - - gVBoxAPI.UIMedium.GetId(parentDisk, &parentiid); - gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); - vboxIIDUnalloc(&parentiid); - if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(disk, - snapshotMachineDesc->mediaRegis= try, - parentUuid) < 0) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to the media re= gistry")); - VIR_FREE(disk); - goto cleanup; - } - - if (needToChangeStorageController) { - /* We need to append this disk in the storage controller */ - char *tmp =3D NULL; - resultSize =3D virStringSearch(snapshotMachineDesc->storag= eController, - VBOX_UUID_REGEX, - it + 1, - &searchResultTab); - if (resultSize !=3D it + 1) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID %1$s"), searchR= esultTab[it]); - goto cleanup; - } - - tmp =3D virStringReplace(snapshotMachineDesc->storageContr= oller, - searchResultTab[it], - disk->uuid); - VIR_FREE(snapshotMachineDesc->storageController); - if (!tmp) - goto cleanup; - snapshotMachineDesc->storageController =3D g_strdup(tmp); - - VIR_FREE(tmp); - } - /* Close disk */ - rc =3D gVBoxAPI.UIMedium.Close(medium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to close HardDisk")); - goto cleanup; - } + if (vboxSnapshotAddRWDisks(data, def, snapshotMachineDesc, + needToChangeStorageController) < 0) { + goto cleanup; } } else { char *snapshotContent; --=20 2.49.0 From nobody Thu Dec 18 04:14:28 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=1743773539; cv=none; d=zohomail.com; s=zohoarc; b=h809HEfiaot3oGtZ797ptqoB75fxWTQAIp8vQtbha/wnKoIIT9kKuFH8Tfg1ayFRUQSJJ5MwrSzxJ8bsibOrEK0hqwmbtS6eMq7qAND6oH7am06Il/FmkqdOnvNhe09mHV2K2KPnAXZqVACwD5mdH0/wzsw2oP5uDBnq2nEnPxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773539; 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=qbgKmgDN5priO2jC5joyB7Gca9TgV9XcC42yi4/TblE=; b=kpqkQqAQTl8kqadwWTGdAfhV47AO4M4PTZc4ekeVtH9175bCWB/zYSc28WunHhRU7hHNisS/1Ka/VOIUN/pGQ0ETKy2qONVK/I20phVbJlNvvMYOvfqq4rqgbGtB74862AUhDUesGm326zTKmtg3rLLoT4tMMBLXjskqRGHwk1E= 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 1743773539197573.6620074309815; Fri, 4 Apr 2025 06:32:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 99ADD15E9; Fri, 4 Apr 2025 09:32:18 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C30061625; Fri, 4 Apr 2025 09:28:35 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3857A1509; Fri, 4 Apr 2025 09:28:30 -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 E330215EC for ; Fri, 4 Apr 2025 09:28:13 -0400 (EDT) Received: from mx-prod-mc-05.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-639-eVESsBSfOhaMFRAA4iL4Hw-1; Fri, 04 Apr 2025 09:28:12 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 990BB19560A2 for ; Fri, 4 Apr 2025 13:28:11 +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 E40441955BC2 for ; Fri, 4 Apr 2025 13:28:10 +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=1743773293; 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=EUFnoO63651k7MqXvd9DjAAjWEYjf96HhMD8cAJzY4s=; b=c0npCWJP80Tlk1fFHhOJ3/tIG1vXlVtb1Xnc1Skv/oBxz9iWdl6UpcHRdXiFMOZJcGz3qR 1z1JV4JqyBBiMCurU86zaA26kfEpT/tsZHxt8vMnBfnCumcTSgOHS5NCXJfeCxlZp6tNbh ZxivGByVbP1gkilzYYHL8bds7ZHz9n0= X-MC-Unique: eVESsBSfOhaMFRAA4iL4Hw-1 X-Mimecast-MFC-AGG-ID: eVESsBSfOhaMFRAA4iL4Hw_1743773291 To: devel@lists.libvirt.org Subject: [PATCH 7/8] vbox: Move parts of vboxSnapshotRedefine() into a separate function Date: Fri, 4 Apr 2025 15:27:59 +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: R68-QvicQ76mvLWxv8n9Dj3yrTLNbfhxJIoBmBj03Hs_1743773291 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4SG3SEWLWUNJMR5ECRNTXR7V6DP3EHWC X-Message-ID-Hash: 4SG3SEWLWUNJMR5ECRNTXR7V6DP3EHWC 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: 1743773541401019000 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik There's too much happening inside of vboxSnapshotRedefine(). Not only it makes the function hard to read, but it also increases stack size of the function. Move one part into a separate function: vboxSnapshotCreateFakeDiffStorage() Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/vbox/vbox_common.c | 288 ++++++++++++++++++++++------------------- 1 file changed, 157 insertions(+), 131 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 9ed972e52e..349ac832dc 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4903,6 +4903,157 @@ vboxSnapshotAddRWDisks(struct _vboxDriver *data, } =20 =20 +static int +vboxSnapshotCreateFakeDiffStorage(struct _vboxDriver *data, + virDomainSnapshotDef *def, + char *machineLocationPath, + virVBoxSnapshotConfMachine *snapshotMach= ineDesc) +{ + virVBoxSnapshotConfHardDisk *newHardDisk =3D NULL; + int it; + int ret =3D -1; + + for (it =3D 0; it < def->parent.dom->ndisks; it++) { + IMedium *medium =3D NULL; + PRUnichar *locationUtf16 =3D NULL; + char *parentUuid =3D NULL; + IMedium *newMedium =3D NULL; + PRUnichar *formatUtf16 =3D NULL; + PRUnichar *newLocation =3D NULL; + char *newLocationUtf8 =3D NULL; + resultCodeUnion resultCode; + char *uuid =3D NULL; + char *format =3D NULL; + char *tmp =3D NULL; + vboxIID iid, parentiid; + IProgress *progress =3D NULL; + PRUint32 tab[1]; + nsresult rc; + g_auto(GStrv) searchResultTab =3D NULL; + ssize_t resultSize =3D 0; + + VBOX_IID_INITIALIZE(&iid); + VBOX_IID_INITIALIZE(&parentiid); + VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &locatio= nUtf16); + rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, + locationUtf16, + DeviceType_HardDisk, + AccessMode_ReadWrite, + &medium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); + VBOX_UTF16_FREE(locationUtf16); + goto cleanup; + } + VBOX_UTF16_FREE(locationUtf16); + + rc =3D gVBoxAPI.UIMedium.GetId(medium, &parentiid); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk id")); + goto cleanup; + } + gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); + vboxIIDUnalloc(&parentiid); + VBOX_UTF8_TO_UTF16("VDI", &formatUtf16); + + newLocationUtf8 =3D g_strdup_printf("%sfakedisk-%d.vdi", + machineLocationPath, it); + VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation); + rc =3D gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj, + formatUtf16, + newLocation, + &newMedium); + VBOX_UTF16_FREE(newLocation); + VBOX_UTF16_FREE(formatUtf16); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to create HardDisk")); + goto cleanup; + } + + tab[0] =3D MediumVariant_Diff; + gVBoxAPI.UIMedium.CreateDiffStorage(medium, newMedium, 1, tab, &pr= ogress); + + gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); + gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); + if (RC_FAILED(resultCode)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Error while creating diff storage, rc=3D%1$= 08x"), + resultCode.uResultCode); + goto cleanup; + } + VBOX_RELEASE(progress); + /* + * The differential newHardDisk is created, we add it to the + * media registry and the machine storage controllers. + */ + + newHardDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); + + rc =3D gVBoxAPI.UIMedium.GetId(newMedium, &iid); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get medium uuid")); + goto cleanup; + } + gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); + newHardDisk->uuid =3D uuid; + vboxIIDUnalloc(&iid); + + newHardDisk->location =3D g_strdup(newLocationUtf8); + + rc =3D gVBoxAPI.UIMedium.GetFormat(newMedium, &formatUtf16); + VBOX_UTF16_TO_UTF8(formatUtf16, &format); + newHardDisk->format =3D format; + VBOX_UTF16_FREE(formatUtf16); + + if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(newHardDisk, + snapshotMachineD= esc->mediaRegistry, + parentUuid) < 0)= { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to the media regist= ry")); + goto cleanup; + } + newHardDisk =3D NULL; /* Consumed by above */ + /* Adding the fake disk to the machine storage controllers */ + + resultSize =3D virStringSearch(snapshotMachineDesc->storageControl= ler, + VBOX_UUID_REGEX, + it + 1, + &searchResultTab); + if (resultSize !=3D it + 1) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID %1$s"), searchResultTab= [it]); + goto cleanup; + } + + tmp =3D virStringReplace(snapshotMachineDesc->storageController, + searchResultTab[it], + uuid); + VIR_FREE(snapshotMachineDesc->storageController); + if (!tmp) + goto cleanup; + snapshotMachineDesc->storageController =3D g_strdup(tmp); + + VIR_FREE(tmp); + /* Closing the "fake" disk */ + rc =3D gVBoxAPI.UIMedium.Close(newMedium); + if (NS_FAILED(rc)) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close the new medium")); + goto cleanup; + } + } + + ret =3D 0; + cleanup: + virVboxSnapshotConfHardDiskFree(newHardDisk); + return ret; +} + + static int vboxSnapshotRedefine(virDomainPtr dom, virDomainSnapshotDef *def, @@ -4950,7 +5101,6 @@ vboxSnapshotRedefine(virDomainPtr dom, unsigned char snapshotUuid[VIR_UUID_BUFLEN]; virVBoxSnapshotConfHardDisk **hardDiskToOpen =3D NULL; size_t hardDiskToOpenSize =3D 0; - virVBoxSnapshotConfHardDisk *newHardDisk =3D NULL; g_auto(GStrv) searchResultTab =3D NULL; ssize_t resultSize =3D 0; int it =3D 0; @@ -5224,137 +5374,14 @@ vboxSnapshotRedefine(virDomainPtr dom, } } else { char *snapshotContent; + /* Create a "fake" disk to avoid corrupting children snapshot disk= s. */ - for (it =3D 0; it < def->parent.dom->ndisks; it++) { - IMedium *medium =3D NULL; - PRUnichar *locationUtf16 =3D NULL; - char *parentUuid =3D NULL; - IMedium *newMedium =3D NULL; - PRUnichar *formatUtf16 =3D NULL; - PRUnichar *newLocation =3D NULL; - char *newLocationUtf8 =3D NULL; - resultCodeUnion resultCode; - char *uuid =3D NULL; - char *format =3D NULL; - char *tmp =3D NULL; - vboxIID iid, parentiid; - IProgress *progress =3D NULL; - PRUint32 tab[1]; - - VBOX_IID_INITIALIZE(&iid); - VBOX_IID_INITIALIZE(&parentiid); - VBOX_UTF8_TO_UTF16(def->parent.dom->disks[it]->src->path, &loc= ationUtf16); - rc =3D gVBoxAPI.UIVirtualBox.OpenMedium(data->vboxObj, - locationUtf16, - DeviceType_HardDisk, - AccessMode_ReadWrite, - &medium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to open HardDisk")); - VBOX_UTF16_FREE(locationUtf16); - goto cleanup; - } - VBOX_UTF16_FREE(locationUtf16); - - rc =3D gVBoxAPI.UIMedium.GetId(medium, &parentiid); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get hard disk id")); - goto cleanup; - } - gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); - vboxIIDUnalloc(&parentiid); - VBOX_UTF8_TO_UTF16("VDI", &formatUtf16); - - newLocationUtf8 =3D g_strdup_printf("%sfakedisk-%d.vdi", - machineLocationPath, it); - VBOX_UTF8_TO_UTF16(newLocationUtf8, &newLocation); - rc =3D gVBoxAPI.UIVirtualBox.CreateHardDisk(data->vboxObj, - formatUtf16, - newLocation, - &newMedium); - VBOX_UTF16_FREE(newLocation); - VBOX_UTF16_FREE(formatUtf16); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to create HardDisk")); - goto cleanup; - } - - tab[0] =3D MediumVariant_Diff; - gVBoxAPI.UIMedium.CreateDiffStorage(medium, newMedium, 1, tab,= &progress); - - gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); - gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); - if (RC_FAILED(resultCode)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Error while creating diff storage, rc= =3D%1$08x"), - resultCode.uResultCode); - goto cleanup; - } - VBOX_RELEASE(progress); - /* - * The differential newHardDisk is created, we add it to the - * media registry and the machine storage controllers. - */ - - newHardDisk =3D g_new0(virVBoxSnapshotConfHardDisk, 1); - - rc =3D gVBoxAPI.UIMedium.GetId(newMedium, &iid); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get medium uuid")); - goto cleanup; - } - gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); - newHardDisk->uuid =3D uuid; - vboxIIDUnalloc(&iid); - - newHardDisk->location =3D g_strdup(newLocationUtf8); - - rc =3D gVBoxAPI.UIMedium.GetFormat(newMedium, &formatUtf16); - VBOX_UTF16_TO_UTF8(formatUtf16, &format); - newHardDisk->format =3D format; - VBOX_UTF16_FREE(formatUtf16); - - if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(newHardDisk, - snapshotMachineDesc->mediaRegis= try, - parentUuid) < 0) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to the media re= gistry")); - goto cleanup; - } - newHardDisk =3D NULL; /* Consumed by above */ - /* Adding the fake disk to the machine storage controllers */ - - resultSize =3D virStringSearch(snapshotMachineDesc->storageCon= troller, - VBOX_UUID_REGEX, - it + 1, - &searchResultTab); - if (resultSize !=3D it + 1) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID %1$s"), searchResul= tTab[it]); - goto cleanup; - } - - tmp =3D virStringReplace(snapshotMachineDesc->storageControlle= r, - searchResultTab[it], - uuid); - VIR_FREE(snapshotMachineDesc->storageController); - if (!tmp) - goto cleanup; - snapshotMachineDesc->storageController =3D g_strdup(tmp); - - VIR_FREE(tmp); - /* Closing the "fake" disk */ - rc =3D gVBoxAPI.UIMedium.Close(newMedium); - if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to close the new medium")); - goto cleanup; - } + if (vboxSnapshotCreateFakeDiffStorage(data, def, + machineLocationPath, + snapshotMachineDesc) < 0) { + goto cleanup; } + /* * We save the snapshot xml file to retrieve the real read-write d= isk during the * next define. This file is saved as "'machineLocation'/snapshot-= 'uuid'.xml" @@ -5443,7 +5470,6 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(currentSnapshotXmlFilePath); VBOX_UTF16_FREE(machineNameUtf16); VBOX_UTF8_FREE(machineName); - virVboxSnapshotConfHardDiskFree(newHardDisk); VIR_FREE(hardDiskToOpen); VIR_FREE(newSnapshotPtr); VIR_FREE(machineLocationPath); --=20 2.49.0 From nobody Thu Dec 18 04:14:28 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=1743773557; cv=none; d=zohomail.com; s=zohoarc; b=cIwxMQj0nycQpGqm8b4E/M0gK1Q6h+Bflw2kPnuby/oX9ZEluHhUCL8ZfYjLuHPbo/wzlhe0b65sfLKG5pF3+cLmlUd1j2QSpr8+RdEuKnPngbeHzI72KXolwhikOComCqZAnklfq5dXP3X5J6+A4wj1VJt5LZi23GY7OT07m8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1743773557; 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=FA0hIxmQL2p2B1ShKQkdSGfzmhnYyPGvM3TeT3Lis5c=; b=LMsNSY1jWfIVFoGWk1bgRPF7MqmnGLAdryC5m0OF0de/dTFX2kxcxmca4URl2UkFc2l/QWjO836cgEf8+6ddV1rd+XZFpdqZRmtWNSwOvywXuijJDi4Ihc4DjNCWjDA0o4S7Qe0uC9YkghHJq2fyyYXFAs+2a03fx8hyegsvJP4= 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 1743773557693157.83011888210353; Fri, 4 Apr 2025 06:32:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0EF411550; Fri, 4 Apr 2025 09:32:37 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DFFC215D9; Fri, 4 Apr 2025 09:28:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 61ABB1454; Fri, 4 Apr 2025 09:28:30 -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 CD1AF15A0 for ; Fri, 4 Apr 2025 09:28:14 -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-677-b6tvzJmUNgmVlPgqgsX8Eg-1; Fri, 04 Apr 2025 09:28:13 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C23921955DD0 for ; Fri, 4 Apr 2025 13:28:12 +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 0E5EA1955BC2 for ; Fri, 4 Apr 2025 13:28:11 +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=1743773294; 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=efWN24lAM+ZVpJ6C8hooEopPNjKpnBB7NjpaeLQEvo4=; b=eXmf/2bGBz7qiDztx8pLyXoxSZpVWAgYs3CA8nJBsp0V4q57BigX2BachDSZNkQeMGXske AP8K94RzgQxKTxVSmbJnwndYdi7DC5T2RdV88+KpfEqKxNQlE/xINGqOZwDf6JjPctY6/a e9eTM+ZkXKkj8Lvbc8dDUaXm2UzbyNY= X-MC-Unique: b6tvzJmUNgmVlPgqgsX8Eg-1 X-Mimecast-MFC-AGG-ID: b6tvzJmUNgmVlPgqgsX8Eg_1743773292 To: devel@lists.libvirt.org Subject: [PATCH 8/8] meson: Drop workaround for -Wframe-larger-than and clang Date: Fri, 4 Apr 2025 15:28:00 +0200 Message-ID: <3c7a9ae5afe2ea717c1fec546daec903e5253928.1743772966.git.mprivozn@redhat.com> 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: RGIuYjJAfW5CLyoGicDwuEIMtRTXvt2JRwrn3-BrrhA_1743773292 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TS3J7PXWH5BLJMGY4MTRM5DYYVL3CXY5 X-Message-ID-Hash: TS3J7PXWH5BLJMGY4MTRM5DYYVL3CXY5 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: 1743773558074019000 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik After previous cleanups, all functions have their stack smaller than 2048 bytes and thus the workaround is no longer needed. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko Reviewed-by: Roman Bogorodskiy --- meson.build | 5 ----- 1 file changed, 5 deletions(-) diff --git a/meson.build b/meson.build index bf4a245dd3..37b1caa566 100644 --- a/meson.build +++ b/meson.build @@ -258,11 +258,6 @@ alloc_max =3D run_command( =20 stack_frame_size =3D 2048 =20 -# clang without optimization enlarges stack frames in certain corner cases -if cc.get_id() =3D=3D 'clang' and get_option('optimization') =3D=3D '0' - stack_frame_size =3D 4096 -endif - # sanitizer instrumentation may enlarge stack frames if get_option('b_sanitize') !=3D 'none' stack_frame_size =3D 32768 --=20 2.49.0