1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

Hide use of timers for domain event dispatch

Currently all drivers using domain events need to provide a callback
for handling a timer to dispatch events in a clean stack. There is
no technical reason for dispatch to go via driver specific code. It
could trivially be dispatched directly from the domain event code,
thus removing tedious boilerplate code from all drivers

Also fix the libxl & xen drivers to pass 'true' when creating the
virDomainEventState, since they run inside the daemon & thus always
expect events to be present.

* src/conf/domain_event.c, src/conf/domain_event.h: Internalize
  dispatch of events from timer callback
* src/libxl/libxl_driver.c, src/lxc/lxc_driver.c,
  src/qemu/qemu_domain.c, src/qemu/qemu_driver.c,
  src/remote/remote_driver.c, src/test/test_driver.c,
  src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
  src/xen/xen_driver.c: Remove all timer dispatch functions
This commit is contained in:
Daniel P. Berrange 2011-12-13 13:46:28 +00:00
parent 2c2d533768
commit 34ad13536e
12 changed files with 84 additions and 348 deletions

View File

@ -619,21 +619,26 @@ virDomainEventStateFree(virDomainEventStatePtr state)
VIR_FREE(state); VIR_FREE(state);
} }
static void virDomainEventStateFlush(virDomainEventStatePtr state);
static void
virDomainEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
{
virDomainEventStatePtr state = opaque;
virDomainEventStateFlush(state);
}
/** /**
* virDomainEventStateNew: * virDomainEventStateNew:
* @timeout_cb: virEventTimeoutCallback to call when timer expires
* @timeout_opaque: Data for timeout_cb
* @timeout_free: Optional virFreeCallback for freeing timeout_opaque
* @requireTimer: If true, return an error if registering the timer fails. * @requireTimer: If true, return an error if registering the timer fails.
* This is fatal for drivers that sit behind the daemon * This is fatal for drivers that sit behind the daemon
* (qemu, lxc), since there should always be a event impl * (qemu, lxc), since there should always be a event impl
* registered. * registered.
*/ */
virDomainEventStatePtr virDomainEventStatePtr
virDomainEventStateNew(virEventTimeoutCallback timeout_cb, virDomainEventStateNew(bool requireTimer)
void *timeout_opaque,
virFreeCallback timeout_free,
bool requireTimer)
{ {
virDomainEventStatePtr state = NULL; virDomainEventStatePtr state = NULL;
@ -659,9 +664,9 @@ virDomainEventStateNew(virEventTimeoutCallback timeout_cb,
} }
if ((state->timer = virEventAddTimeout(-1, if ((state->timer = virEventAddTimeout(-1,
timeout_cb, virDomainEventTimer,
timeout_opaque, state,
timeout_free)) < 0) { NULL)) < 0) {
if (requireTimer == false) { if (requireTimer == false) {
VIR_DEBUG("virEventAddTimeout failed: No addTimeoutImpl defined. " VIR_DEBUG("virEventAddTimeout failed: No addTimeoutImpl defined. "
"continuing without events."); "continuing without events.");
@ -1086,7 +1091,15 @@ virDomainEventQueuePush(virDomainEventQueuePtr evtQueue,
} }
void virDomainEventDispatchDefaultFunc(virConnectPtr conn, typedef void (*virDomainEventDispatchFunc)(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque);
static void
virDomainEventDispatchDefaultFunc(virConnectPtr conn,
virDomainEventPtr event, virDomainEventPtr event,
virConnectDomainEventGenericCallback cb, virConnectDomainEventGenericCallback cb,
void *cbopaque, void *cbopaque,
@ -1206,7 +1219,9 @@ static int virDomainEventDispatchMatchCallback(virDomainEventPtr event,
} }
} }
void virDomainEventDispatch(virDomainEventPtr event,
static void
virDomainEventDispatch(virDomainEventPtr event,
virDomainEventCallbackListPtr callbacks, virDomainEventCallbackListPtr callbacks,
virDomainEventDispatchFunc dispatch, virDomainEventDispatchFunc dispatch,
void *opaque) void *opaque)
@ -1230,7 +1245,8 @@ void virDomainEventDispatch(virDomainEventPtr event,
} }
void virDomainEventQueueDispatch(virDomainEventQueuePtr queue, static void
virDomainEventQueueDispatch(virDomainEventQueuePtr queue,
virDomainEventCallbackListPtr callbacks, virDomainEventCallbackListPtr callbacks,
virDomainEventDispatchFunc dispatch, virDomainEventDispatchFunc dispatch,
void *opaque) void *opaque)
@ -1266,10 +1282,25 @@ virDomainEventStateQueue(virDomainEventStatePtr state,
virDomainEventStateUnlock(state); virDomainEventStateUnlock(state);
} }
void
virDomainEventStateFlush(virDomainEventStatePtr state, static void
virDomainEventDispatchFunc dispatchFunc, virDomainEventStateDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque) void *opaque)
{
virDomainEventStatePtr state = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
virDomainEventStateUnlock(state);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
virDomainEventStateLock(state);
}
static void
virDomainEventStateFlush(virDomainEventStatePtr state)
{ {
virDomainEventQueue tempQueue; virDomainEventQueue tempQueue;
@ -1287,8 +1318,8 @@ virDomainEventStateFlush(virDomainEventStatePtr state,
virDomainEventQueueDispatch(&tempQueue, virDomainEventQueueDispatch(&tempQueue,
state->callbacks, state->callbacks,
dispatchFunc, virDomainEventStateDispatchFunc,
opaque); state);
/* Purge any deleted callbacks */ /* Purge any deleted callbacks */
virDomainEventStateLock(state); virDomainEventStateLock(state);
@ -1312,7 +1343,8 @@ virDomainEventStateFlush(virDomainEventStatePtr state,
* *
* Returns: the number of lifecycle callbacks now registered, or -1 on error * Returns: the number of lifecycle callbacks now registered, or -1 on error
*/ */
int virDomainEventStateRegister(virConnectPtr conn, int
virDomainEventStateRegister(virConnectPtr conn,
virDomainEventStatePtr state, virDomainEventStatePtr state,
virConnectDomainEventCallback callback, virConnectDomainEventCallback callback,
void *opaque, void *opaque,
@ -1342,7 +1374,8 @@ int virDomainEventStateRegister(virConnectPtr conn,
* *
* Returns: the number of callbacks now registered, or -1 on error * Returns: the number of callbacks now registered, or -1 on error
*/ */
int virDomainEventStateRegisterID(virConnectPtr conn, int
virDomainEventStateRegisterID(virConnectPtr conn,
virDomainEventStatePtr state, virDomainEventStatePtr state,
virDomainPtr dom, virDomainPtr dom,
int eventID, int eventID,

View File

@ -119,42 +119,12 @@ void virDomainEventFree(virDomainEventPtr event);
void virDomainEventStateFree(virDomainEventStatePtr state); void virDomainEventStateFree(virDomainEventStatePtr state);
virDomainEventStatePtr virDomainEventStatePtr
virDomainEventStateNew(virEventTimeoutCallback timeout_cb, virDomainEventStateNew(bool requireTimer);
void *timeout_opaque,
virFreeCallback timeout_free,
bool requireTimer)
ATTRIBUTE_NONNULL(1);
typedef void (*virDomainEventDispatchFunc)(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque);
void virDomainEventDispatchDefaultFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque);
void virDomainEventDispatch(virDomainEventPtr event,
virDomainEventCallbackListPtr cbs,
virDomainEventDispatchFunc dispatch,
void *opaque);
void virDomainEventQueueDispatch(virDomainEventQueuePtr queue,
virDomainEventCallbackListPtr cbs,
virDomainEventDispatchFunc dispatch,
void *opaque);
void void
virDomainEventStateQueue(virDomainEventStatePtr state, virDomainEventStateQueue(virDomainEventStatePtr state,
virDomainEventPtr event) virDomainEventPtr event)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
void
virDomainEventStateFlush(virDomainEventStatePtr state,
virDomainEventDispatchFunc dispatchFunc,
void *opaque)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int virDomainEventStateRegister(virConnectPtr conn, int virDomainEventStateRegister(virConnectPtr conn,
virDomainEventStatePtr state, virDomainEventStatePtr state,
virConnectDomainEventCallback callback, virConnectDomainEventCallback callback,

View File

@ -475,8 +475,6 @@ virDomainEventControlErrorNewFromDom;
virDomainEventControlErrorNewFromObj; virDomainEventControlErrorNewFromObj;
virDomainEventDiskChangeNewFromDom; virDomainEventDiskChangeNewFromDom;
virDomainEventDiskChangeNewFromObj; virDomainEventDiskChangeNewFromObj;
virDomainEventDispatch;
virDomainEventDispatchDefaultFunc;
virDomainEventFree; virDomainEventFree;
virDomainEventGraphicsNewFromDom; virDomainEventGraphicsNewFromDom;
virDomainEventGraphicsNewFromObj; virDomainEventGraphicsNewFromObj;
@ -499,7 +497,6 @@ virDomainEventStateDeregisterConn;
virDomainEventStateEventID; virDomainEventStateEventID;
virDomainEventStateRegister; virDomainEventStateRegister;
virDomainEventStateRegisterID; virDomainEventStateRegisterID;
virDomainEventStateFlush;
virDomainEventStateFree; virDomainEventStateFree;
virDomainEventStateNew; virDomainEventStateNew;
virDomainEventStateQueue; virDomainEventStateQueue;

View File

@ -111,30 +111,6 @@ libxlDomainObjPrivateFree(void *data)
VIR_FREE(priv); VIR_FREE(priv);
} }
static void
libxlDomainEventDispatchFunc(virConnectPtr conn, virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque, void *opaque)
{
libxlDriverPrivatePtr driver = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
libxlDriverUnlock(driver);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
libxlDriverLock(driver);
}
static void
libxlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
libxlDriverPrivatePtr driver = opaque;
libxlDriverLock(driver);
virDomainEventStateFlush(driver->domainEventState,
libxlDomainEventDispatchFunc,
driver);
libxlDriverUnlock(driver);
}
/* driver must be locked before calling */ /* driver must be locked before calling */
static void static void
@ -952,11 +928,7 @@ libxlStartup(int privileged) {
} }
VIR_FREE(log_file); VIR_FREE(log_file);
libxl_driver->domainEventState = virDomainEventStateNew( libxl_driver->domainEventState = virDomainEventStateNew(true);
libxlDomainEventFlush,
libxl_driver,
NULL,
false);
if (!libxl_driver->domainEventState) if (!libxl_driver->domainEventState)
goto error; goto error;

View File

@ -109,7 +109,6 @@ static void lxcDomainObjPrivateFree(void *data)
} }
static void lxcDomainEventFlush(int timer, void *opaque);
static void lxcDomainEventQueue(lxc_driver_t *driver, static void lxcDomainEventQueue(lxc_driver_t *driver,
virDomainEventPtr event); virDomainEventPtr event);
@ -2192,33 +2191,6 @@ lxcDomainEventDeregisterAny(virConnectPtr conn,
} }
static void lxcDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
lxc_driver_t *driver = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
lxcDriverUnlock(driver);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
lxcDriverLock(driver);
}
static void lxcDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
lxc_driver_t *driver = opaque;
lxcDriverLock(driver);
virDomainEventStateFlush(driver->domainEventState,
lxcDomainEventDispatchFunc,
driver);
lxcDriverUnlock(driver);
}
/* driver must be locked before calling */ /* driver must be locked before calling */
static void lxcDomainEventQueue(lxc_driver_t *driver, static void lxcDomainEventQueue(lxc_driver_t *driver,
virDomainEventPtr event) virDomainEventPtr event)
@ -2446,10 +2418,7 @@ static int lxcStartup(int privileged)
if (virDomainObjListInit(&lxc_driver->domains) < 0) if (virDomainObjListInit(&lxc_driver->domains) < 0)
goto cleanup; goto cleanup;
lxc_driver->domainEventState = virDomainEventStateNew(lxcDomainEventFlush, lxc_driver->domainEventState = virDomainEventStateNew(true);
lxc_driver,
NULL,
true);
if (!lxc_driver->domainEventState) if (!lxc_driver->domainEventState)
goto cleanup; goto cleanup;

View File

@ -114,31 +114,6 @@ qemuDomainAsyncJobPhaseFromString(enum qemuDomainAsyncJob job,
return -1; return -1;
} }
static void qemuDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
struct qemud_driver *driver = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
qemuDriverUnlock(driver);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
qemuDriverLock(driver);
}
void qemuDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
struct qemud_driver *driver = opaque;
qemuDriverLock(driver);
virDomainEventStateFlush(driver->domainEventState,
qemuDomainEventDispatchFunc,
driver);
qemuDriverUnlock(driver);
}
/* driver must be locked before calling */ /* driver must be locked before calling */
void qemuDomainEventQueue(struct qemud_driver *driver, void qemuDomainEventQueue(struct qemud_driver *driver,

View File

@ -431,10 +431,7 @@ qemudStartup(int privileged) {
goto out_of_memory; goto out_of_memory;
/* Init domain events */ /* Init domain events */
qemu_driver->domainEventState = virDomainEventStateNew(qemuDomainEventFlush, qemu_driver->domainEventState = virDomainEventStateNew(true);
qemu_driver,
NULL,
true);
if (!qemu_driver->domainEventState) if (!qemu_driver->domainEventState)
goto error; goto error;

View File

@ -145,7 +145,6 @@ static void make_nonnull_storage_vol (remote_nonnull_storage_vol *vol_dst, virSt
static void make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src); static void make_nonnull_secret (remote_nonnull_secret *secret_dst, virSecretPtr secret_src);
static void make_nonnull_nwfilter (remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src); static void make_nonnull_nwfilter (remote_nonnull_nwfilter *nwfilter_dst, virNWFilterPtr nwfilter_src);
static void make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src); static void make_nonnull_domain_snapshot (remote_nonnull_domain_snapshot *snapshot_dst, virDomainSnapshotPtr snapshot_src);
static void remoteDomainEventQueueFlush(int timer, void *opaque);
static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event); static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event);
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
@ -727,10 +726,7 @@ doRemoteOpen (virConnectPtr conn,
} }
} }
if (!(priv->domainEventState = virDomainEventStateNew(remoteDomainEventQueueFlush, if (!(priv->domainEventState = virDomainEventStateNew(false)))
conn,
NULL,
false)))
goto failed; goto failed;
/* Successful. */ /* Successful. */
@ -4352,37 +4348,6 @@ call (virConnectPtr conn,
} }
static void remoteDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
struct private_data *priv = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
remoteDriverUnlock(priv);
VIR_DEBUG("Dispatch event %p %p", event, conn);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
remoteDriverLock(priv);
}
static void
remoteDomainEventQueueFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
virConnectPtr conn = opaque;
struct private_data *priv = conn->privateData;
remoteDriverLock(priv);
VIR_DEBUG("Event queue flush %p", conn);
virDomainEventStateFlush(priv->domainEventState,
remoteDomainEventDispatchFunc,
priv);
remoteDriverUnlock(priv);
}
static void static void
remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event) remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
{ {

View File

@ -117,7 +117,6 @@ static const virNodeInfo defaultNodeInfo = {
__FUNCTION__, __LINE__, __VA_ARGS__) __FUNCTION__, __LINE__, __VA_ARGS__)
static int testClose(virConnectPtr conn); static int testClose(virConnectPtr conn);
static void testDomainEventFlush(int timer, void *opaque);
static void testDomainEventQueue(testConnPtr driver, static void testDomainEventQueue(testConnPtr driver,
virDomainEventPtr event); virDomainEventPtr event);
@ -1138,10 +1137,7 @@ static virDrvOpenStatus testOpen(virConnectPtr conn,
privconn = conn->privateData; privconn = conn->privateData;
testDriverLock(privconn); testDriverLock(privconn);
privconn->domainEventState = virDomainEventStateNew(testDomainEventFlush, privconn->domainEventState = virDomainEventStateNew(false);
privconn,
NULL,
false);
if (!privconn->domainEventState) { if (!privconn->domainEventState) {
testDriverUnlock(privconn); testDriverUnlock(privconn);
testClose(conn); testClose(conn);
@ -5469,32 +5465,6 @@ testDomainEventDeregisterAny(virConnectPtr conn,
} }
static void testDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
testConnPtr driver = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
testDriverUnlock(driver);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
testDriverLock(driver);
}
static void testDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
testConnPtr driver = opaque;
testDriverLock(driver);
virDomainEventStateFlush(driver->domainEventState,
testDomainEventDispatchFunc,
driver);
testDriverUnlock(driver);
}
/* driver must be locked before calling */ /* driver must be locked before calling */
static void testDomainEventQueue(testConnPtr driver, static void testDomainEventQueue(testConnPtr driver,
virDomainEventPtr event) virDomainEventPtr event)

View File

@ -124,7 +124,6 @@ static int umlOpenMonitor(struct uml_driver *driver,
virDomainObjPtr vm); virDomainObjPtr vm);
static int umlReadPidFile(struct uml_driver *driver, static int umlReadPidFile(struct uml_driver *driver,
virDomainObjPtr vm); virDomainObjPtr vm);
static void umlDomainEventFlush(int timer, void *opaque);
static void umlDomainEventQueue(struct uml_driver *driver, static void umlDomainEventQueue(struct uml_driver *driver,
virDomainEventPtr event); virDomainEventPtr event);
@ -414,10 +413,7 @@ umlStartup(int privileged)
if (virDomainObjListInit(&uml_driver->domains) < 0) if (virDomainObjListInit(&uml_driver->domains) < 0)
goto error; goto error;
uml_driver->domainEventState = virDomainEventStateNew(umlDomainEventFlush, uml_driver->domainEventState = virDomainEventStateNew(true);
uml_driver,
NULL,
true);
if (!uml_driver->domainEventState) if (!uml_driver->domainEventState)
goto error; goto error;
@ -2511,33 +2507,6 @@ umlDomainEventDeregisterAny(virConnectPtr conn,
} }
static void umlDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
struct uml_driver *driver = opaque;
/* Drop the lock whle dispatching, for sake of re-entrancy */
umlDriverUnlock(driver);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
umlDriverLock(driver);
}
static void umlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
struct uml_driver *driver = opaque;
umlDriverLock(driver);
virDomainEventStateFlush(driver->domainEventState,
umlDomainEventDispatchFunc,
driver);
umlDriverUnlock(driver);
}
/* driver must be locked before calling */ /* driver must be locked before calling */
static void umlDomainEventQueue(struct uml_driver *driver, static void umlDomainEventQueue(struct uml_driver *driver,
virDomainEventPtr event) virDomainEventPtr event)

