From nobody Fri Jan 3 00:25:06 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1728551960792863.2795217644172; Thu, 10 Oct 2024 02:19:20 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A79191440; Thu, 10 Oct 2024 05:19:19 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1F14E1374; Thu, 10 Oct 2024 05:19:01 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id F1C5EE75; Thu, 10 Oct 2024 05:18:57 -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 37F18132C for ; Thu, 10 Oct 2024 05:18:57 -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-441-XqMJuqkfMiuS5PBt5bXQtQ-1; Thu, 10 Oct 2024 05:18:55 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 B34A919560B0 for ; Thu, 10 Oct 2024 09:18:54 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.2.246]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 16E14300018D for ; Thu, 10 Oct 2024 09:18:53 +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.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,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=1728551936; 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; bh=QMJcuTYbi7FCzXjy8PGe1s3aa3pNCoCxOTQ3z7LcH40=; b=STeajJQeHbQR+4atjOEG6HrjMb2yMeVwsUxCh7I7q+tkBqbkmtgWY/PUHm6sJCgOAhWWuk MJKZII/do8GH3gT6AhdxSuIj2ifYluvhgDfmS37agikEthNdA0h4AwoL11hs/f24HKvUSF LOwasXkaEHW7lwndver5z8VVmD94jD8= X-MC-Unique: XqMJuqkfMiuS5PBt5bXQtQ-1 From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH] lxc: fix variable storage order before call Date: Thu, 10 Oct 2024 11:18:50 +0200 Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6FABWQQG5YPADQKTMPEXFVDYGU2NMKOP X-Message-ID-Hash: 6FABWQQG5YPADQKTMPEXFVDYGU2NMKOP X-MailFrom: ajulis@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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1728551962312116600 Content-Type: text/plain; charset="utf-8"; x-default="true" virDomainConfNWFilterInstantiate() was called without updated net->ifname, it caused in some cases throwing error message. If function failed, change is reverted. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/658 Signed-off-by: Adam Julis --- src/lxc/lxc_process.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 205ab96ebb..b00608e30a 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -271,6 +271,7 @@ virLXCProcessSetupInterfaceTap(virDomainDef *vm, { g_autofree char *parentVeth =3D NULL; g_autofree char *containerVeth =3D NULL; + g_autofree char *backupIfname =3D NULL; const virNetDevVPortProfile *vport =3D virDomainNetGetActualVirtPortPr= ofile(net); =20 VIR_DEBUG("calling vethCreate()"); @@ -315,14 +316,18 @@ virLXCProcessSetupInterfaceTap(virDomainDef *vm, return NULL; } =20 - if (net->filter && - virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) <= 0) - return NULL; - - /* success is guaranteed, so update the interface object */ + /* success almost guaranteed, next function needs updated net->ifname = */ + backupIfname =3D g_strdup(net->ifname); g_free(net->ifname); net->ifname =3D g_steal_pointer(&parentVeth); =20 + if (net->filter && + virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, false) <= 0) { + g_free(net->ifname); + net->ifname =3D g_steal_pointer(&backupIfname); + return NULL; + } + return g_steal_pointer(&containerVeth); } =20 --=20 2.45.2