<br><br><div class="gmail_quote">2011/4/14 Matthias Bolte <span dir="ltr"><<a href="mailto:matthias.bolte@googlemail.com">matthias.bolte@googlemail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
2011/4/14 kadir yüceer <<a href="mailto:kadiryuceer@gmail.com">kadiryuceer@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hi all,<br>
><br>
> Quick question:<br>
> When the hypervisor triggers a callback which is registered for generic<br>
> events, (assuming I'm connected through qemu+tcp) where exactly is the<br>
> callback triggered? On the hypervisor host or on my host?<br>
><br>
> Regards<br>
> Kadir<br>
><br>
<br>
</div></div>The event system is more complex.<br>
<br>
The hypervisor/connection driver add events to a queue. The events<br>
from this queue are transported to the client and can trigger you<br>
registered callbacks.<br>
<br>
In order to have your callbacks called you need to register an "event<br>
implementation" that is responsible for driving the event delivery.<br>
Recent libvirt exposed it's default "event implementation" via<br>
virEventRegisterDefaultImpl().<br>
<br>
In order to have events delivered to your callbacks you need to call<br>
virEventRegisterDefaultImpl() or virEventRegisterImpl() with your own<br>
"event implementation".<br>
<br>
I assume you're still talking about the Java bindings here then you<br>
hit the problem that the bindings are incomplete and don't export<br>
virEventRegisterImpl() nor virEventRegisterDefaultImpl() yet. This<br>
means that the event related part of the libvirt API can not be used<br>
from the Java bindings yet.<br>
<br>
<br>
A totally untested patch to add virEventRegisterDefaultImpl() looks like this:<br>
<br>
<br>
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java<br>
b/src/main/java/org/libvirt/jna/Libvirt.java<br>
index 2c8c03d..5b73859 100644<br>
--- a/src/main/java/org/libvirt/jna/Libvirt.java<br>
+++ b/src/main/java/org/libvirt/jna/Libvirt.java<br>
@@ -373,4 +373,7 @@ public interface Libvirt extends Library {<br>
     public int virNWFilterGetUUID(NetworkFilterPointer<br>
virNWFilterPtr, byte[] uuidString);<br>
     public int virNWFilterGetUUIDString(NetworkFilterPointer<br>
virNWFilterPtr, byte[] uuidString);<br>
     public int virNWFilterUndefine(NetworkFilterPointer virNWFilterPtr);<br>
+<br>
+    // Event Methods<br>
+    public int virEventRegisterDefaultImpl(void);<br>
 }<br>
<br>
<br>
Then import org.libvirt.jna.Libvirt in your code and call:<br>
<br>
Libvirt.INSTANCE.virEventRegisterDefaultImpl()<br>
<br>
This _should_ register the default event implementation and make<br>
events work for you assuming the rest of your event related code is<br>
correct.<br>
<font color="#888888"><br>
Matthias<br></font></blockquote><div><br>First of all, thanks for the answer Matthias, I've been looking for help for some time.<br><br>I had already tried your suggestion, I added the function just as the same way you did above, and I have this error:<br>
<br>Exception in thread "main"<b> java.lang.UnsatisfiedLinkError: Error looking up function 'virEventRegisterDefaultImpl': /usr/local/lib/libvirt.so: undefined symbol: virEventRegisterDefaultImpl</b><br>
        at com.sun.jna.Function.<init>(Function.java:179)<br>        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:345)<br>        at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:325)<br>        at com.sun.jna.Library$Handler.invoke(Library.java:203)<br>
        at $Proxy0.virEventRegisterDefaultImpl(Unknown Source)<br>        at novatest_v03.MainFrame.main(MainFrame.java:168)<br></div></div><br>I did not post not go too technical. I have the feeling that I need to arrange one more step to satisfy the link to java bindings, because I've tested event-driving in C and it works fine. Since I could not figure out if I can do it on binding side or it should be done originally by the driver, I've posted my question.<br>
<br>So, any comments about how can I complete the link to C API? Maybe how to edit this "libvirt.so"?<br><br>Regards<br>Kadir<br><br>PS: Everything else works fine, libvirtd running, I can command to domains, etc. I can even register my own callback and register it via Connect.setErrorCallback(). I assume only missing thing is the link.<br>