-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 ? -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSE/XIAAoJEH3ap8veG8EHNO4H/iu8FLlL2fXMrWC6Z75fgoL+ 1LKH504VD/oZ4UUyEMURdywNOp4cHmXQOiCbgN3ardFMjhFQ/hwbDHgBXLuQGsr0 yXyUoX8ft3sEojTJS0ys9J+vkFcqm/eOykCeAKRPHQPAeUivKQpRhx3+6mXDJ3z8 OyTGqD5GFdhgktz/4IbqeOp4PKI55QXVrrsB2414hPykBq6xsRqbtQC9QZ/Df2SP kHGAymEYK+i242xJYZSxTy5BLH+JNa1yzJNE+XoAtaMz2ypRg3ycMipo0io+8VMy KJWRxmq3O/ZKrqGsI++D7ugAkkLCLUbpyC35fXK7GXAEnxk/uTkQInU7F26FdJs=32hk -----END PGP SIGNATURE-----
Martin Kletzander
2013-Aug-21 06:32 UTC
Re: [libvirt-users] virConnectDomainEventRegisterAny problem
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
Alexandr
2013-Aug-21 06:46 UTC
Re: [libvirt-users] virConnectDomainEventRegisterAny problem
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 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 . -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.21 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSFGI9AAoJEH3ap8veG8EHl6QH/iHtRzwc/WRUTiPjvWTIVcKR wsTMByOqUE82A1pWScJJDF/C8+HTVb5dgF4sXH61TJT8mMu/h721oSv/mh3jMjwJ KUO5X/7h75RPVizLvUW6PofI4DWzSyJec73UG+4QIYyMs8en9D4C46QqVdXnnlVd yXGAAIV5y4BPPHV+QYaPp09oEqf+DnVhTrf14LjHOhUZF+6rO56n7fP9heOAXe5Z vhifJ0y8NiiAl1uGeEm4ty7rdw2geTZaSIo1EFVc7/j4Ejlb4+Bosg67aFlW+PmU gN5A08/l/9FnDk1qZL7twwc3+38CQr9n88hhZLaVs8sgm9R7VhQum8qMpSRS3oE=Xrdk -----END PGP SIGNATURE-----