1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

util: don't return early from virNetDevTapReattachBridge() if "force" is 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 <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Laine Stump 2024-09-17 13:28:04 -04:00
parent a37bd2a15b
commit e3f8bccea6
3 changed files with 9 additions and 4 deletions

View File

@ -30625,7 +30625,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn,
virDomainNetGetActualVirtPortProfile(iface),
virDomainNetGetActualVlan(iface),
virDomainNetGetActualPortOptionsIsolated(iface),
iface->mtu, NULL));
iface->mtu, NULL, false));
}
}

View File

@ -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 MTU)
* @force: set true to force detach/reattach even if the bridge name is unchanged
* (this can be useful if, for example, the profileid of the
* <virtualport> 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 = false;
g_autofree char *master = NULL;
@ -542,7 +546,7 @@ virNetDevTapReattachBridge(const char *tapname,
}
/* Nothing more todo if we're on the right bridge already */
if (STREQ_NULLABLE(brname, master))
if (STREQ_NULLABLE(brname, master) && !force)
return 0;
/* disconnect from current (incorrect) bridge, if any */

View File

@ -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;