This patch alone does not make much sense, I know. But it
prepares ground for next patch which when looking up a network in
the object list will not lock each network separately when
accessing its definition. Therefore we must have all the places
changing network definition lock the list.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/network_conf.c | 9 ++++++++-
src/conf/network_conf.h | 3 ++-
src/network/bridge_driver.c | 4 ++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 3d318ce..007cebb 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -537,12 +537,19 @@ virNetworkObjSetDefTransient(virNetworkObjPtr network, bool live)
* This *undoes* what virNetworkObjSetDefTransient did.
*/
void
-virNetworkObjUnsetDefTransient(virNetworkObjPtr network)
+virNetworkObjUnsetDefTransient(virNetworkObjListPtr nets,
+ virNetworkObjPtr network)
{
if (network->newDef) {
+ virObjectRef(network);
+ virObjectUnlock(network);
+ virObjectLock(nets);
+ virObjectLock(network);
+ virObjectUnref(network);
virNetworkDefFree(network->def);
network->def = network->newDef;
network->newDef = NULL;
+ virObjectUnlock(nets);
}
}
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 3e926f7..c2e1885 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -323,7 +323,8 @@ void virNetworkObjAssignDef(virNetworkObjPtr network,
virNetworkDefPtr def,
bool live);
int virNetworkObjSetDefTransient(virNetworkObjPtr network, bool live);
-void virNetworkObjUnsetDefTransient(virNetworkObjPtr network);
+void virNetworkObjUnsetDefTransient(virNetworkObjListPtr nets,
+ virNetworkObjPtr network);
virNetworkDefPtr virNetworkObjGetPersistentDef(virNetworkObjPtr network);
int virNetworkObjReplacePersistentDef(virNetworkObjPtr network,
virNetworkDefPtr def);
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2eb225f..c112d50 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2415,7 +2415,7 @@ networkStartNetwork(virNetworkObjPtr network)
cleanup:
if (ret < 0) {
- virNetworkObjUnsetDefTransient(network);
+ virNetworkObjUnsetDefTransient(driver->networks, network);
virErrorPtr save_err = virSaveLastError();
int save_errno = errno;
networkShutdownNetwork(network);
@@ -2469,7 +2469,7 @@ static int networkShutdownNetwork(virNetworkObjPtr network)
VIR_HOOK_SUBOP_END);
network->active = 0;
- virNetworkObjUnsetDefTransient(network);
+ virNetworkObjUnsetDefTransient(driver->networks, network);
return ret;
}
--
2.0.5