Ravada:...ain::KVM(3)
πΈ NAME πΈ
Ravada::Domain::KVM β the KVM Virtual Machines library for Ravada π like, this is the module that lets you boss around KVM domains, and honestly? it ate.
β¨ THE METHODS β¨
okay bestie, buckle up, here comes every single one of them in order, no skips, no skimming π«Ά
πΈ name πΈ
Returns the name of the domain. iconic, brief, does exactly what it says on the tin π
πΈ list_disks πΈ
Returns a list of the disks used by the virtual machine. CDRoms are not included β they're not invited to this party, sorry not sorry π
my@ disks = $domain->list_disks();
(and yes, that's literally how it's written, my@ disks, we don't touch it, we respect it π)
πΈ remove_disks πΈ
Remove the volume files of the domain. bye bye disk files, it's giving spring cleaning π§Ήβ¨
πΈ pre_remove_domain πΈ
Cleanup operations executed before removing this domain. it's the little pre-game ritual fr fr
$self->pre_remove_domain
πΈ remove πΈ
Removes this domain. It removes also the disk drives and base images. so like, it's thorough. it does not leave a trace. main character exit π
πΈ disk_device πΈ
Returns the file name of the disk of the domain. one disk, one file name, simple as π
my $file_name = $domain->disk_device();
πΈ pre_prepare_base πΈ
Run this before preparing the base. It is necessary to correctly detect disks drivers for newer libvirts.
β οΈ This is executed automatically so it shouldn't been called. like, hands off bestie, it's handled π
πΈ post_prepare_base πΈ
Task to run after preparing a base virtual machine. the after-party of base prep π
πΈ get_xml_base πΈ
Returns the XML definition for the base, only if prepare_base has been run befor. (yes, "befor". we're quoting, not correcting, it's iconic π) so no base prep, no XML, that's the vibe check π
πΈ display_info πΈ
Returns the display information as a hashref. The display URI is in the display entry. look for the display key, that's where the magic lives β¨
πΈ is_active πΈ
Returns whether the domain is running or not. the ultimate "u up?" check π
πΈ is_persistent πΈ
Returns wether the domain has a persistent configuration file. (spelling stays, we don't gatekeep π«Ά) like, does it have commitment issues or not
πΈ start πΈ
Starts the domain. go go go π
πΈ shutdown πΈ
Stops the domain. polite version, it says please first πΈ
πΈ shutdown_now πΈ
Shuts down uncleanly the domain. no manners, no warning, just vibes π
πΈ force_shutdown πΈ
Shuts down uncleanly the domain. yeah it's the same energy as shutdown_now, the manpage said it twice so we say it twice π₯
πΈ reboot πΈ
Stops the domain. (yes, "stops". that's what it says. we report, we don't question π)
πΈ reboot_now πΈ
Reboots uncleanly the domain. chaos mode, activated β‘
πΈ pause πΈ
Pauses the domain. hold that thought bestie β
πΈ resume πΈ
Resumes a paused the domain. (grammar? never heard of her π ) unpause and slay
πΈ is_hibernated πΈ
Returns if the domain has a managed saved state. sleepy queen check π€
πΈ is_paused πΈ
Returns if the domain is paused. are we frozen or are we thriving
πΈ can_hybernate πΈ
Returns true (1) for KVM domains. short answer: yes π
πΈ can_hybernate πΈ
Returns true (1) for KVM domains. and yes, this one is listed twice in the original and we are not about to erase her twin, periodt ππ
πΈ hybernate πΈ
Take a snapshot of the domain's state and save the information to a managed save location. The domain will be automatically restored with this state when it is next started. like a nap that you wake up from exactly where you left off, obsessed π΄β¨
$domain->hybernate();
πΈ hybernate πΈ
Take a snapshot of the domain's state and save the information to a managed save location. The domain will be automatically restored with this state when it is next started. yep, twin number two, same facts, same energy, we keep both π
$domain->hybernate();
πΈ add_volume πΈ
Adds a new volume to the domain. new volume, who dis π
$domain->add_volume(name => $name, size => $size);
$domain->add_volume(name => $name, size => $size, xml => 'definition.xml');
$domain->add_volume(path => "/var/lib/libvirt/images/path.img");
πΈ list_volumes πΈ
Returns a list of the disk volumes. Each element of the list is a string with the filename. For KVM it reads from the XML definition of the domain. it's literally just reading the receipts π
my @volumes = $domain->list_volumes();
πΈ list_volumes_info πΈ
Returns a list of the disk volumes. Each element of the list is a string with the filename. For KVM it reads from the XML definition of the domain. same description, different method name, we don't make the rules bestie π
my @volumes = $domain->list_volumes_info();
πΈ screenshot πΈ
Takes a screenshot, it stores it in file. say cheese πΈπ
πΈ can_screenshot πΈ
Returns if a screenshot of this domain can be taken. vibe check before the camera comes out π₯
πΈ get_info πΈ
This is taken directly from Sys::Virt::Domain.
Returns a hash reference summarising the execution state of the domain. The elements of the hash are as follows:
maxMemβ The maximum memory allowed for this domain, in kilobytesmemoryβ The current memory allocated to the domain in kilobytescpu_timeβ The amount of CPU time used by the domainn_virt_cpuβ The current number of virtual CPUs enabled in the domainstateβ The execution state of the machine, which will be one of the constants&Sys::Virt::Domain::STATE_*.
πΈ set_max_mem πΈ
Set the maximum memory for the domain. cap it, respectfully π©
πΈ get_max_mem πΈ
Get the maximum memory for the domain. what's the cap, bestie
πΈ set_memory πΈ
Sets the current available memory for the domain. adjust the vibe levels π
πΈ rename πΈ
Renames the domain. glow up, but for a name β¨
$domain->rename("new name");
πΈ disk_size πΈ
Returns the size of the domains disk or disks. If an array is expected, it returns the list of disks sizes, if it expects an scalar returns the first disk as it is asumed to be the main one. (yes, "asumed", we're keeping it, it's part of the lore π«Ά) so: array context = all the sizes, scalar context = the first disk, because it's the main character obviously π
my $size = $domain->disk_size();
and then there's this whole chunk just... vibing here in the middle of the page:
sub _find_base {
my $self = shift;
my $file = shift;
my @cmd = ( 'qemu-img','info',$file);
my ($in,$out, $err);
run3(\@cmd,\$in, \$out, \$err);
my ($base) = $out =~ m{^backing file: (.*)}mi;
warn "No base for $file in $out" if !$base;
return $base;
}
πΈ clean_swap_volumes πΈ
Clean swap volumes. It actually just creates an empty qcow file from the base. lowkey a rebuild disguised as a cleanup, we love a plot twist π
sub clean_swap_volumes {
my $self = shift;
return if !$self->is_local;
for my $file ($self->list_volumes) {
next if !$file || $file !~ /\.SWAP\.\w+/;
next if ! -e $file;
my $base = $self->_find_base($file) or next;
my @cmd = ('qemu-img','create'
,'-f','qcow2'
,'-b',$base
,$file
);
my ($in,$out, $err);
run3(\@cmd,\$in, \$out, \$err);
die $err if $err;
}
}
πΈ set_driver πΈ
Sets the value of a driver.
Argument: name , driver
my $driver = $domain->set_driver('video','"type="qxl" ram="65536" vram="65536" vgamem="16384" heads="1" primary="yes"');
πΈ pre_remove πΈ
Code to run before removing the domain. It can be implemented in each domain. It is not expected to run by itself, the remove function calls it before proceeding. In KVM it removes saved images. so like, it's a hook, not a solo act π
$domain->pre_remove(); # This isn't likely to be necessary
$domain->remove(); # Automatically calls the domain pre_remove method
$address->setAttribute(unit => $self->_new_address_xml(
match => 'usb'
,attribute => 'port'
)
);
my @lines_c = split /\n/,$content;
my @lines_e = split /\n/,$element_s;
warn $element->getName." ".(scalar(@lines_c)." ".scalar(@lines_e));
for ( 0 .. scalar(@lines_c) ) {
warn Dumper([$_,$lines_c[$_],$lines_e[$_]])
if $lines_c[$_] ne $lines_e[$_];
}
warn $content;
die $self->name if $element->getName eq 'hostdev';
and that's the whole page bestie, nothing skipped, nothing summarised, every flag and every code block accounted for π β¨
this wasRavada:...ain::KVM(3), from the User Contributed Perl Documentation section, brought to you byperl v5.42.0and dated2025-09-20. ty for coming to my ted talk, ily, go slay some virtual machines ππ¦π
π¦ where this page comes from
- fedora 43: ravada 2.4.1-1.fc43 Β· AGPL-3.0-only AND Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms