提交 7405aebe 编写于 作者: C Cole Robinson

libxl: Convert to virDomainEventState

上级 4d7297f8
无相关合并请求
...@@ -61,11 +61,7 @@ struct _libxlDriverPrivate { ...@@ -61,11 +61,7 @@ struct _libxlDriverPrivate {
virBitmapPtr reservedVNCPorts; virBitmapPtr reservedVNCPorts;
virDomainObjList domains; virDomainObjList domains;
/* A list of callbacks */ virDomainEventStatePtr domainEventState;
virDomainEventCallbackListPtr domainEventCallbacks;
virDomainEventQueuePtr domainEventQueue;
int domainEventTimer;
int domainEventDispatching;
char *configDir; char *configDir;
char *autostartDir; char *autostartDir;
......
...@@ -130,28 +130,11 @@ static void ...@@ -130,28 +130,11 @@ static void
libxlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque) libxlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
{ {
libxlDriverPrivatePtr driver = opaque; libxlDriverPrivatePtr driver = opaque;
virDomainEventQueue tempQueue;
libxlDriverLock(driver); libxlDriverLock(driver);
virDomainEventStateFlush(driver->domainEventState,
driver->domainEventDispatching = 1; libxmlDomainEventDispatchFunc,
driver);
/* Copy the queue, so we're reentrant safe */
tempQueue.count = driver->domainEventQueue->count;
tempQueue.events = driver->domainEventQueue->events;
driver->domainEventQueue->count = 0;
driver->domainEventQueue->events = NULL;
virEventUpdateTimeout(driver->domainEventTimer, -1);
virDomainEventQueueDispatch(&tempQueue,
driver->domainEventCallbacks,
libxlDomainEventDispatchFunc,
driver);
/* Purge any deleted callbacks */
virDomainEventCallbackListPurgeMarked(driver->domainEventCallbacks);
driver->domainEventDispatching = 0;
libxlDriverUnlock(driver); libxlDriverUnlock(driver);
} }
...@@ -159,10 +142,7 @@ libxlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque) ...@@ -159,10 +142,7 @@ libxlDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
static void static void
libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event) libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
{ {
if (virDomainEventQueuePush(driver->domainEventQueue, event) < 0) virDomainEventStateQueue(driver->domainEventState, event);
virDomainEventFree(event);
if (driver->domainEventQueue->count == 1)
virEventUpdateTimeout(driver->domainEventTimer, 0);
} }
/* /*
...@@ -706,12 +686,7 @@ libxlShutdown(void) ...@@ -706,12 +686,7 @@ libxlShutdown(void)
VIR_FREE(libxl_driver->libDir); VIR_FREE(libxl_driver->libDir);
VIR_FREE(libxl_driver->saveDir); VIR_FREE(libxl_driver->saveDir);
/* Free domain callback list */ virDomainEventStateFree(privconn->domainEventState);
virDomainEventCallbackListFree(libxl_driver->domainEventCallbacks);
virDomainEventQueueFree(libxl_driver->domainEventQueue);
if (libxl_driver->domainEventTimer != -1)
virEventRemoveTimeout(libxl_driver->domainEventTimer);
libxlDriverUnlock(libxl_driver); libxlDriverUnlock(libxl_driver);
virMutexDestroy(&libxl_driver->lock); virMutexDestroy(&libxl_driver->lock);
...@@ -822,16 +797,14 @@ libxlStartup(int privileged) { ...@@ -822,16 +797,14 @@ libxlStartup(int privileged) {
} }
VIR_FREE(log_file); VIR_FREE(log_file);
/* Init callback list */ libxl_driver->domainEventState = virDomainEventStateNew(
if (VIR_ALLOC(libxl_driver->domainEventCallbacks) < 0) libxlDomainEventFlush,
goto out_of_memory; libxml_driver,
if (!(libxl_driver->domainEventQueue = virDomainEventQueueNew())) NULL,
goto out_of_memory; false);
if ((libxl_driver->domainEventTimer = if (!libxml_driver->domainEventState)
virEventAddTimeout(-1, libxlDomainEventFlush, libxl_driver, NULL)) < 0)
goto error; goto error;
libxl_driver->logger = libxl_driver->logger =
(xentoollog_logger *)xtl_createlogger_stdiostream(libxl_driver->logger_file, XTL_DEBUG, 0); (xentoollog_logger *)xtl_createlogger_stdiostream(libxl_driver->logger_file, XTL_DEBUG, 0);
if (!libxl_driver->logger) { if (!libxl_driver->logger) {
...@@ -982,7 +955,8 @@ libxlClose(virConnectPtr conn ATTRIBUTE_UNUSED) ...@@ -982,7 +955,8 @@ libxlClose(virConnectPtr conn ATTRIBUTE_UNUSED)
libxlDriverPrivatePtr driver = conn->privateData; libxlDriverPrivatePtr driver = conn->privateData;
libxlDriverLock(driver); libxlDriverLock(driver);
virDomainEventCallbackListRemoveConn(conn, driver->domainEventCallbacks); virDomainEventCallbackListRemoveConn(conn,
driver->domainEventState->callbacks);
libxlDriverUnlock(driver); libxlDriverUnlock(driver);
conn->privateData = NULL; conn->privateData = NULL;
return 0; return 0;
...@@ -2224,7 +2198,8 @@ libxlDomainEventRegister(virConnectPtr conn, ...@@ -2224,7 +2198,8 @@ libxlDomainEventRegister(virConnectPtr conn,
int ret; int ret;
libxlDriverLock(driver); libxlDriverLock(driver);
ret = virDomainEventCallbackListAdd(conn, driver->domainEventCallbacks, ret = virDomainEventCallbackListAdd(conn,
driver->domainEventState->callbacks,
callback, opaque, freecb); callback, opaque, freecb);
libxlDriverUnlock(driver); libxlDriverUnlock(driver);
...@@ -2240,14 +2215,9 @@ libxlDomainEventDeregister(virConnectPtr conn, ...@@ -2240,14 +2215,9 @@ libxlDomainEventDeregister(virConnectPtr conn,
int ret; int ret;
libxlDriverLock(driver); libxlDriverLock(driver);
if (driver->domainEventDispatching) ret = virDomainEventStateDeregister(conn,
ret = virDomainEventCallbackListMarkDelete(conn, driver->domainEventState,
driver->domainEventCallbacks, callback);
callback);
else
ret = virDomainEventCallbackListRemove(conn,
driver->domainEventCallbacks,
callback);
libxlDriverUnlock(driver); libxlDriverUnlock(driver);
return ret; return ret;
...@@ -2648,7 +2618,8 @@ libxlDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, int eventID, ...@@ -2648,7 +2618,8 @@ libxlDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, int eventID,
int ret; int ret;
libxlDriverLock(driver); libxlDriverLock(driver);
ret = virDomainEventCallbackListAddID(conn, driver->domainEventCallbacks, ret = virDomainEventCallbackListAddID(conn,
driver->domainEventState->callbacks,
dom, eventID, callback, opaque, dom, eventID, callback, opaque,
freecb); freecb);
libxlDriverUnlock(driver); libxlDriverUnlock(driver);
...@@ -2664,14 +2635,9 @@ libxlDomainEventDeregisterAny(virConnectPtr conn, int callbackID) ...@@ -2664,14 +2635,9 @@ libxlDomainEventDeregisterAny(virConnectPtr conn, int callbackID)
int ret; int ret;
libxlDriverLock(driver); libxlDriverLock(driver);
if (driver->domainEventDispatching) ret = virDomainEventStateDeregisterAny(conn,
ret = virDomainEventCallbackListMarkDeleteID(conn, driver->domainEventState,
driver->domainEventCallbacks, callbackID);
callbackID);
else
ret = virDomainEventCallbackListRemoveID(conn,
driver->domainEventCallbacks,
callbackID);
libxlDriverUnlock(driver); libxlDriverUnlock(driver);
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部