mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
event: add API for requiring an event loop impl to be registered
Reviewed-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
cccc3fc1bb
commit
2e07a1e146
@ -240,6 +240,7 @@
|
||||
@SRCDIR@/src/util/virdnsmasq.c
|
||||
@SRCDIR@/src/util/virerror.c
|
||||
@SRCDIR@/src/util/virerror.h
|
||||
@SRCDIR@/src/util/virevent.c
|
||||
@SRCDIR@/src/util/vireventpoll.c
|
||||
@SRCDIR@/src/util/virfcp.c
|
||||
@SRCDIR@/src/util/virfdstream.c
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "virlog.h"
|
||||
#include "virerror.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_EVENT
|
||||
|
||||
VIR_LOG_INIT("util.event");
|
||||
|
||||
@ -251,6 +252,27 @@ void virEventRegisterImpl(virEventAddHandleFunc addHandle,
|
||||
removeTimeoutImpl = removeTimeout;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virEventRequireImpl:
|
||||
*
|
||||
* Require that there is an event loop implementation
|
||||
* registered.
|
||||
*
|
||||
* Returns: -1 if no event loop is registered, 0 otherwise
|
||||
*/
|
||||
int virEventRequireImpl(void)
|
||||
{
|
||||
if (!addHandleImpl || !addTimeoutImpl) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("An event loop implementation must be registered"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virEventRegisterDefaultImpl:
|
||||
*
|
||||
@ -276,6 +298,8 @@ int virEventRegisterDefaultImpl(void)
|
||||
{
|
||||
VIR_DEBUG("registering default event implementation");
|
||||
|
||||
virInitialize();
|
||||
|
||||
virResetLastError();
|
||||
|
||||
if (virEventPollInit() < 0) {
|
||||
|
@ -21,3 +21,5 @@
|
||||
|
||||
#pragma once
|
||||
#include "internal.h"
|
||||
|
||||
int virEventRequireImpl(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user