mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Expose event loop implementation as a public API
Not all applications have an existing event loop they need
to integrate with. Forcing them to implement the libvirt
event loop integration APIs is an undue burden. This just
exposes our simple poll() based implementation for apps
to use. So instead of calling
virEventRegister(....callbacks...)
The app would call
virEventRegisterDefaultImpl()
And then have a thread somewhere calling
static bool quit = false;
....
while (!quit)
virEventRunDefaultImpl()
* daemon/libvirtd.c, tools/console.c,
tools/virsh.c: Convert to public event loop APIs
* include/libvirt/libvirt.h.in, src/libvirt_private.syms: Add
virEventRegisterDefaultImpl and virEventRunDefaultImpl
* src/util/event.c: Implement virEventRegisterDefaultImpl
and virEventRunDefaultImpl using poll() event loop
* src/util/event_poll.c: Add full error reporting
* src/util/virterror.c, include/libvirt/virterror.h: Add
VIR_FROM_EVENTS
This commit is contained in:
@@ -893,8 +893,7 @@ static struct qemud_server *qemudInitialize(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virEventPollInit() < 0) {
|
||||
VIR_ERROR0(_("Failed to initialize event system"));
|
||||
if (virEventRegisterDefaultImpl() < 0) {
|
||||
virMutexDestroy(&server->lock);
|
||||
if (virCondDestroy(&server->job) < 0)
|
||||
{}
|
||||
@@ -957,13 +956,6 @@ static struct qemud_server *qemudInitialize(void) {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
virEventRegisterImpl(virEventPollAddHandle,
|
||||
virEventPollUpdateHandle,
|
||||
virEventPollRemoveHandle,
|
||||
virEventPollAddTimeout,
|
||||
virEventPollUpdateTimeout,
|
||||
virEventPollRemoveTimeout);
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
@@ -2283,7 +2275,7 @@ qemudDispatchServerEvent(int watch, int fd, int events, void *opaque) {
|
||||
static int qemudOneLoop(void) {
|
||||
sig_atomic_t errors;
|
||||
|
||||
if (virEventPollRunOnce() < 0)
|
||||
if (virEventRunDefaultImpl() < 0)
|
||||
return -1;
|
||||
|
||||
/* Check for any signal handling errors and log them. */
|
||||
|
||||
Reference in New Issue
Block a user