[libvirt-users] virConnectDomainEventRegisterAny problem

Alexandr sss at sss.chaoslab.ru
Wed Aug 21 09:58:07 UTC 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

21.08.2013 12:39, Daniel P. Berrange пишет:
> On Wed, Aug 21, 2013 at 12:36:06PM +0300, Alexandr wrote:
>> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
>> 
>> 21.08.2013 09:46, Alexandr пишет:
>>> 21.08.2013 09:32, Martin Kletzander пишет:
>>>> On Wed 21 Aug 2013 01:03:37 AM CEST, Alexandr wrote:
>>>>> 
>>>>> good day. i trying to make callback function for 
>>>>> VIR_DOMAIN_EVENT_ID_LIFECYCLE, i have successfully
>>>>> registering callback, but it never called, i need to know
>>>>> when domain started, stopped or crashed, i have write
>>>>> following code
>>>>> 
>>>>> static int    domain_event_handler(virConnectPtr conn, 
>>>>> virDomainPtr dom, int event, int detail, void * opaque) { 
>>>>> switch(event) { } return 0; }
>>>>> 
>>>>> ..... int callback = 
>>>>> virConnectDomainEventRegisterAny(libvirt_connection, NULL,
>>>>>  VIR_DOMAIN_EVENT_ID_LIFECYCLE, 
>>>>> VIR_DOMAIN_EVENT_CALLBACK(domain_event_handler), NULL,
>>>>> NULL); if(callback == -1) { std::cout<<"Error: failed to
>>>>> register domain event handle callback\n"; return -1; }
>>>>> .....
>>>>> 
>>>>> 
>>>>> but "domain_event_handler" is never called, what is wrong
>>>>> here ?
>>> 
>>>> Are you running an event loop?  You can have a look at our 
>>>> examples [1] and see what's being done there.  Especially
>>>> note the virEventRunDefaultImpl() [2] there.
>>> 
>>>> Martin
>>> 
>>>> [1] 
>>>> http://libvirt.org/git/?p=libvirt.git;a=blob;f=examples/domain-events/events-c/event-test.c;h=52aa3d08d7326e422c12a8521717c3d55b2d8afd;hb=HEAD
>>>
>>>>
>>>
>>>
>>>> 
[2]
>>>> http://libvirt.org/git/?p=libvirt.git;a=blob;f=examples/domain-events/events-c/event-test.c;h=52aa3d08d7326e422c12a8521717c3d55b2d8afd;hb=HEAD#l611
>>>
>>>>
>>>
>>>
>>>> 
oh..., i missed it, thx for hint and sorry for stupid questions .
>> 
>> now it's working except for events from other connections, for
>> example i want to handle domain started by virt-manager, now i do
>> not have event when it's started, is exists any api to handle
>> this events, or i need to implement internal polling of domains
>> state in my application ?
> 
> The events system reports all lifecycle events, regardless of
> which connection triggered them.
> 
> If you're not seeing events from domains started by virt-manager
> then your almost certainly connecting to a different libvirt URI
> than virt-manager is using.
> 
> Daniel
> 
also looks like i do not receiving last event, i mean last event what
passed to callback is "eventcount - 1"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSFI8vAAoJEH3ap8veG8EHfmkH/1FKXCBGLTTzU8DN2DrvobDx
whVooW5J5Y4PBfSkKDqdERk+d5uxV2eWnobRxXVZCjDKk3M3Q6HztW5OvcMoGXM+
guGDok/Hp7n9XC17DnVbS4GpMSkaIcbpN6s8+PWu3r1nI7sX1o+YssT48a88XYjF
MtrMVOganILKHjQkoVmJAC22ajk89OnnPBkXwqrdUN1fxi7+SJpgPM/3UDyFoFEv
pwfMSHoKSaqlb99Q6ir2qom+bJKOfjez9xerHulIbYhYVW8vxTTceLGOQU++sN6i
EsH2LGVHggptOMPUom2zXo6+gOTVT1xp1VSYusKHCT8PobXUEJT8fEAnwKSoWWY=
=Lfmn
-----END PGP SIGNATURE-----




More information about the libvirt-users mailing list