
On 12/2/19 10:03 AM, Daniel P. Berrangé wrote:
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> --- po/POTFILES.in | 1 + src/util/virevent.c | 25 +++++++++++++++++++++++++ src/util/virevent.h | 2 ++ 3 files changed, 28 insertions(+)
diff --git a/po/POTFILES.in b/po/POTFILES.in index debb51cd70..b396797ff2 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -238,6 +238,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 diff --git a/src/util/virevent.c b/src/util/virevent.c index 3cac9f9472..a86acf64c0 100644 --- a/src/util/virevent.c +++ b/src/util/virevent.c @@ -29,6 +29,9 @@
VIR_LOG_INIT("util.event");
+ +#define VIR_FROM_THIS VIR_FROM_EVENT + static virEventAddHandleFunc addHandleImpl; static virEventUpdateHandleFunc updateHandleImpl; static virEventRemoveHandleFunc removeHandleImpl; @@ -251,6 +254,26 @@ 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_NO_SUPPORT, "%s", + _("An event loop implementation must be registered")); + return -1; + } + + return 0; +} +
I just noticed, maybe VIR_ERR_NO_SUPPORT isn't the best thing here, since this is more a client config issue if it didn't register an event loop impl - Cole