[PATCH 3/7] event: add API for requiring an event loop impl to be registered

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 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;
+}
+
 /**
  * virEventRegisterDefaultImpl:
  *
@@ -276,6 +299,8 @@ int virEventRegisterDefaultImpl(void)
 {
     VIR_DEBUG("registering default event implementation");
 
+    virInitialize();
+
     virResetLastError();
 
     if (virEventPollInit() < 0) {
diff --git a/src/util/virevent.h b/src/util/virevent.h
index 0b4f7d2b1b..6c8fdcbac4 100644
--- a/src/util/virevent.h
+++ b/src/util/virevent.h
@@ -21,3 +21,5 @@
 
 #pragma once
 #include "internal.h"
+
+int virEventRequireImpl(void);
-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux