On 10/29/2012 03:35 AM, Peter Krempa wrote:
When assigning the new persistent definition for a transient network
(thus making it persistent) the network needs to be marked persistent
before actually atempting to assign the definition.
---
src/network/bridge_driver.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
You might want to get Laine's opinion as well, but I think this is a
candidate for 1.0.0, and looks right to me.
ACK.
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 22bd99b..643b00c 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2820,7 +2820,7 @@ cleanup:
static virNetworkPtr networkDefine(virConnectPtr conn, const char *xml) {
struct network_driver *driver = conn->networkPrivateData;
- virNetworkDefPtr def;
+ virNetworkDefPtr def = NULL;
bool freeDef = true;
virNetworkObjPtr network = NULL;
virNetworkPtr ret = NULL;
@@ -2833,11 +2833,17 @@ static virNetworkPtr networkDefine(virConnectPtr conn, const char
*xml) {
if (networkValidate(driver, def, false) < 0)
goto cleanup;
- if (!(network = virNetworkAssignDef(&driver->networks, def, false)))
- goto cleanup;
- freeDef = false;
+ if ((network = virNetworkFindByName(&driver->networks, def->name))) {
+ network->persistent = 1;
+ if (virNetworkObjAssignDef(network, def, false) < 0)
+ goto cleanup;
+ } else {
+ if (!(network = virNetworkAssignDef(&driver->networks, def, false)))
+ goto cleanup;
+ }
- network->persistent = 1;
+ /* def was asigned */
+ freeDef = false;
if (virNetworkSaveConfig(driver->networkConfigDir, def) < 0) {
virNetworkRemoveInactive(&driver->networks, network);
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org