diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bb0faf52d8..f80b69074f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2343,6 +2343,23 @@ void virDomainObjListRemove(virDomainObjListPtr doms, virObjectUnlock(doms); } +/* The caller must hold lock on 'doms' in addition to 'virDomainObjListRemove' + * requirements + * + * Can be used to remove current element while iterating with + * virDomainObjListForEach + */ +void virDomainObjListRemoveLocked(virDomainObjListPtr doms, + virDomainObjPtr dom) +{ + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virUUIDFormat(dom->def->uuid, uuidstr); + virObjectUnlock(dom); + + virHashRemoveEntry(doms->objs, uuidstr); +} + static int virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 7200062232..da83eb6060 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2260,6 +2260,8 @@ virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); +void virDomainObjListRemoveLocked(virDomainObjListPtr doms, + virDomainObjPtr dom); virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 0881af43ad..6df55005e9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -311,6 +311,7 @@ virDomainObjListLoadAllConfigs; virDomainObjListNew; virDomainObjListNumOfDomains; virDomainObjListRemove; +virDomainObjListRemoveLocked; virDomainObjNew; virDomainObjSetDefTransient; virDomainObjSetState;