[libvirt] getting notified of events

Daniel P. Berrange berrange at redhat.com
Mon Oct 5 11:08:40 UTC 2009


On Thu, Oct 01, 2009 at 06:29:25PM +0200, Dan Kenigsberg wrote:
> I am trying to understand how to use the virEvent* API.
> I've built latest libvirt (with "Fix emission of domain events messages"
> commit) and run the domain-events example.
> 
> events-c gives me mostly silence. nothing is printed when a domain
> changes state.
> 
> events-python is more bizarre: it prints a line on every event - except
> for the first one, where "Updating Timeout 0 0
> Poll sleep 1" is printed. Only when the second event occurs, does the
> callback for the first event gets executed.
> 
> What am I missing?

I've just tested the current GIT repo with events, as follows and couldn't
reproduce the problem you describe.

 - Open 3 terminals
 - In first terminal run 
        ./daemon/libvirtd
 - In second terminal run  
        ./examples/domain-events/event-test qemu:///session
 - In third terminal use virsh to stop/start/etc a guest

    $ virsh start demo
    Domain demo started

    $ virsh suspend demo
    Domain demo suspended

    $ virsh resume demo
    Domain demo resumed

    $ virsh destroy demo
    Domain demo destroyed


 - Now back in the second terminal, it showed

    myDomainEventCallback1 EVENT: Domain demo(1) Started Booted
    myDomainEventCallback2 EVENT: Domain demo(1) Started Booted
    myDomainEventCallback1 EVENT: Domain demo(1) Suspended Paused
    myDomainEventCallback2 EVENT: Domain demo(1) Suspended Paused
    myDomainEventCallback1 EVENT: Domain demo(1) Resumed Unpaused
    myDomainEventCallback2 EVENT: Domain demo(1) Resumed Unpaused
    myDomainEventCallback1 EVENT: Domain demo(-1) Stopped Destroyed
    myDomainEventCallback2 EVENT: Domain demo(-1) Stopped Destroyed


NB, having 2 lines printed for each event is *delibrate* in the demo
program since it registered 2 callbacks

I saw the same results for the python demo program too

Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list