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(a)redhat.com>
---
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,
virDomainNetGetActualVirtPortProfile(iface),
virDomainNetGetActualVlan(iface),
virDomainNetGetActualPortOptionsIsolated(iface),
- iface->mtu, NULL));
+ iface->mtu, NULL, false));
}
}
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 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 */
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;
--
2.46.0