[libvirt-users] Sys::Virt integration into other event loops

Scott Wiersdorf scott at betterservers.com
Fri Mar 14 15:01:22 UTC 2014


Hi all,

I’m trying to integrate Perl’s Sys::Virt into an already existing AnyEvent program.

I’m accustomed to writing things like this:

use EV;
use AnyEvent;
use AnyEvent::Handle;
my $h = AnyEvent::Handle->new(fh => $fh, …);
$h->on_read(sub { … });

EV::run;  ## start the event loop

I can add some code in the on_read() handler and every time the $fh has something to read, it will fire off. I’d like to do something similar with Sys::Virt, but I can’t seem to wrap my head around its event system. The only examples I can find are the ones included in Sys::Virt source, which consist of a series of run_once() calls, or a while loop around run_default().

Does anyone have any idea how I can make this play nicely with an existing event loop such as EV, or even to fire off ($cv->send) an AnyEvent condvar when the event I set in domain_event_register_any() triggers?

Our current solution involves setting an AnyEvent->timer, which periodically fires off and then does a run_once() to see if any events happened during the period, but we’d like something more responsive (i.e., triggers when the event actually occurs) and less poll-y feeling.

I’d appreciate any advice you may have—thanks!

Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20140314/e902d13b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://listman.redhat.com/archives/libvirt-users/attachments/20140314/e902d13b/attachment.sig>


More information about the libvirt-users mailing list