[libvirt-users] Where actually is the callback triggered?

Matthias Bolte matthias.bolte at googlemail.com
Thu Apr 14 20:26:16 UTC 2011


2011/4/14 kadir yüceer <kadiryuceer at gmail.com>:
> Hi all,
>
> Quick question:
> When the hypervisor triggers a callback which is registered for generic
> events, (assuming I'm connected through qemu+tcp) where exactly is the
> callback triggered? On the hypervisor host or on my host?
>
> Regards
> Kadir
>

The event system is more complex.

The hypervisor/connection driver add events to a queue. The events
from this queue are transported to the client and can trigger you
registered callbacks.

In order to have your callbacks called you need to register an "event
implementation" that is responsible for driving the event delivery.
Recent libvirt exposed it's default "event implementation" via
virEventRegisterDefaultImpl().

In order to have events delivered to your callbacks you need to call
virEventRegisterDefaultImpl() or virEventRegisterImpl() with your own
"event implementation".

I assume you're still talking about the Java bindings here then you
hit the problem that the bindings are incomplete and don't export
virEventRegisterImpl() nor virEventRegisterDefaultImpl() yet. This
means that the event related part of the libvirt API can not be used
from the Java bindings yet.


A totally untested patch to add virEventRegisterDefaultImpl() looks like this:


diff --git a/src/main/java/org/libvirt/jna/Libvirt.java
b/src/main/java/org/libvirt/jna/Libvirt.java
index 2c8c03d..5b73859 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -373,4 +373,7 @@ public interface Libvirt extends Library {
     public int virNWFilterGetUUID(NetworkFilterPointer
virNWFilterPtr, byte[] uuidString);
     public int virNWFilterGetUUIDString(NetworkFilterPointer
virNWFilterPtr, byte[] uuidString);
     public int virNWFilterUndefine(NetworkFilterPointer virNWFilterPtr);
+
+    // Event Methods
+    public int virEventRegisterDefaultImpl(void);
 }


Then import org.libvirt.jna.Libvirt in your code and call:

Libvirt.INSTANCE.virEventRegisterDefaultImpl()

This _should_ register the default event implementation and make
events work for you assuming the rest of your event related code is
correct.

Matthias




More information about the libvirt-users mailing list