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(a)redhat.com>
---
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