This patch -Removes EventImpl from being a private function -Introduces the virDomainEventCallbackListPtr, and virDomainEventQueuePtr objects proxy/Makefile.am | 1 src/event.c | 12 +++++----- src/event.h | 37 ------------------------------- src/internal.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 42 deletions(-)
diff --git a/proxy/Makefile.am b/proxy/Makefile.am index 5902cab..75ba6b4 100644 --- a/proxy/Makefile.am +++ b/proxy/Makefile.am @@ -17,6 +17,7 @@ libvirt_proxy_SOURCES = libvirt_proxy.c @top_srcdir@/src/xend_internal.c \ @top_srcdir@/src/memory.c \ @top_srcdir@/src/domain_conf.c \ @top_srcdir@/src/util.c \ + @top_srcdir@/src/event.c \ @top_srcdir@/src/uuid.c libvirt_proxy_LDFLAGS = $(WARN_CFLAGS) libvirt_proxy_DEPENDENCIES = diff --git a/src/event.c b/src/event.c index 49a9e61..7ce70ec 100644 --- a/src/event.c +++ b/src/event.c @@ -70,12 +70,12 @@ int virEventRemoveTimeout(int timer) { return removeTimeoutImpl(timer); } -void __virEventRegisterImpl(virEventAddHandleFunc addHandle, - virEventUpdateHandleFunc updateHandle, - virEventRemoveHandleFunc removeHandle, - virEventAddTimeoutFunc addTimeout, - virEventUpdateTimeoutFunc updateTimeout, - virEventRemoveTimeoutFunc removeTimeout) { +void virEventRegisterImpl(virEventAddHandleFunc addHandle, + virEventUpdateHandleFunc updateHandle, + virEventRemoveHandleFunc removeHandle, + virEventAddTimeoutFunc addTimeout, + virEventUpdateTimeoutFunc updateTimeout, + virEventRemoveTimeoutFunc removeTimeout) { addHandleImpl = addHandle; updateHandleImpl = updateHandle; removeHandleImpl = removeHandle; diff --git a/src/event.h b/src/event.h index 758573c..fbff0e8 100644 --- a/src/event.h +++ b/src/event.h @@ -23,17 +23,7 @@ #ifndef __VIR_EVENT_H__ #define __VIR_EVENT_H__ - - -/** - * virEventHandleCallback: callback for receiving file handle events - * - * @fd: file handle on which the event occurred - * @events: bitset of events from POLLnnn constants - * @opaque: user data registered with handle - */ -typedef void (*virEventHandleCallback)(int fd, int events, void *opaque); - +#include "internal.h" /** * virEventAddHandle: register a callback for monitoring file handle events * @@ -66,14 +56,6 @@ void virEventUpdateHandle(int fd, int events); int virEventRemoveHandle(int fd); /** - * virEventTimeoutCallback: callback for receiving timer events - * - * @timer: timer id emitting the event - * @opaque: user data registered with handle - */ -typedef void (*virEventTimeoutCallback)(int timer, void *opaque); - -/** * virEventAddTimeout: register a callback for a timer event * * @frequency: time between events in milliseconds @@ -110,21 +92,4 @@ void virEventUpdateTimeout(int timer, int frequency); */ int virEventRemoveTimeout(int timer); -typedef int (*virEventAddHandleFunc)(int, int, virEventHandleCallback, void *); -typedef void (*virEventUpdateHandleFunc)(int, int); -typedef int (*virEventRemoveHandleFunc)(int); - -typedef int (*virEventAddTimeoutFunc)(int, virEventTimeoutCallback, void *); -typedef void (*virEventUpdateTimeoutFunc)(int, int); -typedef int (*virEventRemoveTimeoutFunc)(int); - -void __virEventRegisterImpl(virEventAddHandleFunc addHandle, - virEventUpdateHandleFunc updateHandle, - virEventRemoveHandleFunc removeHandle, - virEventAddTimeoutFunc addTimeout, - virEventUpdateTimeoutFunc updateTimeout, - virEventRemoveTimeoutFunc removeTimeout); - -#define virEventRegisterImpl(ah,rh,at,rt) __virEventRegisterImpl(ah,rh,at,rt) - #endif /* __VIR_EVENT_H__ */ diff --git a/src/internal.h b/src/internal.h index 2ae764d..e996eea 100644 --- a/src/internal.h +++ b/src/internal.h @@ -383,4 +383,67 @@ char *virStringListJoin(const virStringList *list, const char *pre, const char *post, const char *sep); void virStringListFree(virStringList *list); +/** + * Domain Event Notification + */ + +struct _virDomainEventCallback { + virConnectPtr conn; + virConnectDomainEventCallback cb; + void *opaque; +}; +typedef struct _virDomainEventCallback virDomainEventCallback; +typedef virDomainEventCallback *virDomainEventCallbackPtr; + +struct _virDomainEventCallbackList { + unsigned int count; + virDomainEventCallbackPtr *callbacks; +}; +typedef struct _virDomainEventCallbackList virDomainEventCallbackList; +typedef virDomainEventCallbackList *virDomainEventCallbackListPtr; + +void __virDomainEventCallbackListFree(virDomainEventCallbackListPtr list); +#define virDomainEventCallbackListFree(x) __virDomainEventCallbackListFree(x) + +int __virDomainEventCallbackListAdd(virConnectPtr conn, + virDomainEventCallbackListPtr cbList, + virConnectDomainEventCallback callback, + void *opaque); +#define virDomainEventCallbackListAdd(a,b,c,d) __virDomainEventCallbackListAdd((a),(b),(c),(d)) + +int __virDomainEventCallbackListRemove(virConnectPtr conn, + virDomainEventCallbackListPtr cbList, + virConnectDomainEventCallback callback); +#define virDomainEventCallbackListRemove(a,b,c) __virDomainEventCallbackListRemove((a),(b),(c)) + +void virDispatchDomainEvent(virDomainPtr dom, int event); + +/** + * Dispatching domain events that come in while + * in a call / response rpc + */ +struct _virDomainEvent { + virDomainPtr dom; + virDomainEventType event; + virConnectDomainEventCallback cb; + void *opaque; +}; +typedef struct _virDomainEvent virDomainEvent; +typedef virDomainEvent *virDomainEventPtr; + +struct _virDomainEventQueue { + unsigned int count; + virDomainEventPtr *events; +}; +typedef struct _virDomainEventQueue virDomainEventQueue; +typedef virDomainEventQueue *virDomainEventQueuePtr; + +int virDomainEventCallbackQueuePush(virDomainEventQueuePtr evtQueue, + virDomainPtr dom, + virDomainEventType event, + virConnectDomainEventCallback cb, + void *opaque ); +virDomainEventPtr virDomainEventCallbackQueuePop(virDomainEventQueuePtr evtQueue); +void virDomainEventQueueFree(virDomainEventQueuePtr queue); + #endif /* __VIR_INTERNAL_H__ */
-- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list