]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: don't return early from virNetDevTapReattachBridge() if "force" is true
authorLaine Stump <laine@redhat.com>
Tue, 17 Sep 2024 17:28:04 +0000 (13:28 -0400)
committerLaine Stump <laine@redhat.com>
Thu, 19 Sep 2024 17:56:19 +0000 (13:56 -0400)
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>
src/conf/domain_conf.c
src/util/virnetdevtap.c
src/util/virnetdevtap.h

index 7f6a91c4279087f6774d6400d74e0de9f11e573f..6d7dee7956d2d38fe69f0bd5fc20e201bc9d961d 100644 (file)
@@ -30625,7 +30625,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn,
                                                 virDomainNetGetActualVirtPortProfile(iface),
                                                 virDomainNetGetActualVlan(iface),
                                                 virDomainNetGetActualPortOptionsIsolated(iface),
-                                                iface->mtu, NULL));
+                                                iface->mtu, NULL, false));
     }
 }
 
index 3d7f6805996e10ec4bb4ac29e5093874364dc0fe..2701ba6dfc22b01bee83f00a77bde82267b06f14 100644 (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  */
index c9d29c0384b7ba192cb951546f5f9492005f4663..9ebe0ee9ed4b524defaa67c10f151f5599cc9b92 100644 (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;