From 8e9189001501558e237451d755a01008f5dfa561 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 22 Apr 2013 11:10:39 +0200 Subject: [PATCH] network: Don't remove transient network if creating of config file fails On the off-chance that creation of persistent configuration file would fail when defining a network that is already started as transient, the code would remove the transient data structure and thus the network. This patch changes the code so that in such case, the network is again marked as transient and left behind. --- src/network/bridge_driver.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 1a81ae38d5..19c9bdb4fe 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3160,8 +3160,14 @@ static virNetworkPtr networkDefineXML(virConnectPtr conn, const char *xml) { freeDef = false; if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) { - virNetworkRemoveInactive(&driver->networks, network); - network = NULL; + if (!virNetworkObjIsActive(network)) { + virNetworkRemoveInactive(&driver->networks, network); + network = NULL; + goto cleanup; + } + network->persistent = 0; + virNetworkDefFree(network->newDef); + network->newDef = NULL; goto cleanup; } -- 2.47.2