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:
Marek Marczykowski-Górecki 2013-06-13 03:54:08 +02:00 committed by Jim Fehlig
parent cdd703f475
commit 8f65fcb4a4
3 changed files with 20 additions and 0 deletions

View File

@ -2343,6 +2343,23 @@ void virDomainObjListRemove(virDomainObjListPtr doms,
virObjectUnlock(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 static int
virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr) virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr)
{ {

View File

@ -2260,6 +2260,8 @@ virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom,
void virDomainObjListRemove(virDomainObjListPtr doms, void virDomainObjListRemove(virDomainObjListPtr doms,
virDomainObjPtr dom); virDomainObjPtr dom);
void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
virDomainObjPtr dom);
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
virDomainDefPtr def, virDomainDefPtr def,

View File

@ -311,6 +311,7 @@ virDomainObjListLoadAllConfigs;
virDomainObjListNew; virDomainObjListNew;
virDomainObjListNumOfDomains; virDomainObjListNumOfDomains;
virDomainObjListRemove; virDomainObjListRemove;
virDomainObjListRemoveLocked;
virDomainObjNew; virDomainObjNew;
virDomainObjSetDefTransient; virDomainObjSetDefTransient;
virDomainObjSetState; virDomainObjSetState;