[libvirt-users] virConnectDomainEventRegisterAny problem
Martin Kletzander
mkletzan at redhat.com
Wed Aug 21 06:32:27 UTC 2013
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
More information about the libvirt-users
mailing list