Re: [libvirt] [RFC] events scripts support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2010-03-23 at 12:12 +0000, Daniel P. Berrange wrote:
> I think it would be useful to have a libvirt-events daemon that
> listened
> for these async events via our public API & invoked scripts upon
> certain
> scenarios. This is obviously separate from the synchronous hooks.
> 

FWIW, a few days ago I wrote a small event watcher perl script based on
one of the test scripts in libvirt-perl to print out machine start and
stop events and the used interface name. The main program looks like
this:

######################
my $ev = Sys::Virt::Event::Simple->new();

my $conn = Sys::Virt->new(uri => $URI);

my @events;

$conn->domain_event_register(
    sub {
        my $con = shift;
        my $dom = shift;
        my $event = shift;
        my $detail = shift;

        printf("event handler: " . $con->get_uri() . ", " .
$dom->get_name() . ", $event, $detail\n");
        push @events, [$con, $dom, $event, $detail];
    });

while (1) {
    my $no_of_ev = int(@events);
    $ev->run_once();
    printf("no of ev : $no_of_ev \n" );
    printf("uri  : " . $events[$no_of_ev]->[0]->get_uri());
    printf("\n" );
    printf("name : " . $events[$no_of_ev]->[1]->get_name());
    printf("\n" );

    my $xmldesc = $events[$no_of_ev]->[1]->get_xml_description();
    my $ifname = get_ifname($xmldesc);
    print "ifname = $ifname\n";
    printf("\n" );
}


$conn->domain_event_deregister;

$conn = undef;
######################

Current output looks like this:

######################
event handler: qemu:///system, f12a, 2, 0
no of ev : 0 
uri  : qemu:///system
name : f12a
ifname = macvtap0

event handler: qemu:///system, f12, 5, 0
no of ev : 1 
uri  : qemu:///system
name : f12
ifname = macvtap1
######################

Having an architected events daemon in libvirt would certainly be a good
idea in my opinion.

-- 
Best regards, 

Gerhard Stenzel, 
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]