[PATCH 8/8] network: Clean up after disappeared transient inactive networks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a network disappeared the daemon should not only remove it from the
list of networks, but also do a proper cleanup.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/network/bridge_driver.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 0e8057e24aed..0ba62d986ff4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -533,6 +533,23 @@ networkUpdateState(virNetworkObj *obj,
 }
 
 
+static int
+networkCleanupTransientInactive(virNetworkObj *obj,
+                                void *opaque)
+{
+    virNetworkDriverState *driver = opaque;
+
+    if (!virNetworkObjIsActive(obj) &&
+        !virNetworkObjIsPersistent(obj)) {
+        /* We can only do a cleanup here so that this can be called from an
+         * iterator over the networks */
+        networkCleanupInactive(driver, obj);
+    }
+
+    return 0;
+}
+
+
 static int
 networkAutostartConfig(virNetworkObj *obj,
                        void *opaque)
@@ -659,6 +676,11 @@ networkStateInitialize(bool privileged,
     virNetworkObjListForEach(network_driver->networks,
                              networkUpdateState,
                              network_driver);
+    /* Before removing inactive transient networks from the list make sure we
+     * clean up after them as well */
+    virNetworkObjListForEach(network_driver->networks,
+                             networkCleanupTransientInactive,
+                             network_driver);
     virNetworkObjListPrune(network_driver->networks,
                            VIR_CONNECT_LIST_NETWORKS_INACTIVE |
                            VIR_CONNECT_LIST_NETWORKS_TRANSIENT);
-- 
2.46.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux