mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: Use virDomainEventState helpers
v2: Drop libvirt_private.syms changes v3: Adjust for new virDomainEventStateNew argument
This commit is contained in:
parent
227d67ca00
commit
42a3687f29
@ -109,11 +109,7 @@ struct qemud_driver {
|
||||
|
||||
virCapsPtr caps;
|
||||
|
||||
/* An array of callbacks */
|
||||
virDomainEventCallbackListPtr domainEventCallbacks;
|
||||
virDomainEventQueuePtr domainEventQueue;
|
||||
int domainEventTimer;
|
||||
int domainEventDispatching;
|
||||
virDomainEventStatePtr domainEventState;
|
||||
|
||||
char *securityDriverName;
|
||||
virSecurityManagerPtr securityManager;
|
||||
|
@ -65,28 +65,11 @@ static void qemuDomainEventDispatchFunc(virConnectPtr conn,
|
||||
void qemuDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
|
||||
{
|
||||
struct qemud_driver *driver = opaque;
|
||||
virDomainEventQueue tempQueue;
|
||||
|
||||
qemuDriverLock(driver);
|
||||
|
||||
driver->domainEventDispatching = 1;
|
||||
|
||||
/* 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,
|
||||
virDomainEventStateFlush(driver->domainEventState,
|
||||
qemuDomainEventDispatchFunc,
|
||||
driver);
|
||||
|
||||
/* Purge any deleted callbacks */
|
||||
virDomainEventCallbackListPurgeMarked(driver->domainEventCallbacks);
|
||||
|
||||
driver->domainEventDispatching = 0;
|
||||
qemuDriverUnlock(driver);
|
||||
}
|
||||
|
||||
@ -95,11 +78,7 @@ void qemuDomainEventFlush(int timer ATTRIBUTE_UNUSED, void *opaque)
|
||||
void qemuDomainEventQueue(struct qemud_driver *driver,
|
||||
virDomainEventPtr event)
|
||||
{
|
||||
if (virDomainEventQueuePush(driver->domainEventQueue,
|
||||
event) < 0)
|
||||
virDomainEventFree(event);
|
||||
if (driver->domainEventQueue->count == 1)
|
||||
virEventUpdateTimeout(driver->domainEventTimer, 0);
|
||||
virDomainEventStateQueue(driver->domainEventState, event);
|
||||
}
|
||||
|
||||
|
||||
|
@ -393,14 +393,12 @@ qemudStartup(int privileged) {
|
||||
if (virDomainObjListInit(&qemu_driver->domains) < 0)
|
||||
goto out_of_memory;
|
||||
|
||||
/* Init callback list */
|
||||
if (VIR_ALLOC(qemu_driver->domainEventCallbacks) < 0)
|
||||
goto out_of_memory;
|
||||
if (!(qemu_driver->domainEventQueue = virDomainEventQueueNew()))
|
||||
goto out_of_memory;
|
||||
|
||||
if ((qemu_driver->domainEventTimer =
|
||||
virEventAddTimeout(-1, qemuDomainEventFlush, qemu_driver, NULL)) < 0)
|
||||
/* Init domain events */
|
||||
qemu_driver->domainEventState = virDomainEventStateNew(qemuDomainEventFlush,
|
||||
qemu_driver,
|
||||
NULL,
|
||||
true);
|
||||
if (!qemu_driver->domainEventState)
|
||||
goto error;
|
||||
|
||||
/* Allocate bitmap for vnc port reservation */
|
||||
@ -764,11 +762,7 @@ qemudShutdown(void) {
|
||||
}
|
||||
|
||||
/* Free domain callback list */
|
||||
virDomainEventCallbackListFree(qemu_driver->domainEventCallbacks);
|
||||
virDomainEventQueueFree(qemu_driver->domainEventQueue);
|
||||
|
||||
if (qemu_driver->domainEventTimer != -1)
|
||||
virEventRemoveTimeout(qemu_driver->domainEventTimer);
|
||||
virDomainEventStateFree(qemu_driver->domainEventState);
|
||||
|
||||
if (qemu_driver->brctl)
|
||||
brShutdown(qemu_driver->brctl);
|
||||
@ -856,7 +850,8 @@ static int qemudClose(virConnectPtr conn) {
|
||||
|
||||
/* Get rid of callbacks registered for this conn */
|
||||
qemuDriverLock(driver);
|
||||
virDomainEventCallbackListRemoveConn(conn, driver->domainEventCallbacks);
|
||||
virDomainEventCallbackListRemoveConn(conn,
|
||||
driver->domainEventState->callbacks);
|
||||
qemuDriverUnlock(driver);
|
||||
|
||||
conn->privateData = NULL;
|
||||
@ -5651,7 +5646,8 @@ qemuDomainEventRegister(virConnectPtr conn,
|
||||
int ret;
|
||||
|
||||
qemuDriverLock(driver);
|
||||
ret = virDomainEventCallbackListAdd(conn, driver->domainEventCallbacks,
|
||||
ret = virDomainEventCallbackListAdd(conn,
|
||||
driver->domainEventState->callbacks,
|
||||
callback, opaque, freecb);
|
||||
qemuDriverUnlock(driver);
|
||||
|
||||
@ -5667,11 +5663,8 @@ qemuDomainEventDeregister(virConnectPtr conn,
|
||||
int ret;
|
||||
|
||||
qemuDriverLock(driver);
|
||||
if (driver->domainEventDispatching)
|
||||
ret = virDomainEventCallbackListMarkDelete(conn, driver->domainEventCallbacks,
|
||||
callback);
|
||||
else
|
||||
ret = virDomainEventCallbackListRemove(conn, driver->domainEventCallbacks,
|
||||
ret = virDomainEventStateDeregister(conn,
|
||||
driver->domainEventState,
|
||||
callback);
|
||||
qemuDriverUnlock(driver);
|
||||
|
||||
@ -5692,7 +5685,7 @@ qemuDomainEventRegisterAny(virConnectPtr conn,
|
||||
|
||||
qemuDriverLock(driver);
|
||||
ret = virDomainEventCallbackListAddID(conn,
|
||||
driver->domainEventCallbacks,
|
||||
driver->domainEventState->callbacks,
|
||||
dom, eventID,
|
||||
callback, opaque, freecb);
|
||||
qemuDriverUnlock(driver);
|
||||
@ -5709,11 +5702,8 @@ qemuDomainEventDeregisterAny(virConnectPtr conn,
|
||||
int ret;
|
||||
|
||||
qemuDriverLock(driver);
|
||||
if (driver->domainEventDispatching)
|
||||
ret = virDomainEventCallbackListMarkDeleteID(conn, driver->domainEventCallbacks,
|
||||
callbackID);
|
||||
else
|
||||
ret = virDomainEventCallbackListRemoveID(conn, driver->domainEventCallbacks,
|
||||
ret = virDomainEventStateDeregisterAny(conn,
|
||||
driver->domainEventState,
|
||||
callbackID);
|
||||
qemuDriverUnlock(driver);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user