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

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

 



From: "Jesse J. Cook" <jesse.j.cook@xxxxxxxxxxxxxx>

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");
+    }
+
     virEventRegisterDefaultImpl();
 
     virConnectPtr dconn = NULL;
-- 
1.7.10.4

--
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]