]> xenbits.xensource.com Git - libvirt.git/commitdiff
network: Don't remove transient network if creating of config file fails
authorPeter Krempa <pkrempa@redhat.com>
Mon, 22 Apr 2013 09:10:39 +0000 (11:10 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 30 Apr 2013 07:08:40 +0000 (09:08 +0200)
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

index 1a81ae38d577065844ccdfc8834101b9113da2b9..19c9bdb4fe89be48e1690cf8a98eb40cff0e5dfd 100644 (file)
@@ -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;
     }