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

[libvirt] [PATCH 1/2] dom event example: init before register event impl

From: "Jesse J. Cook" <jesse j cook member fsf org>

In the domain-events example C code virEventRegisterDefaultImpl was being
called before virConnectOpen without first calling virInitialize. While this
code worked, it is incorrect. Adding a call to g_string_new prior to the call
to virEventRegisterDefaultImpl would cause the code to break. This fix will
help avoid unintentional misue of the API.

Relates to: Ret Hat Bugzilla - Bug 961155
 examples/domain-events/events-c/event-test.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index ede9796..09ec6aa 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -468,6 +468,12 @@ int main(int argc, char **argv)
         return -1;
+    if(0 != virInitialize()) {
+        virErrorPtr err = virGetLastError();
+        fprintf(stderr, "Failed to initialize: %s\n",
+                err && err->message ? err->message: "Unknown error");
+    }
     virConnectPtr dconn = NULL;

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