]> xenbits.xensource.com Git - libvirt.git/commitdiff
dom event example: init before register event impl
authorJesse J. Cook <jesse.j.cook@member.fsf.org>
Thu, 9 May 2013 21:17:43 +0000 (16:17 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 10 May 2013 09:21:08 +0000 (11:21 +0200)
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

index ede9796df4c0d4bbadf78b4f5f6ecd9a3e41ad2c..0f7be55600c1ad6aaadb3d4714fca9dacee1c111 100644 (file)
@@ -468,6 +468,11 @@ int main(int argc, char **argv)
         return -1;
     }
 
+    if (virInitialize() < 0) {
+        fprintf(stderr, "Failed to initialize libvirt");
+        return -1;
+    }
+
     virEventRegisterDefaultImpl();
 
     virConnectPtr dconn = NULL;