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

Matthias Bolte matthias.bolte at googlemail.com
Fri Apr 15 07:46:12 UTC 2011


2011/4/15 kadir yüceer <kadiryuceer at gmail.com>:
>
>
> 2011/4/14 Matthias Bolte <matthias.bolte at googlemail.com>
>>
>> 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
>
> First of all, thanks for the answer Matthias, I've been looking for help for
> some time.
>
> I had already tried your suggestion, I added the function just as the same
> way you did above, and I have this error:
>
> Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up
> function 'virEventRegisterDefaultImpl': /usr/local/lib/libvirt.so: undefined
> symbol: virEventRegisterDefaultImpl
>         at com.sun.jna.Function.<init>(Function.java:179)
>         at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:345)
>         at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:325)
>         at com.sun.jna.Library$Handler.invoke(Library.java:203)
>         at $Proxy0.virEventRegisterDefaultImpl(Unknown Source)
>         at novatest_v03.MainFrame.main(MainFrame.java:168)
>

virEventRegisterDefaultImpl was added in libvirt 0.9.0. Your libvirt
is probably too old.

Matthias




More information about the libvirt-users mailing list