From nobody Sun Feb 8 23:27:25 2026 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 1726673241160989.1077961080207; Wed, 18 Sep 2024 08:27:21 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 110101A84; Wed, 18 Sep 2024 11:27:20 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9D94B14E4; Wed, 18 Sep 2024 11:26:40 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 41B82146A; Wed, 18 Sep 2024 11:26:37 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C4C5A1459 for ; Wed, 18 Sep 2024 11:26:36 -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-149-vPs6Y2vJOp-8rgMDUuHVtg-1; Wed, 18 Sep 2024 11:26:34 -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 D728C1955F42 for ; Wed, 18 Sep 2024 15:26:33 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.17.190]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2ED7730001A1 for ; Wed, 18 Sep 2024 15:26:33 +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,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=1726673196; 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=htsuMyxnrN/MFCwRVGeFcEH1YUWbgtOzT2L9zvMy74c=; b=hi1MAFqIcsm+BQaqNLo7rLQhSCEPZtRuih3JF0xFjBqnv3ZqfAMsrCzheDCBFGcAOZeV+O xPZgQo2VplZQPo6FL1WWWtZdY7jJrv6aMeSH1ye4UQagvKVW7jf5pJP+AmLadEhHawjAcV L6c5teev6cB7xge+iDvOFl9aIje2KRc= X-MC-Unique: vPs6Y2vJOp-8rgMDUuHVtg-1 From: Laine Stump To: devel@lists.libvirt.org Subject: [PATCH 2/4] util: don't return early from virNetDevTapReattachBridge() if "force" is true Date: Wed, 18 Sep 2024 11:26:28 -0400 Message-ID: <20240918152630.875195-3-laine@redhat.com> In-Reply-To: <20240918152630.875195-1-laine@redhat.com> References: <20240918152630.875195-1-laine@redhat.com> 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: 4AZE42RJKWOIRQ4RGQPXOTUMEVMUXR6M X-Message-ID-Hash: 4AZE42RJKWOIRQ4RGQPXOTUMEVMUXR6M X-MailFrom: laine@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: 1726673242166116600 Content-Type: text/plain; charset="utf-8"; x-default="true" It can be useful to force an interface to be detached/reattached from its bridge even if it's the same bridge - possibly something like the virtualport profileID has changed, and a detach/attach cycle will get it connected with the new profileID. The one and only current use of virNetDevTapReattachBridge() sets force to false, to preserve current behavior. An upcoming patch will use it with force set to true. Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 2 +- src/util/virnetdevtap.c | 8 ++++++-- src/util/virnetdevtap.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cf4b1b2aef..963322f2f6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30630,7 +30630,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn, virDomainNetGetActualVirtP= ortProfile(iface), virDomainNetGetActualVlan(= iface), virDomainNetGetActualPortO= ptionsIsolated(iface), - iface->mtu, NULL)); + iface->mtu, NULL, false)); } } =20 diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 3d7f680599..2701ba6dfc 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -510,6 +510,9 @@ virNetDevTapAttachBridge(const char *tapname, * @virtVlan: vlan tag info * @mtu: requested MTU for port (or 0 for "default") * @actualMTU: MTU actually set for port (after accounting for bridge's MT= U) + * @force: set true to force detach/reattach even if the bridge name is un= changed + * (this can be useful if, for example, the profileid of the + * changes) * * Ensures that the tap device (@tapname) is connected to the bridge * (@brname), potentially removing it from any existing bridge that @@ -526,7 +529,8 @@ virNetDevTapReattachBridge(const char *tapname, const virNetDevVlan *virtVlan, virTristateBool isolatedPort, unsigned int mtu, - unsigned int *actualMTU) + unsigned int *actualMTU, + bool force) { bool useOVS =3D false; g_autofree char *master =3D NULL; @@ -542,7 +546,7 @@ virNetDevTapReattachBridge(const char *tapname, } =20 /* Nothing more todo if we're on the right bridge already */ - if (STREQ_NULLABLE(brname, master)) + if (STREQ_NULLABLE(brname, master) && !force) return 0; =20 /* disconnect from current (incorrect) bridge, if any */ diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h index c9d29c0384..9ebe0ee9ed 100644 --- a/src/util/virnetdevtap.h +++ b/src/util/virnetdevtap.h @@ -82,7 +82,8 @@ virNetDevTapReattachBridge(const char *tapname, const virNetDevVlan *virtVlan, virTristateBool isolatedPort, unsigned int mtu, - unsigned int *actualMTU) + unsigned int *actualMTU, + bool force) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) G_GNUC_WARN_UNUSED_RESULT; =20 --=20 2.46.0