View File

@ -970,46 +970,6 @@ static void vboxUninitialize(vboxGlobalData *data) {
} }
#if VBOX_API_VERSION == 2002
/* No domainEventCallbacks in 2.2.* version */
#else /* !(VBOX_API_VERSION == 2002) */
static void
vboxDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
vboxGlobalData *data = opaque;
/*
* Release the lock while the callback is running so that
* we're re-entrant safe for callback work - the callback
* may want to invoke other virt functions & we have already
* protected the one piece of state we have - the callback
* list
*/
vboxDriverUnlock(data);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
vboxDriverLock(data);
}
static void vboxDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
virConnectPtr conn = opaque;
vboxGlobalData *data = conn->privateData;
vboxDriverLock(data);
virDomainEventStateFlush(data->domainEvents,
vboxDomainEventDispatchFunc,
data);
vboxDriverUnlock(data);
}
#endif /* !(VBOX_API_VERSION == 2002) */
static virDrvOpenStatus vboxOpen(virConnectPtr conn, static virDrvOpenStatus vboxOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED, virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags) unsigned int flags)
@ -1074,10 +1034,7 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn,
#else /* !(VBOX_API_VERSION == 2002) */ #else /* !(VBOX_API_VERSION == 2002) */
if (!(data->domainEvents = virDomainEventStateNew(vboxDomainEventFlush, if (!(data->domainEvents = virDomainEventStateNew(true))) {
data,
NULL,
true))) {
vboxUninitialize(data); vboxUninitialize(data);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }

View File

@ -63,7 +63,6 @@ static int
xenUnifiedDomainGetVcpus (virDomainPtr dom, xenUnifiedDomainGetVcpus (virDomainPtr dom,
virVcpuInfoPtr info, int maxinfo, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen); unsigned char *cpumaps, int maplen);
static void xenDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque);
/* The five Xen drivers below us. */ /* The five Xen drivers below us. */
@ -326,10 +325,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags)
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
} }
if (!(priv->domainEvents = virDomainEventStateNew(xenDomainEventFlush, if (!(priv->domainEvents = virDomainEventStateNew(true))) {
priv,
NULL,
false))) {
virMutexDestroy(&priv->lock); virMutexDestroy(&priv->lock);
VIR_FREE(priv); VIR_FREE(priv);
return VIR_DRV_OPEN_ERROR; return VIR_DRV_OPEN_ERROR;
@ -2388,40 +2384,6 @@ xenUnifiedRemoveDomainInfo(xenUnifiedDomainInfoListPtr list,
} }
static void
xenUnifiedDomainEventDispatchFunc(virConnectPtr conn,
virDomainEventPtr event,
virConnectDomainEventGenericCallback cb,
void *cbopaque,
void *opaque)
{
xenUnifiedPrivatePtr priv = opaque;
/*
* Release the lock while the callback is running so that
* we're re-entrant safe for callback work - the callback
* may want to invoke other virt functions & we have already
* protected the one piece of state we have - the callback
* list
*/
xenUnifiedUnlock(priv);
virDomainEventDispatchDefaultFunc(conn, event, cb, cbopaque, NULL);
xenUnifiedLock(priv);
}
static void xenDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{
virConnectPtr conn = opaque;
xenUnifiedPrivatePtr priv = conn->privateData;
xenUnifiedLock(priv);
virDomainEventStateFlush(priv->domainEvents,
xenUnifiedDomainEventDispatchFunc,
priv);
xenUnifiedUnlock(priv);
}
/** /**
* xenUnifiedDomainEventDispatch: * xenUnifiedDomainEventDispatch:
* @priv: the connection to dispatch events on * @priv: the connection to dispatch events on