mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 03:21:44 +03:00
conf: virDomainObjListRemoveLocked function
While iterating with virDomainObjListForEach it is safe to remove current element. But while iterating, 'doms' lock is already taken, so can't use standard virDomainObjListRemove. So introduce virDomainObjListRemoveLocked for this purpose. Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
This commit is contained in:
parent
cdd703f475
commit
8f65fcb4a4
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -311,6 +311,7 @@ virDomainObjListLoadAllConfigs;
|
||||
virDomainObjListNew;
|
||||
virDomainObjListNumOfDomains;
|
||||
virDomainObjListRemove;
|
||||
virDomainObjListRemoveLocked;
|
||||
virDomainObjNew;
|
||||
virDomainObjSetDefTransient;
|
||||
virDomainObjSetState;
|
||||
|
Loading…
Reference in New Issue
Block a user