This is going to be needed later, when some functions already have the virNetworkObjList object already locked and need to lookup a object to work on. As an example of such function is virNetworkAssignDef(). The other use case might be in virNetworkObjListForEach() callback. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/network_conf.c | 34 ++++++++++++++++++++++++++++++---- src/conf/network_conf.h | 4 ++++ src/libvirt_private.syms | 2 ++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 399c372..be5cf0e 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -164,8 +164,9 @@ virNetworkObjListPtr virNetworkObjListNew(void) return nets; } -virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets, - const unsigned char *uuid) +virNetworkObjPtr +virNetworkObjFindByUUIDLocked(virNetworkObjListPtr nets, + const unsigned char *uuid) { virNetworkObjPtr ret = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; @@ -178,6 +179,18 @@ virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets, return ret; } +virNetworkObjPtr +virNetworkObjFindByUUID(virNetworkObjListPtr nets, + const unsigned char *uuid) +{ + virNetworkObjPtr ret; + + virObjectLock(nets); + ret = virNetworkObjFindByUUIDLocked(nets, uuid); + virObjectUnlock(nets); + return ret; +} + static int virNetworkObjSearchName(const void *payload, const void *name ATTRIBUTE_UNUSED, @@ -193,8 +206,9 @@ virNetworkObjSearchName(const void *payload, return want; } -virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets, - const char *name) +virNetworkObjPtr +virNetworkObjFindByNameLocked(virNetworkObjListPtr nets, + const char *name) { virNetworkObjPtr ret = NULL; @@ -204,6 +218,18 @@ virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets, return ret; } +virNetworkObjPtr +virNetworkObjFindByName(virNetworkObjListPtr nets, + const char *name) +{ + virNetworkObjPtr ret; + + virObjectLock(nets); + ret = virNetworkObjFindByNameLocked(nets, name); + virObjectUnlock(nets); + return ret; +} + bool virNetworkObjTaint(virNetworkObjPtr obj, virNetworkTaintFlags taint) diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h index e0ed714..3e926f7 100644 --- a/src/conf/network_conf.h +++ b/src/conf/network_conf.h @@ -300,8 +300,12 @@ virNetworkObjIsActive(const virNetworkObj *net) virNetworkObjListPtr virNetworkObjListNew(void); +virNetworkObjPtr virNetworkObjFindByUUIDLocked(virNetworkObjListPtr nets, + const unsigned char *uuid); virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets, const unsigned char *uuid); +virNetworkObjPtr virNetworkObjFindByNameLocked(virNetworkObjListPtr nets, + const char *name); virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets, const char *name); bool virNetworkObjTaint(virNetworkObjPtr obj, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 5fbe094..64808ce 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -565,7 +565,9 @@ virNetworkLoadAllState; virNetworkObjAssignDef; virNetworkObjEndAPI; virNetworkObjFindByName; +virNetworkObjFindByNameLocked; virNetworkObjFindByUUID; +virNetworkObjFindByUUIDLocked; virNetworkObjGetPersistentDef; virNetworkObjIsDuplicate; virNetworkObjListExport; -- 2.0.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list