network_conf: Introduce virNetworkObjEndAPI

This is practically copy of qemuDomObjEndAPI. The reason why is
it so widely available is to avoid code duplication, since the
function is going to be called from our bridge driver, test
driver and parallels driver too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2015-02-25 16:49:19 +01:00
parent ea57049156
commit aa7c7f880e
3 changed files with 16 additions and 6 deletions

View File

@ -129,6 +129,16 @@ virNetworkObjNew(void)
return NULL;
}
void
virNetworkObjEndAPI(virNetworkObjPtr *net)
{
if (!*net)
return;
virObjectUnlock(*net);
*net = NULL;
}
virNetworkObjListPtr virNetworkObjListNew(void)
{
virNetworkObjListPtr nets;
@ -3034,8 +3044,8 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
if (!virFileStripSuffix(entry->d_name, ".xml"))
continue;
if ((net = virNetworkLoadState(nets, stateDir, entry->d_name)))
virObjectUnlock(net);
net = virNetworkLoadState(nets, stateDir, entry->d_name);
virNetworkObjEndAPI(&net);
}
closedir(dir);
@ -3075,8 +3085,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
configDir,
autostartDir,
entry->d_name);
if (net)
virObjectUnlock(net);
virNetworkObjEndAPI(&net);
}
closedir(dir);
@ -4260,8 +4269,7 @@ virNetworkObjIsDuplicate(virNetworkObjListPtr nets,
}
cleanup:
if (net)
virObjectUnlock(net);
virNetworkObjEndAPI(&net);
return ret;
}

View File

@ -276,6 +276,7 @@ struct _virNetworkObj {
};
virNetworkObjPtr virNetworkObjNew(void);
void virNetworkObjEndAPI(virNetworkObjPtr *net);
typedef struct _virNetworkObjList virNetworkObjList;
typedef virNetworkObjList *virNetworkObjListPtr;

View File

@ -563,6 +563,7 @@ virNetworkIpDefPrefix;
virNetworkLoadAllConfigs;
virNetworkLoadAllState;
virNetworkObjAssignDef;
virNetworkObjEndAPI;
virNetworkObjFindByName;
virNetworkObjFindByUUID;
virNetworkObjGetPersistentDef;