From nobody Wed Jun 24 21:39:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1781770016; cv=none; d=zohomail.com; s=zohoarc; b=QJIhLyMhU5e+OymwqdSdMIPfUS1oFXQcPLckCJ3B1JRtrrrpzyHBnhPW8cAa/Ga32HKS1tWs/ProPysR/a2qdOKMPdPEFO9V8u70dMGpPdCH5pYg40GrgpguctEJZ9yT75HBrZv/Nwaj0wKf1ksx36fPIA3tdxloa1FDCk/BoeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781770016; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=6R71O+ATK9zdHhepspMc8Zq2NeY1t3kJdGldfFkYLk8=; b=ZpSS0cgq9DsecBOdXTME2IE6KaBmhXDNWpxz3OGl5kk0vtEpaTulpuK3aLOJWPqU1jcFoi7+kRLE6MimXipun7w9mrhXvx6Bo2TakM+zYIhDF6dBm8fauJaIb/bsyGfG71Y9SdGekYANY9dBwMeRINzzH5uBEC5xAS7OzwFuqHw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1781770016464190.73754556574693; Thu, 18 Jun 2026 01:06:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 24DED41CBA; Thu, 18 Jun 2026 04:06:55 -0400 (EDT) Received: from [172.19.199.7] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 1C0D441D58; Thu, 18 Jun 2026 04:05:11 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id CF77D41BA3; Thu, 18 Jun 2026 04:04:55 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1B12F41BA3 for ; Thu, 18 Jun 2026 04:04:55 -0400 (EDT) Received: from mx-prod-mc-03.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-500-OOwbEb0gNE6pSX-aN_U5vg-1; Thu, 18 Jun 2026 04:04:53 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9F21B1956045 for ; Thu, 18 Jun 2026 08:04:52 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04BCD180058D for ; Thu, 18 Jun 2026 08:04:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781769894; 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=6R71O+ATK9zdHhepspMc8Zq2NeY1t3kJdGldfFkYLk8=; b=aNILueFo8Cc/5QOpj21lVJ0cqUqQ3al6TJae21T6NfEa9j12HZW1DEDq7hAhd/56f5vaRw pHEFyx5K+RX9JGQbCgiCCYc04vV7Lant6At8AWpLa79h5Jvv3xdyl3d2JtTqQ79XsAsZRS C5NbUY+z0Mp/EnwGYcLB/n6vPpn4o5U= X-MC-Unique: OOwbEb0gNE6pSX-aN_U5vg-1 X-Mimecast-MFC-AGG-ID: OOwbEb0gNE6pSX-aN_U5vg_1781769892 To: devel@lists.libvirt.org Subject: [PATCH 1/3] lxc: Drop pointless g_free() from virLXCProcessStart() Date: Thu, 18 Jun 2026 10:04:46 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AKccY0v66-0TlIvfJHVWMoGkfvz1SO2l28jlmp2nrSs_1781769892 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6UTJLES3OFFD4G65P2QWPFY627CBJIG4 X-Message-ID-Hash: 6UTJLES3OFFD4G65P2QWPFY627CBJIG4 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: 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: 1781770018834158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik When staring an LXC domain (well, container) its consoles are opened and each one is assigned an alias (for later use with virDomainOpenConsole()). Now, before generating new alias the old one is freed. But the old one can never be anything other than NULL. The domain is inactive at this point (we are in process of starting it, after all). And LXC driver does not support user aliases, yet. Just drop the pointless g_free(). Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/lxc/lxc_process.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 2c0bcb9dd3..cac49af6e2 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1346,7 +1346,6 @@ int virLXCProcessStart(virLXCDriver * driver, g_free(vm->def->consoles[i]->source->data.file.path); vm->def->consoles[i]->source->data.file.path =3D ttyPath; =20 - g_free(vm->def->consoles[i]->info.alias); vm->def->consoles[i]->info.alias =3D g_strdup_printf("console%zu",= i); } =20 --=20 2.53.0 From nobody Wed Jun 24 21:39:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1781770084; cv=none; d=zohomail.com; s=zohoarc; b=gZufYJj0Pw35ubzuDwHKXkmNU5ovqbIFQiqOtIeaRMaSY1oZq2FQ9ZS4+kAvcK5/+137kaRTqWT1k9boyJh13NboYu050SGGq3viUiFt4YN/14kD9CySzAjykf5wGaYsEf5MegdsuhNmmkpWv+CWWsTHW4Gf91DAOhHCCNRL/QU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781770084; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=jlmtpMzfDyu+ZZX56eF6SlD5NfVnzSUKdSYgXzklH3M=; b=DIjouiVT+qDYb3X4OC/DK4YRmmMSZGs+gzNZ744v2jNauIWuS7VHaM6RaKoo9Ysm+2wdodB7x7uv0CrByrykyqDstRmVS6NV4FtLzf+AND2NryrEvS9JIpKWuDOchwqcpP6whm8UtOCFSuBKBNwq0MYE2hHzX4iiQ/BBmohCbGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1781770084835385.9057939688979; Thu, 18 Jun 2026 01:08:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id EBA7741BD8; Thu, 18 Jun 2026 04:08:02 -0400 (EDT) Received: from [172.19.199.7] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id A882641CB9; Thu, 18 Jun 2026 04:05:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6DFD841BA3; Thu, 18 Jun 2026 04:04:56 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C1DAA41BA5 for ; Thu, 18 Jun 2026 04:04:55 -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-396-ednySKlKOoiVsCeMTXvq-Q-1; Thu, 18 Jun 2026 04:04:54 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9370A18005A9 for ; Thu, 18 Jun 2026 08:04:53 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 028F91800591 for ; Thu, 18 Jun 2026 08:04:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781769895; 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=jlmtpMzfDyu+ZZX56eF6SlD5NfVnzSUKdSYgXzklH3M=; b=CDtmiOLIyyvynM3qS4rBsc1GtkRutiAXEDiwxSPA/WrGN4lTwRTY7Vhan2Hx4NCn1W0UWs Xd0KtHEYOkyCRx2tpPPr+Fed1QWO/BoHIHm0K/qNi4TM4CusN2PRWLa0I4eAenMXKDTnIe mQDcuYa0qgytC1nMpYMgVkKmdzh70Mc= X-MC-Unique: ednySKlKOoiVsCeMTXvq-Q-1 X-Mimecast-MFC-AGG-ID: ednySKlKOoiVsCeMTXvq-Q_1781769893 To: devel@lists.libvirt.org Subject: [PATCH 2/3] lxc: Don't leak @veth in lxcDomainAttachDeviceNetLive() Date: Thu, 18 Jun 2026 10:04:47 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kYCaEIoWc_S5RHGLLdsby6ahWmegwcYJwjBM83yVZNw_1781769893 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5T2VDQXF76FCGPUJXB5YZK77AKELMX6A X-Message-ID-Hash: 5T2VDQXF76FCGPUJXB5YZK77AKELMX6A X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: 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: 1781770087099158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik During hotplug of an into an LXC domain (lxcDomainAttachDeviceNetLive()), the host side name of the interface is stored in @veth variable. Well, all possible paths that set the variable (virLXCProcessSetupInterfaceTap(), virLXCProcessSetupInterfaceDirect()) document it is caller's responsibility to free the memory. But it never does so. =3D=3D49848=3D=3D 12 bytes in 2 blocks are definitely lost in loss record 6= 8 of 1,763 =3D=3D49848=3D=3D at 0x4913888: malloc (vg_replace_malloc.c:447) =3D=3D49848=3D=3D by 0x546F0BC: __vasprintf_internal (in /usr/lib64/libc= .so.6) =3D=3D49848=3D=3D by 0x5077A70: g_vasprintf (in /usr/lib64/libglib-2.0.s= o.0.8400.4) =3D=3D49848=3D=3D by 0x50404DB: g_strdup_vprintf (in /usr/lib64/libglib-= 2.0.so.0.8400.4) =3D=3D49848=3D=3D by 0x50405A4: g_strdup_printf (in /usr/lib64/libglib-2= .0.so.0.8400.4) =3D=3D49848=3D=3D by 0x4A8591E: virNetDevGenerateName (virnetdev.c:3573) =3D=3D49848=3D=3D by 0x4A93C38: virNetDevVethCreate (virnetdevveth.c:124) =3D=3D49848=3D=3D by 0xED6C505: virLXCProcessSetupInterfaceTap (lxc_proc= ess.c:279) =3D=3D49848=3D=3D by 0xED5F7A7: lxcDomainAttachDeviceNetLive (lxc_driver= .c:3517) =3D=3D49848=3D=3D by 0xED60D24: lxcDomainAttachDeviceLive (lxc_driver.c:= 3925) =3D=3D49848=3D=3D by 0xED6262D: lxcDomainAttachDeviceFlags (lxc_driver.c= :4453) =3D=3D49848=3D=3D by 0xED62819: lxcDomainAttachDevice (lxc_driver.c:4485) Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/lxc/lxc_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 0b0592a4b7..a1a0343a5b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3473,7 +3473,7 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, int ret =3D -1; virDomainNetType actualType; const virNetDevBandwidth *actualBandwidth; - char *veth =3D NULL; + g_autofree char *veth =3D NULL; =20 if (!priv->initpid) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", --=20 2.53.0 From nobody Wed Jun 24 21:39:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1781770146; cv=none; d=zohomail.com; s=zohoarc; b=fvLO0UvNLHn5oAOZCEHVC/I3X09V/5UcG+GCMihTlVDi4ElnaLks9qWjPPClOusvKMTouFyfH3BEU4fHjDkVAoYSGFou2mvnFJ9NfU7xDVmkwuJbE/e6MOIAiIubk2FH7EcUIAe64ySRWz7cbT6U0XtNTINZwdTPV0Wfg/AjrPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781770146; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=bXqzFYS2+KGFlnDHiIjpymvJik4hp/z/WEMj1UyvHvM=; b=Tgye8kp17ghRrFa0pVvdMOHLxVq7F4rFpvaNybcXUFRxoKqSaqvXJoSj9ZdXftbslEJp0dyS2xUGi704CtUh2jECLwtWm5FMk42fhn6jbOdzk+E9crvMI4b2W7nsrgVhE45UEv/CteMrYziPJprK0roW9Pr5yNLHa8g9qhewe8A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1781770146612397.59322544180804; Thu, 18 Jun 2026 01:09:06 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1CD4641907; Thu, 18 Jun 2026 04:09:04 -0400 (EDT) Received: from [172.19.199.7] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 2BC8841DE1; Thu, 18 Jun 2026 04:05:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6718141BA7; Thu, 18 Jun 2026 04:04:57 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C20CB4198C for ; Thu, 18 Jun 2026 04:04:56 -0400 (EDT) Received: from mx-prod-mc-03.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-98-8jl2Uj5oOci6DxKNbAzaGA-1; Thu, 18 Jun 2026 04:04:55 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86B9B1956049 for ; Thu, 18 Jun 2026 08:04:54 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAA0D1800598 for ; Thu, 18 Jun 2026 08:04:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781769896; 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=bXqzFYS2+KGFlnDHiIjpymvJik4hp/z/WEMj1UyvHvM=; b=FrU95qN/x0BfuzRQcZsrcAe6f926bxrz/14ZoyoDzJ5+lHed6Xy5RgEMlvihkanYSyz1fc /6nL79OR7a6YE3NI2V54sFUp+KadpFmHP7EykBDpbRV3DdOu5TWyhy8kiHB76I4TnXYPud nFBd5aVPwt6DQGQljdB6Qx/bvVSJKbA= X-MC-Unique: 8jl2Uj5oOci6DxKNbAzaGA-1 X-Mimecast-MFC-AGG-ID: 8jl2Uj5oOci6DxKNbAzaGA_1781769894 To: devel@lists.libvirt.org Subject: [PATCH 3/3] lxc: Rework cleanup section in lxcDomainAttachDeviceNetLive() Date: Thu, 18 Jun 2026 10:04:48 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sVrekRo62JPlYRcR1bHcC9ggmChiocOQjKIywJ64gkM_1781769894 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MMLW3K3IS7V3ZDTQXL772WX2XJUHJN4N X-Message-ID-Hash: MMLW3K3IS7V3ZDTQXL772WX2XJUHJN4N X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: 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: 1781770147460158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik The cleanup section in lxcDomainAttachDeviceNetLive() is suspicious. It checks @ret for success and adds net into domain definition. This is not something fits into cleanup. It belongs right before 'ret =3D 0' line when we know everything before succeeded. Moving that piece of code where it belongs, the cleanup section becomes error because it is executed only in case of failure. Change the label to error, fix corresponding goto-s, and drop @ret variable. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/lxc/lxc_driver.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index a1a0343a5b..b59c080da9 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3470,7 +3470,6 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, virDomainNetDef *net) { virLXCDomainObjPrivate *priv =3D vm->privateData; - int ret =3D -1; virDomainNetType actualType; const virNetDevBandwidth *actualBandwidth; g_autofree char *veth =3D NULL; @@ -3512,18 +3511,18 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, if (!brname) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No bridge name specified")); - goto cleanup; + return -1; } if (!(veth =3D virLXCProcessSetupInterfaceTap(vm->def, net, brname= ))) - goto cleanup; + return -1; } break; case VIR_DOMAIN_NET_TYPE_ETHERNET: if (!(veth =3D virLXCProcessSetupInterfaceTap(vm->def, net, NULL))) - goto cleanup; + return -1; break; case VIR_DOMAIN_NET_TYPE_DIRECT: { if (!(veth =3D virLXCProcessSetupInterfaceDirect(driver, vm->def, = net))) - goto cleanup; + return -1; } break; case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_VHOSTUSER: @@ -3538,11 +3537,11 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, case VIR_DOMAIN_NET_TYPE_VDS: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Network device type is not supported")); - goto cleanup; + return -1; case VIR_DOMAIN_NET_TYPE_LAST: default: virReportEnumRangeError(virDomainNetType, actualType); - goto cleanup; + return -1; } /* Set bandwidth or warn if requested and not supported. */ actualBandwidth =3D virDomainNetGetActualBandwidth(net); @@ -3554,7 +3553,7 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, flags |=3D VIR_NETDEV_BANDWIDTH_SET_DIR_SWAPPED; =20 if (virNetDevBandwidthSet(net->ifname, actualBandwidth, flags)= < 0) - goto cleanup; + goto error; } else { VIR_WARN("setting bandwidth on interfaces of type '%s' is not = implemented yet: %s", virDomainNetTypeToString(actualType), virGetLastError= Message()); @@ -3563,17 +3562,16 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, =20 if (virNetDevSetNamespace(veth, priv->initpid) < 0) { virDomainAuditNet(vm, NULL, net, "attach", false); - goto cleanup; + goto error; } =20 virDomainAuditNet(vm, NULL, net, "attach", true); =20 - ret =3D 0; + vm->def->nets[vm->def->nnets++] =3D net; + return 0; =20 - cleanup: - if (!ret) { - vm->def->nets[vm->def->nnets++] =3D net; - } else if (veth) { + error: + if (veth) { switch (actualType) { case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -3603,7 +3601,7 @@ lxcDomainAttachDeviceNetLive(virLXCDriver *driver, } } =20 - return ret; + return -1; } =20 =20 --=20 2.53.0