Sys::V...ntImpl(3pm)
β¨ NAME β¨
Sys::Virt::EventImpl β Event loop implementation parent class. This is the Sys::Virt::EventImpl(3pm) manual, bestie, and it's giving βabstract parent class energyβ π
πΈ DESCRIPTION πΈ
The Sys::Virt::EventImpl module is literally the contract for integrating libvirt with an event loop. This package is abstract and is intended to be subclassed so you can provide an actual implementation. No cap.
This module is new in 9.5.0. To use this module while also supporting pre-9.5.0 versions, you could may consider the code below to set up inheritance:
package YourImpl;
use strict;
use warnings;
BEGIN {
if (require Sys::Virt::EventImpl) {
eval "use parent 'Sys::Virt::EventImpl';";
}
else {
eval "use parent 'Sys::Virt::Event';";
}
}
π EVENT LOOP IMPLEMENTATION π
When implementing an event loop, the implementation must be a sub-class of the Sys::Virt::EventImpl class. It must override these functions:
my $watch_id = $self->add_handle( $fd, $events, $callback, $opaque, $ff )β Registers$callbackto be invoked for$eventson$fd. Use_run_handle_callbackto do the actual invocation from the event loop (see βCallback helpersβ below). Next to the events explicitly indicated by$events,Sys::Virt::Event::HANDLE_ERRORandSys::Virt::Event::HANDLE_HANGUPshould always trigger the callback. Returns a positive integer$watch_idor-1on error.$self->update_handle($watch_id, $events)β Replaces the events currently triggering$watch_idwith$events.my $ret = $self->remove_handle($watch_id)β Removes the$callbackfrom the$fd. Returns0on success or-1on failure.
IMPORTANT β This should also make sure that _free_callback_opaque is called after this function has been executed: not doing so will prevent the connection from being garbage collected. π«Ά
my $timer_id = $self->add_timeout($frequency, $callback, $opaque, $ff)$self->update_timeout($timer_id, $frequency)β Replaces the interval on the timer with$frequency.my $ret = $self->remove_timeout($timer_id)β Discards the timer. Returns0on success or-1on failure.
IMPORTANT β This should also make sure that _free_callback_opaque is called after this function has been executed: not doing so will prevent the connection from being garbage collected. π«Ά
π§ Callback helpers π§
$self->_run_handle_callback($watch_id, $fd, $events, $cb, $opaque)β A helper method for executing a callback in response to one or more$eventson the file handle$fd. The$watchnumber is the unique identifier associated with the file descriptor. The$cband$opaqueparameters are the callback and data registered for the handle.$self->_run_timeout_callback($timer_id, $cb, $opaque)β A helper method for executing a callback in response to the expiry of a timeout identified by$timer. The$cband$opaqueparameters are the callback and data registered for the timeout.$self->_free_callback_opaque($ff, $opaque)β A helper method for freeing the data associated with a callback. The$ffand$opaqueparameters are the callback and data registered for the handle/timeout.
IMPORTANT β This helper must be called outside of any callbacks; that is after theremove_handleorremove_timeoutcallbacks complete. π¨
π AUTHORS π
Daniel P. Berrange <berrange@redhat.com>
π COPYRIGHT π
Copyright (C) 2006-2009 Red HatCopyright (C) 2006-2009 Daniel P. Berrange
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the terms of either the GNU General Public License as published by the Free Software Foundation (either version 2 of the License, or at your option any later version), or, the Artistic License, as specified in the Perl README file.
π₯ SEE ALSO π₯
Sys::Virt, "http://libvirt.org"
okay bestie, that's the whole manual β source/version perl v5.40.2, dated 2026-06-08, on the Sys::V...ntImpl(3pm) page. periodt πβ¨π¦
π¦ where this page comes from
- epel 10: perl-Sys-Virt 12.4.0-1.el10_3 Β· GPL-2.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms