mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Introduce per-domain condition variable
Complex jobs, such as migration, need to monitor several events at once, which is impossible when each of the event uses its own condition variable. This patch adds a single condition variable to each domain object. This variable can be used instead of the other event specific conditions. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
355d8f470f
commit
e0713c4bed
@ -2509,6 +2509,7 @@ static void virDomainObjDispose(void *obj)
|
||||
virDomainObjPtr dom = obj;
|
||||
|
||||
VIR_DEBUG("obj=%p", dom);
|
||||
virCondDestroy(&dom->cond);
|
||||
virDomainDefFree(dom->def);
|
||||
virDomainDefFree(dom->newDef);
|
||||
|
||||
@ -2529,6 +2530,12 @@ virDomainObjNew(virDomainXMLOptionPtr xmlopt)
|
||||
if (!(domain = virObjectLockableNew(virDomainObjClass)))
|
||||
return NULL;
|
||||
|
||||
if (virCondInit(&domain->cond) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("failed to initialize domain condition"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (xmlopt->privateData.alloc) {
|
||||
if (!(domain->privateData = (xmlopt->privateData.alloc)()))
|
||||
goto error;
|
||||
@ -2651,6 +2658,46 @@ virDomainObjEndAPI(virDomainObjPtr *vm)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virDomainObjSignal(virDomainObjPtr vm)
|
||||
{
|
||||
virCondSignal(&vm->cond);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
virDomainObjBroadcast(virDomainObjPtr vm)
|
||||
{
|
||||
virCondBroadcast(&vm->cond);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virDomainObjWait(virDomainObjPtr vm)
|
||||
{
|
||||
if (virCondWait(&vm->cond, &vm->parent.lock) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("failed to wait for domain condition"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virDomainObjWaitUntil(virDomainObjPtr vm,
|
||||
unsigned long long whenms)
|
||||
{
|
||||
if (virCondWaitUntil(&vm->cond, &vm->parent.lock, whenms) < 0 &&
|
||||
errno != ETIMEDOUT) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("failed to wait for domain condition"));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* If flags & VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE then
|
||||
|
@ -2318,6 +2318,7 @@ typedef struct _virDomainObj virDomainObj;
|
||||
typedef virDomainObj *virDomainObjPtr;
|
||||
struct _virDomainObj {
|
||||
virObjectLockable parent;
|
||||
virCond cond;
|
||||
|
||||
pid_t pid;
|
||||
virDomainStateReason state;
|
||||
@ -2437,6 +2438,11 @@ void virDomainObjEndAPI(virDomainObjPtr *vm);
|
||||
bool virDomainObjTaint(virDomainObjPtr obj,
|
||||
virDomainTaintFlags taint);
|
||||
|
||||
void virDomainObjSignal(virDomainObjPtr vm);
|
||||
void virDomainObjBroadcast(virDomainObjPtr vm);
|
||||
int virDomainObjWait(virDomainObjPtr vm);
|
||||
int virDomainObjWaitUntil(virDomainObjPtr vm,
|
||||
unsigned long long whenms);
|
||||
|
||||
int virDomainDefCheckUnsupportedMemoryHotplug(virDomainDefPtr def);
|
||||
int virDomainDeviceDefCheckUnsupportedMemoryDevice(virDomainDeviceDefPtr dev);
|
||||
|
@ -380,6 +380,7 @@ virDomainNetTypeToString;
|
||||
virDomainNostateReasonTypeFromString;
|
||||
virDomainNostateReasonTypeToString;
|
||||
virDomainObjAssignDef;
|
||||
virDomainObjBroadcast;
|
||||
virDomainObjCopyPersistentDef;
|
||||
virDomainObjEndAPI;
|
||||
virDomainObjFormat;
|
||||
@ -409,8 +410,11 @@ virDomainObjParseNode;
|
||||
virDomainObjSetDefTransient;
|
||||
virDomainObjSetMetadata;
|
||||
virDomainObjSetState;
|
||||
virDomainObjSignal;
|
||||
virDomainObjTaint;
|
||||
virDomainObjUpdateModificationImpact;
|
||||
virDomainObjWait;
|
||||
virDomainObjWaitUntil;
|
||||
virDomainOSTypeFromString;
|
||||
virDomainOSTypeToString;
|
||||
virDomainParseMemory;
|
||||
|
Loading…
Reference in New Issue
Block a user