Sys-Virt-1.2.1/0000755000076500007650000000000012267462221013365 5ustar berrangeberrangeSys-Virt-1.2.1/HACKING0000644000076500007650000000045212267462203014355 0ustar berrangeberrange Hacking on libvirt perl ======================= After each libvirt release: - Look at src/libvirt_public.syms and find any new APIs introduced - Look at include/libvirt/virterror.h and find any new VIR_FROM_XXX and VIR_ERR_XXX constants - Look for any new constants in libvirt.h.inSys-Virt-1.2.1/Changes0000644000076500007650000001657412267462203014675 0ustar berrangeberrangeRevision history for perl module Sys::Virt 1.2.1 2014-01-21 - Add new network event APIs from libvirt 1.2.1 - Add new constants in libvirt 1.2.1 1.2.0 2013-12-02 - Add all new constants in libvirt 1.2.0 - Fix reversed args for virNodeDeviceLookupSCSIHostByWWN 1.1.4 2013-11-05 - Add all new constants in libvirt 1.1.4 - Fix impl of "list_secrets" API (RT #82072) 1.1.3 2013-10-02 - Add all new APIs in libvirt 1.1.3 1.1.2 2013-09-27 - Add all new constants in libvirt 1.1.2 1.1.1 2013-07-30 - Add all new constants/apis in libvirt 1.1.1 1.1.0 2013-07-29 - Add support for v3 of migration APIs - Add all new constants in libvirt 1.1.0 - Fix handling of sparse typed parameters - Fix misc typos in docs 1.0.5 2013-05-14 - Add all new APIs in libvirt 1.0.4 and 1.0.5 1.0.3 2013-03-05 - Add all new APIs in libvirt 1.0.3 1.0.2 2013-02-27 - Add all new APIs in libvirt 1.0.2 1.0.1 2013-02-26 - Add all new APIs and constants in libvirt 1.0.1 - Fix typo preventing listing of NWFilters - Add more testing of object list APIs - Fix some incorrect error handling tests in binding - Remove bogus compare < 0 for size_t variables - Fix const-ness of functions for populating constants - Add option to turn on more GCC warning flags - Fix typos in POD docs 1.0.0 2012-11-16 - Add all new APIs and constants in libvirt 1.0.0 - Fix inconsistent usage of 'uri' in Sys::Virt POD docs - Fix typos in POD docs - Don't explicitly set VIR_TYPED_PARAM_STRING_OKAY flag - Fix hash key field lengths - Add tests for object list APIs - Fix default values for flags parameters - Fix setting of node memory parameters 0.10.2 2012-09-26 - Add all new APIs and constants in libvirt 0.10.2 - Add some constants for macros in libvirt.h related to memory/block/cpu/scheduler parametes - Fix warnings building on Perl with 64 int types - Disable unreliable hostname test case 0.10.0 2012-09-17 - Add all new APIs and constants in libvirt 0.10.0 - Add example program showing use of event callbacks - Fix crash when registering event callback with 'undef' for the domain parameter - Fix typos in the definition of some docs 0.9.13 2012-07-02 - Add all new APIs and constants in libvirt 0.9.13 0.9.12 2012-05-21 - Add all new constants in libvirt 0.9.12 0.9.11 2012-04-16 - Add all new APIs in libvirt 0.9.11 - Add test case to validate API coverage - Fix misc POD docs bugs - Fix reference handling in block stats - Add handling of VIR_TYPED_PARAM_STRING 0.9.10 2012-02-12 - Add all new APIs in libvirt 0.9.10 - Add some constants missing from previous releases - Clarify docs for shutdown/destroy APIs (rt #73908) 0.9.9 2012-01-09 - Add all new APIs in libvirt 0.9.9 - Fix crash in get_hostname - Fix docs typos & nesting screwups - Add example for calculating CPU utilization of host - Update META.yml with correct license info - Add missing dep on Time::HiRes - Convert CHANGES file to Changes & format to comply with Test::CPAN::Changes 0.9.8 2012-01-03 - Add all new APIs in libvirt 0.9.8 - Simplify XS level error reporting code - Cleanup code handling typed parameters 0.9.7 2011-11-08 - Add all new APIs in libvirt 0.9.7 - Add binding for virDomainOpenConsole - Fix missing $flags in documentation - Added example integrating Sys::Virt::Domain->open_graphics GTK3 and GTK-VNC 0.9.5 2011-09-28 - Add all new APIs in libvirt 0.9.5 - Add missing snapshot creation/lookup methods - Fix typo in method listing snapshots - Add missing snapshot constant - Add example for save/restore usage - Re-add abort job binding accidentally deleted 0.9.4 2011-08-03 - Add all new APIs in libvirt 0.9.4 - Requires libvirt >= 0.9.4 - Add missing VIR_DUMP_* and VIR_MIGRATE_* constants from previous releases 0.9.3 2011-07-12 - Add all new APIs in libvirt 0.9.3 - Requires libvirt >= 0.9.3 0.9.2 2011-07-08 - Changed version numbering to track the corresponding minimum required libvirt releases - Add all new APIs in libvirt 0.9.2 - Requires libvirt >= 0.9.2 0.2.8 2011-06-29 - Add all new APIs in libvirt 0.9.0 - Add examples for different ways of using stream APIs to download/upload storage volumes - Requires libvirt >= 0.9.0 0.2.7 2011-06-29 - Honour flags parameter when dumping XML - Use thread local error APIs exclusively - Fix bogus extra URI parameter in migrate_to_uri function - Implement all virStream APIs in Sys::Virt::Stream - Impement virDomainGetSysinfo binding - Call virInitialize when loading module - Add all missing error constants - Update example RPM spec to match Fedora - Requires libvirt >= 0.8.8 0.2.6 2011-02-16 - Fix build with 0.8.7 libvirt by removing reference to non-existant constant only introduced in libvirt > 0.8.7 - Fix test script when hostname is undefined 0.2.5 2011-02-04 - Add all APIs + constants from 0.8.2, 0.8.5 and 0.8.7 releases, with exception of virDomainOpenConsole - Add missing dep on XML::XPath - Requires libvirt >= 0.8.7 0.2.4 2010-05-19 - Add all APIs + constants from 0.7.7, 0.8.0 & 0.8.1 releases - Requires libvirt >= 0.8.1 0.2.3 2010-01-15 - New virSecretPtr APIs - Fix authentication callback handling of NULLs - Document flags parameters to many methods - Add virDomainMigrateToURI and virConnectGetLibVersion - Add virConnectCPUCompare and virDomainMemoryStats - Add vir*IsActive vir*IsPersistent - Add virConnectIsSecure & virConnectIsEncrypted - Add new error codes - Require libvirt >= 0.7.5 0.2.2 2009-09-14 - Add all new APIs upto libvirt 0.7.0 APIs (listing defined network interfaces) - Add missing APIs for looking up storage volumes based on path and key - Fix lookup of network interfaces based on MAC address - Add missing APIs for defining network interfaces and starting defined interfaces 0.2.1 2009-08-25 - Add all new APIs upto libvirt 0.6.4 (network interfaces, storage volume cloning and node device create/delete) - Fix off-by-1 in UUID stringification - Set default values for optional params. - Use SvOK check for potentially undefined string params - Export all the virError related constants - Fix some memory leaks in C layer - Remove bogus module imports from test suite 0.2.0 2009-03-25 - Implement storage, node device, event APIs - Full covereage of all APIs in 0.6.1 release of libvirt - Full documentation coverage - Ability to authenticate when openning connections 0.1.2 2008-02-23 - Added manual written META.yml - Added networking APIs - Added APIs for host capabilities - Added APIs for inactive domains - Switch licensse to GPLv2+ or Artistic for CPAN compatability - Fix return values for reboot/shutdown/undefine/create APIs - Expanded documentation coverage 0.1.1 2006-06-22 - Fixed POD documentation names - Make Sys::Virt::Error use 'strict' and 'warnings' pragmas - Remove duplicated DESTROY sub in Domain.pm since its already provided in the XS backend - Fixed typo in Makefile.PL - Allow connection URI to be passed to example programs - Minimum required libvirt version is now 0.1.1 - Make Makefile.PL exit if minimum required libvirt is not found by pkg-config - Added bindings for newly introduced APIs in libvirt 0.1.1 0.1.0 2006-04-25 - Added Sys::Virt->get_node_info mapping to virNodeGetInfo - Exposed the constants for domain state in Sys::Virt::Domain - Added binding for virDomainReboot - Change get_uuid to return raw UUID string - Add get_uuid_string to return a printable version - More example programs Sys-Virt-1.2.1/examples/0000755000076500007650000000000012267462221015203 5ustar berrangeberrangeSys-Virt-1.2.1/examples/vcpuinfo.pl0000644000076500007650000000173212267462203017374 0ustar berrangeberrange# -*- perl -*- use strict; use warnings; use Sys::Virt; my $addr = @ARGV ? shift @ARGV : ""; print "Addr $addr\n"; my $con = Sys::Virt->new(address => $addr, readonly => 1); print "VMM type: ", $con->get_type(), "\n"; foreach my $dom (sort { $a->get_id <=> $b->get_id } $con->list_all_domains) { print "Domain: {\n"; print " ID: ", $dom->get_id(), " '" , $dom->get_name(), "'\n"; print " UUID: ", $dom->get_uuid_string(), "\n"; my $nodeinfo = $con->get_node_info; my @info = $dom->get_vcpu_info(Sys::Virt::Domain::AFFECT_CONFIG); foreach my $info (@info) { print " VCPU: {\n"; foreach (sort { $a cmp $b } keys %{$info}) { if ($_ eq "affinity") { print " ", $_, ": "; my @mask = split //, $info->{$_}; for (my $p = 0 ; $p < $nodeinfo->{cpus} ; $p++) { print ((ord($mask[$p/8]) & (1 << ($p % 8))) ? 1 : 0); } print "\n"; } else { print " ", $_, ": ", $info->{$_}, "\n"; } } print " }\n"; } print "}\n"; } Sys-Virt-1.2.1/examples/node-ksm.pl0000644000076500007650000000122112267462203017251 0ustar berrangeberrange#!/usr/bin/perl use warnings; use strict; use Sys::Virt; my $pagetoscan = shift @ARGV || 200; my $sleepmillis = shift @ARGV || 100; my $uri = "qemu:///system"; my $con = Sys::Virt->new(address => $uri); my $params = $con->get_node_memory_parameters(); foreach my $key (keys %{$params}) { printf "%s: %d\n", $key, $params->{$key}; } my %param = (Sys::Virt::NODE_MEMORY_SHARED_PAGES_TO_SCAN => $pagetoscan, Sys::Virt::NODE_MEMORY_SHARED_SLEEP_MILLISECS => $sleepmillis); $con->set_node_memory_parameters(\%param); $params = $con->get_node_memory_parameters(); foreach my $key (keys %{$params}) { printf "%s: %d\n", $key, $params->{$key}; } Sys-Virt-1.2.1/examples/auth.pl0000644000076500007650000000120512267462203016477 0ustar berrangeberrange# -*- perl -*- use strict; use warnings; use Sys::Virt; my $addr = @ARGV ? shift @ARGV : ""; print "Addr $addr\n"; my $con = Sys::Virt->new(address => $addr, readonly => 0, auth => 1, credlist => [ Sys::Virt::CRED_AUTHNAME, Sys::Virt::CRED_PASSPHRASE, ], callback => sub { my $creds = shift; foreach my $cred (@{$creds}) { if ($cred->{type} == Sys::Virt::CRED_AUTHNAME) { $cred->{result} = "test"; } if ($cred->{type} == Sys::Virt::CRED_PASSPHRASE) { $cred->{result} = "123456"; } } return 0; }); print "VMM type: ", $con->get_type(), "\n"; Sys-Virt-1.2.1/examples/vol-upload.pl0000644000076500007650000000142212267462203017621 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; my $c = Sys::Virt->new(uri => "qemu:///session"); my $st = $c->new_stream(); die "syntax: $0 VOL-PATH INPUT-FILE" unless int(@ARGV) == 2; my $volpath = shift @ARGV; my $f = shift @ARGV; my $vol = $c->get_storage_volume_by_path($volpath); open FILE, "<$f" or die "cannot open $f: $!"; eval { $vol->upload($st, 0, 0); while (1) { my $nbytes = 1024; my $data; my $rv = sysread FILE, $data, $nbytes; if ($rv < 0) { die "cannot read $f: $!"; } last if $rv == 0; while ($rv > 0) { my $done = $st->send($data, $rv); if ($done) { $data = substr $data, $done; $rv -= $done; } } } $st->finish(); }; if ($@) { close FILE; die $@; } close FILE or die "cannot save $f: $!"; Sys-Virt-1.2.1/examples/vol-download-all.pl0000644000076500007650000000121512267462203020712 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; my $c = Sys::Virt->new(uri => "qemu:///session"); my $st = $c->new_stream(); die "syntax: $0 VOL-PATH OUTPUT-FILE" unless int(@ARGV) == 2; my $volpath = shift @ARGV; my $f = shift @ARGV; my $vol = $c->get_storage_volume_by_path($volpath); open FILE, ">$f" or die "cannot create $f: $!"; sub foo { my $st = shift; my $data = shift; my $nbytes = shift; return syswrite FILE, $data, $nbytes; }; eval { $vol->download($st, 0, 0); $st->recv_all(\&foo); $st->finish(); }; if ($@) { unlink $f if $@; close FILE; die $@; } close FILE or die "cannot save $f: $!"; Sys-Virt-1.2.1/examples/save-restore.pl0000644000076500007650000000217712267462203020166 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; my $xml = < perl-demo 219200 219136 1 hvm destroy restart destroy EOF my $conn = Sys::Virt->new(uri => "qemu:///session"); print "Starting a transient guest\n"; my $dom = $conn->create_domain($xml); print "Saving the guest\n"; my $curxml = $dom->get_xml_description(); $dom->save("perl-demo.img", $curxml, Sys::Virt::Domain::SAVE_BYPASS_CACHE); my $newxml = $conn->get_save_image_xml_description("perl-demo.img"); print $newxml; print "Restoring the guest\n"; $conn->restore_domain("perl-demo.img", $newxml, Sys::Virt::Domain::SAVE_BYPASS_CACHE); print "Destroying the guest\n"; $dom = $conn->get_domain_by_name("perl-demo"); $dom->destroy; unlink "perl-demo.img"; Sys-Virt-1.2.1/examples/dump-info.pl0000644000076500007650000000155012267462203017437 0ustar berrangeberrange# -*- perl -*- use strict; use warnings; use Sys::Virt; my $addr = @ARGV ? shift @ARGV : ""; print "Addr $addr\n"; my $con = Sys::Virt->new(address => $addr, readonly => 1); print "VMM type: ", $con->get_type(), "\n"; print "Node: {\n"; my $ninfo = $con->get_node_info; foreach (sort { $a cmp $b } keys %{$ninfo}) { print " ", $_, ": ", $ninfo->{$_}, "\n"; } print "}\n"; print "libvirt Version: ", $con->get_major_version(), ".", $con->get_minor_version(), ".", $con->get_micro_version(), "\n"; foreach my $dom (sort { $a->get_id <=> $b->get_id } $con->list_domains) { print "Domain: {\n"; print " ID: ", $dom->get_id(), " '" , $dom->get_name(), "'\n"; print " UUID: ", $dom->get_uuid_string(), "\n"; my $info = $dom->get_info; foreach (sort { $a cmp $b } keys %{$info}) { print " ", $_, ": ", $info->{$_}, "\n"; } print "}\n"; } Sys-Virt-1.2.1/examples/node-cpu.pl0000644000076500007650000000225112267462203017252 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; use Time::HiRes qw(time); my $addr = @ARGV ? shift @ARGV : ""; my $hv = Sys::Virt->new(address => $addr, readonly => 1); my $interval = @ARGV ? shift @ARGV : 1; my $iterations = @ARGV ? shift @ARGV : 1; my $nodeinfo = $hv->get_node_info(); my $ncpus = $nodeinfo->{cpus}; my @cpuTime; my $then; for (my $c = 0 ; $c < $ncpus ; $c++) { printf "CPU %3d ", $c; } print "\n"; for (my $i = 0 ; $i < $iterations ; $i++) { sleep $interval if $i; my $now = time; for (my $c = 0 ; $c < $ncpus ; $c++) { my $info = $hv->get_node_cpu_stats($c); my $used = $info->{kernel} + $info->{user}; if (exists $cpuTime[$c]) { my $cpudelta = $used - $cpuTime[$c]; my $timedelta = ($now - $then) * 1000*1000*1000; my $util = $cpudelta * 100 / $timedelta; printf "%03.02f%% ", $util; } $cpuTime[$c] = $used; } print "\n"; $then = $now; } my ($totcpus, $onlinemask, $nonline) = $hv->get_node_cpu_map(); printf "CPUs total %d, online %d\n", $totcpus, $nonline; my @bits = split(//, unpack("b*", $onlinemask)); for (my $i = 0 ; $i < $totcpus ; $i++) { printf " %d: %d\n", $i, $bits[$i]; } Sys-Virt-1.2.1/examples/node-info.pl0000644000076500007650000000046112267462203017417 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; my $addr = @ARGV ? shift @ARGV : ""; my $hv = Sys::Virt->new(address => $addr, readonly => 1); my $info = $hv->get_node_info(); my @models = $hv->get_cpu_model_names($info->{model}); print join ("\n", sort{ lc $a cmp lc $b } @models), "\n"; Sys-Virt-1.2.1/examples/events.pl0000644000076500007650000000115712267462203017050 0ustar berrangeberrange#!/usr/bin/perl use Sys::Virt; use Sys::Virt::Event; my $uri = shift @ARGV; Sys::Virt::Event::register_default(); my $quit = 0; my $c = Sys::Virt->new(uri => $uri, readonly => 1); sub lifecycle_event { my $dom = shift; my $event = shift; my $detail = shift; print "$dom $event $detail\n"; } $c->domain_event_register_any(undef, Sys::Virt::Domain::EVENT_ID_LIFECYCLE, \&lifecycle_event); $c->register_close_callback( sub { my $con = shift ; my $reason = shift ; print "Closed reason=$reason\n"; $quit = 1; }); while (!$quit) { Sys::Virt::Event::run_default(); } Sys-Virt-1.2.1/examples/hv-stat.pl0000644000076500007650000000306412267462203017131 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; use Sys::Virt::Domain; use Time::HiRes qw(time); my $addr = @ARGV ? shift @ARGV : ""; my $hv = Sys::Virt->new(address => $addr, readonly => 1); my $interval = @ARGV ? shift @ARGV : 1; my $iterations = @ARGV ? shift @ARGV : 1; my %states = ( &Sys::Virt::Domain::STATE_NOSTATE => "nostate", &Sys::Virt::Domain::STATE_RUNNING => "running", &Sys::Virt::Domain::STATE_BLOCKED => "blocked", &Sys::Virt::Domain::STATE_PAUSED => "paused", &Sys::Virt::Domain::STATE_SHUTDOWN => "shutdown", &Sys::Virt::Domain::STATE_SHUTOFF => "shutoff", &Sys::Virt::Domain::STATE_CRASHED => "crashed", &Sys::Virt::Domain::STATE_RUNNING => "running", ); my %cpuTime; my $sample; for (my $i = 0 ; $i < $iterations ; $i++) { sleep $interval if $i; my $now = time; my @domains = $hv->list_domains; my @stats; if (!($i % 10)) { printf " %-4s %-15s %-8s %-6s %-4s\n", "ID", "Name", "State", "CPU", "Memory"; } foreach my $domain (sort { $a->get_id <=> $b->get_id } @domains) { my $uuid = $domain->get_uuid_string; my $info = $domain->get_info; my $cpudelta = exists $cpuTime{$uuid} ? $info->{cpuTime} - $cpuTime{$uuid} : 0; my $timedelta = defined $sample ? ($now - $sample)*1000*1000*1000 :0; $cpuTime{$uuid} = $info->{cpuTime}; my $util = $timedelta > 0 ? $cpudelta * 100 / $timedelta : 0; printf " %-4d %-15s %-8s %-6s %-4dMB \n", $domain->get_id, $domain->get_name, $states{$info->{state}}, (sprintf "%d%%",$util), ($info->{memory}/1024); } $sample = $now; print "\n"; } Sys-Virt-1.2.1/examples/devices.pl0000644000076500007650000000044212267462203017162 0ustar berrangeberrange# -*- perl -*- use strict; use warnings; use Sys::Virt; my $addr = @ARGV ? shift @ARGV : undef; my $con = Sys::Virt->new(address => $addr, readonly => 1); my @devs = $con->list_node_devices("net"); print "Available NICS\n"; foreach (@devs) { print "NIC: ", $_->get_name(), "\n"; } Sys-Virt-1.2.1/examples/dump-xml.pl0000644000076500007650000000056612267462203017312 0ustar berrangeberrange# -*- perl -*- use strict; use warnings; use Sys::Virt; my $addr = ""; if (@ARGV == 2) { $addr = shift @ARGV; } if (@ARGV != 1) { print STDERR "syntax: $0 [URI] DOMAIN-NAME\n"; exit 1; } my $con = Sys::Virt->new(address => $addr, readonly => 1); my $name = shift @ARGV; my $dom = $con->get_domain_by_name($name); print $dom->get_xml_description(), "\n"; Sys-Virt-1.2.1/examples/vol-upload-all.pl0000644000076500007650000000114612267462203020372 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; my $c = Sys::Virt->new(uri => "qemu:///session"); my $st = $c->new_stream(); die "syntax: $0 VOL-PATH INPUT-FILE" unless int(@ARGV) == 2; my $volpath = shift @ARGV; my $f = shift @ARGV; my $vol = $c->get_storage_volume_by_path($volpath); open FILE, "<$f" or die "cannot open $f: $!"; sub foo { my $st = $_[0]; my $nbytes = $_[2]; return sysread FILE, $_[1], $nbytes; }; eval { $vol->upload($st, 0, 0); $st->send_all(\&foo); $st->finish(); }; if ($@) { close FILE; die $@; } close FILE or die "cannot save $f: $!"; Sys-Virt-1.2.1/examples/open-console.pl0000644000076500007650000000152012267462203020137 0ustar berrangeberrange#!/usr/bin/perl use Gtk3 -init; use Sys::Virt; Glib::Object::Introspection->setup( basename => 'GtkVnc', version => '2.0', package => 'GtkVnc'); Glib::Object::Introspection->setup( basename => 'GVnc', version => '1.0', package => 'GVnc'); GVnc::util_set_debug(true); my $window = Gtk3::Window->new ('toplevel'); my $display = GtkVnc::Display->new(); my ($SOCK1, $SOCK2); if (1) { use IO::Socket; ($SOCK1, $SOCK2) = IO::Socket->socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "cannot create socketpair: $!"; my $c = Sys::Virt->new(uri => "qemu:///session"); my $d = $c->get_domain_by_name("vm-vnc"); $d->open_graphics(0, $SOCK1->fileno); $display->open_fd($SOCK2->fileno); } else { $display->open_host("localhost", "5900"); } $window->add($display); $window->show_all; Gtk3::main; Sys-Virt-1.2.1/examples/vol-upload-nonblock.pl0000644000076500007650000000234212267462203021426 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; Sys::Virt::Event::register_default(); my $c = Sys::Virt->new(uri => "qemu:///session"); my $st = $c->new_stream(Sys::Virt::Stream::NONBLOCK); die "syntax: $0 VOL-PATH INPUT-FILE" unless int(@ARGV) == 2; my $volpath = shift @ARGV; my $f = shift @ARGV; my $vol = $c->get_storage_volume_by_path($volpath); my $quit = 0; open FILE, "<$f" or die "cannot open $f: $!"; my $nextdata; my $nextdatalen; sub moredata { return if $nextdatalen; $nextdatalen = sysread FILE, $nextdata, 1024; } sub streamevent { my $st = shift; my $events = shift; if ($events & (Sys::Virt::Stream::EVENT_HANGUP | Sys::Virt::Stream::EVENT_ERROR)) { $quit = 1; return; } &moredata; if ($nextdatalen == 0) { $quit = 1; $st->remove_callback(); return; } my $rv = $st->send($nextdata, $nextdatalen); if ($rv > 0) { $nextdata = substr $nextdata, $rv; $nextdatalen -= $rv; } } eval { $vol->upload($st, 0, 0); $st->add_callback(Sys::Virt::Stream::EVENT_WRITABLE, \&streamevent); while (!$quit) { Sys::Virt::Event::run_default(); } $st->finish(); }; if ($@) { close FILE; die $@; } close FILE or die "cannot save $f: $!"; Sys-Virt-1.2.1/examples/node-devlist.pl0000644000076500007650000000034612267462203020140 0ustar berrangeberrange#!/usr/bin/perl use Sys::Virt; my $conn = Sys::Virt->new(); my @nodelist = $conn->list_all_node_devices(); foreach my $dev (@nodelist){ my $parent = $dev->get_parent(); printf "%s: < %s\n", $dev->get_name(), $parent; } Sys-Virt-1.2.1/examples/emulator-pin.pl0000644000076500007650000000153712267462203020162 0ustar berrangeberrange#!/usr/bin/perl use Sys::Virt; my $uri = shift @ARGV; my $c = Sys::Virt->new(uri => $uri); my $d = $c->get_domain_by_name("vm1"); unless ($d->is_active()) { $d->create; } my $mask = $d->get_emulator_pin_info; @bits = split(//, unpack("b*", $mask)); print join(":", @bits), "\n"; if ($bits[0] == '1' && $bits[1] == '1') { @bits[0] = 0; my $newmask = ''; for(my $i = 0 ; $i <= $#bits ; $i++) { vec($newmask, $i, 1) = $bits[$i]; } @bits = split(//, unpack("b*", $newmask)); print join(":", @bits), "\n"; $d->pin_emulator($newmask); $newermask = $d->get_emulator_pin_info; @bits = split(//, unpack("b*", $newermask)); print join(":", @bits), "\n"; $d->pin_emulator($mask); $newermask = $d->get_emulator_pin_info; @bits = split(//, unpack("b*", $newermask)); print join(":", @bits), "\n"; } Sys-Virt-1.2.1/examples/vol-download-nonblock.pl0000644000076500007650000000220212267462203021744 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; Sys::Virt::Event::register_default(); my $c = Sys::Virt->new(uri => "qemu:///session"); my $st = $c->new_stream(Sys::Virt::Stream::NONBLOCK); die "syntax: $0 VOL-PATH OUTPUT-FILE" unless int(@ARGV) == 2; my $volpath = shift @ARGV; my $f = shift @ARGV; my $vol = $c->get_storage_volume_by_path($volpath); my $quit = 0; open FILE, ">$f" or die "cannot create $f: $!"; sub streamevent { my $st = shift; my $events = shift; if ($events & (Sys::Virt::Stream::EVENT_HANGUP | Sys::Virt::Stream::EVENT_ERROR)) { $quit = 1; return; } my $data; my $rv = $st->recv($data, 1024); if ($rv == 0) { $quit = 1; $st->remove_callback(); return; } while ($rv > 0) { my $ret = syswrite FILE, $data, $rv; $data = substr $data, $ret; $rv -= $ret; } } eval { $vol->download($st, 0, 0); $st->add_callback(Sys::Virt::Stream::EVENT_READABLE, \&streamevent); while (!$quit) { Sys::Virt::Event::run_default(); } $st->finish(); }; if ($@) { unlink $f if $@; close FILE; die $@; } close FILE or die "cannot save $f: $!"; Sys-Virt-1.2.1/examples/vol-download.pl0000644000076500007650000000137312267462203020151 0ustar berrangeberrange#!/usr/bin/perl use strict; use warnings; use Sys::Virt; my $c = Sys::Virt->new(uri => "qemu:///session"); my $st = $c->new_stream(); die "syntax: $0 VOL-PATH OUTPUT-FILE" unless int(@ARGV) == 2; my $volpath = shift @ARGV; my $f = shift @ARGV; my $vol = $c->get_storage_volume_by_path($volpath); open FILE, ">$f" or die "cannot create $f: $!"; eval { $vol->download($st, 0, 0); while (1) { my $nbytes = 1024; my $data; my $rv = $st->recv($data, $nbytes); last if $rv == 0; while ($rv > 0) { my $done = syswrite FILE, $data, $rv; if ($done) { $data = substr $data, $done; $rv -= $done; } } } $st->finish(); }; if ($@) { unlink $f if $@; close FILE; die $@; } close FILE or die "cannot save $f: $!"; Sys-Virt-1.2.1/examples/send-key.pl0000644000076500007650000000072112267462203017257 0ustar berrangeberrange# -*- perl -*- use strict; use warnings; use Sys::Virt; die "syntax: $0 URI DOMAIN-NAME\n" unless int(@ARGV) == 2; my $uri = shift @ARGV; my $domname = shift @ARGV; print "Addr $uri\n"; my $con = Sys::Virt->new(address => $uri, readonly => 0); my $dom = $con->get_domain_by_name($domname); my @codes = ( 35, 18, 38, 38, 24, 57, 17, 24, 19, 38, 32, 28, ); $dom->send_key(Sys::Virt::Domain::KEYCODE_SET_LINUX, 100, \@codes); Sys-Virt-1.2.1/typemap0000644000076500007650000001051012267462203014764 0ustar berrangeberrangeTYPEMAP const char * T_PV const unsigned char * T_PV virConnectPtr O_OBJECT_connect virDomainPtr O_OBJECT_domain virNetworkPtr O_OBJECT_network virNWFilterPtr O_OBJECT_nwfilter virInterfacePtr O_OBJECT_interface virStoragePoolPtr O_OBJECT_storagepool virStorageVolPtr O_OBJECT_storagevol virNodeDevicePtr O_OBJECT_nodedevice virSecretPtr O_OBJECT_secret virDomainSnapshotPtr O_OBJECT_domainsnapshot virStreamPtr O_OBJECT_stream INPUT O_OBJECT_connect if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_connect sv_setref_pv( $arg, "Sys::Virt", (void*)$var ); INPUT O_OBJECT_domain if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_domain sv_setref_pv( $arg, "Sys::Virt::Domain", (void*)$var ); INPUT O_OBJECT_network if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_network sv_setref_pv( $arg, "Sys::Virt::Network", (void*)$var ); INPUT O_OBJECT_storagepool if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_storagepool sv_setref_pv( $arg, "Sys::Virt::StoragePool", (void*)$var ); INPUT O_OBJECT_storagevol if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_storagevol sv_setref_pv( $arg, "Sys::Virt::StorageVol", (void*)$var ); INPUT O_OBJECT_nodedevice if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_nodedevice sv_setref_pv( $arg, "Sys::Virt::NodeDevice", (void*)$var ); INPUT O_OBJECT_interface if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_interface sv_setref_pv( $arg, "Sys::Virt::Interface", (void*)$var ); INPUT O_OBJECT_secret if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_secret sv_setref_pv( $arg, "Sys::Virt::Secret", (void*)$var ); INPUT O_OBJECT_nwfilter if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_nwfilter sv_setref_pv( $arg, "Sys::Virt::NWFilter", (void*)$var ); INPUT O_OBJECT_domainsnapshot if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_domainsnapshot sv_setref_pv( $arg, "Sys::Virt::DomainSnapshot", (void*)$var ); INPUT O_OBJECT_stream if (sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG)) $var = INT2PTR($type, SvIV((SV*)SvRV( $arg ))); else { warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" ); XSRETURN_UNDEF; } OUTPUT O_OBJECT_stream sv_setref_pv( $arg, "Sys::Virt::Stream", (void*)$var ); Sys-Virt-1.2.1/INSTALL0000644000076500007650000000107612267462203014422 0ustar berrangeberrange Sys::Virt Installation ====================== Sys::Virt requires that libvirt already be installed on the system. The libvirt libraries and header files are located using the pkg-config database. If libvirt is installed to a prefix other than /usr, then be sure to set the PKG_CONFIG_PATH environment variable before building this module. Regular installation: $ perl Makefile.PL $ make $ sudo make install Install from non-standard location $ export PKG_CONFIG_PATH=/some/prefix/lib/pkgconfig $ perl Makefile.PL $ make $ sudo make install -- End Sys-Virt-1.2.1/lib/0000755000076500007650000000000012267462221014133 5ustar berrangeberrangeSys-Virt-1.2.1/lib/Sys/0000755000076500007650000000000012267462221014711 5ustar berrangeberrangeSys-Virt-1.2.1/lib/Sys/Virt/0000755000076500007650000000000012267462221015635 5ustar berrangeberrangeSys-Virt-1.2.1/lib/Sys/Virt/Event.pm0000644000076500007650000001304412267462203017256 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::Event - An event loop contract =head1 DESCRIPTION The C module represents the contract for integrating libvirt with an event loop. This package is abstract and intended to be subclassed to provide an actual implementation. =head1 METHODS =over 4 =cut package Sys::Virt::Event; use strict; use warnings; our $eventimpl = undef; =item register_default() Register the default libvirt event loop implementation =item run_default() Run a single iteration of the default event loop implementation =item register($impl) Register an event loop implementation. The implementation should be a instance of a sub-class of the C package. =cut sub register { my $impl = shift; if (!(ref($impl) && $impl->isa("Sys::Virt::Event"))) { die "event implementation must be a subclass of Sys::Virt::Event"; } $eventimpl = $impl; Sys::Virt::Event::_register_impl(); } sub _add_handle { $eventimpl->add_handle(@_); } sub _update_handle { $eventimpl->update_handle(@_); } sub _remove_handle { $eventimpl->remove_handle(@_); } sub _add_timeout { $eventimpl->add_timeout(@_); } sub _update_timeout { $eventimpl->update_timeout(@_); } sub _remove_timeout { $eventimpl->remove_timeout(@_); } =item $self->_run_handle_callback($watch, $fd, $events, $cb, $opaque) A helper method for executing a callback in response to one of more C<$events> on the file handle C<$fd>. The C<$watch> number is the unique idenifier associated with the file descriptor. The C<$cb> and C<$opaque> parameters are the callback and data registered for the handle. =cut sub _run_handle_callback { my $self = shift; my $watch = shift; my $fd = shift; my $events = shift; my $cb = shift; my $opaque = shift; Sys::Virt::Event::_run_handle_callback_helper($watch, $fd, $events, $cb, $opaque); } =item $self->_run_timeout_callback($timer, $cb, $opaque) A helper method for executing a callback in response to the expiry of a timeout identified by C<$timer>. The C<$cb> and C<$opaque> parameters are the callback and data registered for the timeout. =cut sub _run_timeout_callback { my $self = shift; my $timer = shift; my $cb = shift; my $opaque = shift; Sys::Virt::Event::_run_timeout_callback_helper($timer, $cb, $opaque); } =item $self->_free_callback_opaque($ff, $opaque) A helper method for freeing the data associated with a callback. The C<$ff> and C<$opaque> parameters are the callback and data registered for the handle/timeout. =cut sub _free_callback_opaque { my $self = shift; my $ff = shift; my $opaque = shift; Sys::Virt::Event::_free_callback_opaque_helper($ff, $opaque); } 1; =item my $watch = Sys::Virt::Event::add_handle($fd, $events, $coderef) Adds a watch on the file descriptor C<$fd> for the events C<$events> which is a mask of the FILE HANDLE EVENTS constants listed later. The C<$coderef> parameter is a subroutine to invoke when an event is triggered. The subroutine will be passed three parameters, the watch identifier, the file descriptor and the event mask. This method returns the watch identifier which can be used to update or remove the watch =item Sys::Virt::Event::update_handle($watch, $events) Update the event mask for the file descriptor watch C<$watch> to use the events C<$events>. =item Sys::Virt::Event::remove_handle($watch) Remove the event mask for the file descriptor watch C<$watch>. =item my $watch = Sys::Virt::Event::add_timeout($frequency, $coderef) Adds a timeout to trigger with C<$frequency> milliseconds interval. The C<$coderef> parameter is a subroutine to invoke when an event is triggered. The subroutine will be passed one parameter, the timer identifier. This method returns the watch identifier which can be used to update or remove the watch =item Sys::Virt::Event::update_timeout($timer, $frequency) Update the timeout C<$timer> to have the frequency C<$frequency> milliseconds. =item Sys::Virt::Event::remove_timeout($timer) Remove the timeout C<$timer> =back =head1 CONSTANTS =head2 FILE HANDLE EVENTS When integrating with an event loop the following constants define the file descriptor events =over 4 =item Sys::Virt::Event::HANDLE_READABLE The file descriptor has data available for read without blocking =item Sys::Virt::Event::HANDLE_WRITABLE The file descriptor has ability to write data without blocking =item Sys::Virt::Event::HANDLE_ERROR An error occurred on the file descriptor =item Sys::Virt::Event::HANDLE_HANGUP The remote end of the file descriptor closed =back =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006-2009 Red Hat Copyright (C) 2006-2009 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/StoragePool.pm0000644000076500007650000002611512267462203020436 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006-2009 Red Hat # Copyright (C) 2006-2009 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::StoragePool - Represent & manage a libvirt storage pool =head1 DESCRIPTION The C module represents a storage pool managed by libvirt. There are a variety of storage pool implementations for LVM, Local directories/filesystems, network filesystems, disk partitioning, iSCSI, and SCSI. =head1 METHODS =over 4 =cut package Sys::Virt::StoragePool; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; my $self; if (exists $params{name}) { $self = Sys::Virt::StoragePool::_lookup_by_name($con, $params{name}); } elsif (exists $params{uuid}) { if (length($params{uuid}) == 16) { $self = Sys::Virt::StoragePool::_lookup_by_uuid($con, $params{uuid}); } elsif (length($params{uuid}) == 32 || length($params{uuid}) == 36) { $self = Sys::Virt::StoragePool::_lookup_by_uuid_string($con, $params{uuid}); } else { die "UUID must be either 16 unsigned bytes, or 32/36 hex characters long"; } } elsif (exists $params{volume}) { $self = Sys::Virt::StoragePool::_lookup_by_volume($params{volume}); } elsif (exists $params{xml}) { if ($params{nocreate}) { $self = Sys::Virt::StoragePool::_define_xml($con, $params{xml}); } else { $self = Sys::Virt::StoragePool::_create_xml($con, $params{xml}); } } else { die "address, id or uuid parameters are required"; } bless $self, $class; return $self; } =item my $uuid = $pool->get_uuid() Returns a 16 byte long string containing the raw globally unique identifier (UUID) for the storage pool. =item my $uuid = $pool->get_uuid_string() Returns a printable string representation of the raw UUID, in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'. =item my $name = $pool->get_name() Returns a string with a locally unique name of the storage pool =item $pool->is_active() Returns a true value if the storage pool is currently running =item $pool->is_persistent() Returns a true value if the storage pool has a persistent configuration file defined =item my $xml = $pool->get_xml_description() Returns an XML document containing a complete description of the storage pool's configuration =item $pool->create() Start a storage pool whose configuration was previously defined using the C method in L. =item $pool->undefine() Remove the configuration associated with a storage pool previously defined with the C method in L. If the storage pool is running, you probably want to use the C or C methods instead. =item $pool->destroy() Immediately terminate the machine, and remove it from the virtual machine monitor. The C<$pool> handle is invalid after this call completes and should not be used again. =item $flag = $pool->get_autostart(); Return a true value if the storage pool is configured to automatically start upon boot. Return false, otherwise =item $pool->set_autostart($flag) Set the state of the autostart flag, which determines whether the storage pool will automatically start upon boot of the host OS =item $pool->refresh([$flags]); Refresh the storage pool state. Typically this will rescan the list of storage volumes. The C<$flags> parameter is currently unused and if omitted defaults to zero. =item $pool->build([$flags]); Construct the storage pool if it does not exist. As an example, for a disk based storage pool this would ensure a partition table exists. The C<$flags> parameter allows control over the build operation and if omitted defaults to zero. =item $pool->delete([$flags]); Delete the storage pool. The C<$flags> parameter allows the data to be optionally wiped during delete and if omitted defaults to zero. =item $info = $pool->get_info() Retrieve information about the current storage pool state. The returned hash reference has the following keys =over 4 =item state The current status of the storage pool. See constants later. =item capacity The total logical size of the storage pool =item allocation The current physical allocation of the storage pool =item available The available space for creation of new volumes. This may be less than the difference between capacity & allocation if there are sizing / metadata constraints for volumes =back =item my $nnames = $pool->num_of_storage_volumes() Return the number of running volumes in this storage pool. The value can be used as the C parameter to C. =item my @volNames = $pool->list_storage_vol_names($maxnames) Return a list of all volume names in this storage pool. The names can be used with the C method. =item my @vols = $pool->list_volumes() Return a list of all volumes in the storage pool. The elements in the returned list are instances of the L class. This method requires O(n) RPC calls, so the C method is recommended as a more efficient alternative. =cut sub list_volumes { my $self = shift; my $nnames = $self->num_of_storage_volumes(); my @names = $self->list_storage_vol_names($nnames); my @volumes; foreach my $name (@names) { eval { push @volumes, Sys::Virt::StorageVol->_new(pool => $self, name => $name); }; if ($@) { # nada - volume went away before we could look it up }; } return @volumes; } =item my @volumes = $pool->list_all_volumes($flags) Return a list of all storage volumes associated with this pool. The elements in the returned list are instances of the L class. The C<$flags> parameter can be used to filter the list of return storage volumes. =item my $vol = $pool->get_volume_by_name($name) Return the volume with a name of C<$name>. The returned object is an instance of the L class. =cut sub get_volume_by_name { my $self = shift; my $name = shift; return Sys::Virt::StorageVol->_new(pool => $self, name => $name); } =item my $vol = $pool->create_volume($xml) Create a new volume based on the XML description passed into the C<$xml> parameter. The returned object is an instance of the L class. If the optional C is provided, data will be copied from that source volume =cut sub create_volume { my $self = shift; my $xml = shift; return Sys::Virt::StorageVol->_new(pool => $self, xml => $xml); } =item my $vol = $pool->clone_volume($xml, $clonevol); Create a new volume based on the XML description passed into the C<$xml> parameter. The returned object is an instance of the L class. The new volume will be populated with data from the specified clone source volume. =cut sub clone_volume { my $self = shift; my $xml = shift; my $clone = shift; return Sys::Virt::StorageVol->_new(pool => $self, xml => $xml, clone => $clone); } 1; =back =head1 CONSTANTS The following sets of constants may be useful in dealing with some of the methods in this package =head2 POOL STATES The following constants are useful for interpreting the C key value in the hash returned by C =over 4 =item Sys::Virt::StoragePool::STATE_INACTIVE The storage pool is not currently active =item Sys::Virt::StoragePool::STATE_BUILDING The storage pool is still being constructed and is not ready for use yet. =item Sys::Virt::StoragePool::STATE_RUNNING The storage pool is running and can be queried for volumes =item Sys::Virt::StoragePool::STATE_DEGRADED The storage pool is running, but its operation is degraded due to a failure. =item Sys::Virt::StoragePool::STATE_INACCESSIBLE The storage pool is not currently accessible =back =head2 DELETION MODES =over 4 =item Sys::Virt::StoragePool::DELETE_NORMAL Delete the pool without any attempt to scrub data =item Sys::Virt::StoragePool::DELETE_ZEROED Fill the allocated storage with zeros when deleting =back =head2 BUILD MODES =over 4 =item Sys::Virt::StoragePool::BUILD_NEW Construct a new storage pool from constituent bits =item Sys::Virt::StoragePool::BUILD_RESIZE Resize an existing built storage pool preserving data where appropriate =item Sys::Virt::StoragePool::BUILD_REPAIR Repair an existing storage pool operating in degraded mode =item Sys::Virt::StoragePool::BUILD_NO_OVERWRITE Do not overwrite existing storage pool data =item Sys::Virt::StoragePool::BUILD_OVERWRITE Overwrite existing storage pool data =back =head2 XML DOCUMENTS The following constants are useful when requesting XML for storage pools =over 4 =item Sys::Virt::StoragePool::XML_INACTIVE Return XML describing the inactive state of the storage pool. =back =head1 LIST FILTERING The following constants are used to filter object lists =over 4 =item Sys::Virt::StoragePool::LIST_ACTIVE Include storage pools which are active =item Sys::Virt::StoragePool::LIST_INACTIVE Include storage pools which are inactive =item Sys::Virt::StoragePool::LIST_AUTOSTART Include storage pools which are marked for autostart =item Sys::Virt::StoragePool::LIST_NO_AUTOSTART Include storage pools which are not marked for autostart =item Sys::Virt::StoragePool::LIST_PERSISTENT Include storage pools which are persistent =item Sys::Virt::StoragePool::LIST_TRANSIENT Include storage pools which are transient =item Sys::Virt::StoragePool::LIST_DIR Include directory storage pools =item Sys::Virt::StoragePool::LIST_DISK Include disk storage pools =item Sys::Virt::StoragePool::LIST_FS Include filesytem storage pools =item Sys::Virt::StoragePool::LIST_ISCSI Include iSCSI storage pools =item Sys::Virt::StoragePool::LIST_LOGICAL Include LVM storage pools =item Sys::Virt::StoragePool::LIST_MPATH Include multipath storage pools =item Sys::Virt::StoragePool::LIST_NETFS Include network filesystem storage pools =item Sys::Virt::StoragePool::LIST_RBD Include RBD storage pools =item Sys::Virt::StoragePool::LIST_SCSI Include SCSI storage pools =item Sys::Virt::StoragePool::LIST_SHEEPDOG Include sheepdog storage pools =item Sys::Virt::StoragePool::LIST_GLUSTER Include gluster storage pools =back =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006-2009 Red Hat Copyright (C) 2006-2009 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/NWFilter.pm0000644000076500007650000000601212267462203017664 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::NWFilter - Represent & manage a libvirt virtual network =head1 DESCRIPTION The C module represents a virtual network managed by the virtual machine monitor. =head1 METHODS =over 4 =cut package Sys::Virt::NWFilter; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; my $self; if (exists $params{name}) { $self = Sys::Virt::NWFilter::_lookup_by_name($con, $params{name}); } elsif (exists $params{uuid}) { if (length($params{uuid}) == 16) { $self = Sys::Virt::NWFilter::_lookup_by_uuid($con, $params{uuid}); } elsif (length($params{uuid}) == 32 || length($params{uuid}) == 36) { $self = Sys::Virt::NWFilter::_lookup_by_uuid_string($con, $params{uuid}); } else { die "UUID must be either 16 unsigned bytes, or 32/36 hex characters long"; } } elsif (exists $params{xml}) { $self = Sys::Virt::NWFilter::_define_xml($con, $params{xml}); } else { die "address, id or uuid parameters are required"; } bless $self, $class; return $self; } =item my $uuid = $filter->get_uuid() Returns a 16 byte long string containing the raw globally unique identifier (UUID) for the network. =item my $uuid = $filter->get_uuid_string() Returns a printable string representation of the raw UUID, in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'. =item my $name = $filter->get_name() Returns a string with a locally unique name of the network =item my $xml = $filter->get_xml_description() Returns an XML document containing a complete description of the network's configuration =item $filter->undefine() Remove the configuration associated with a network previously defined with the C method in L. If the network is running, you probably want to use the C or C methods instead. =cut 1; =back =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/Network.pm0000644000076500007650000001733012267462203017630 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::Network - Represent & manage a libvirt virtual network =head1 DESCRIPTION The C module represents a virtual network managed by the virtual machine monitor. =head1 METHODS =over 4 =cut package Sys::Virt::Network; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; my $self; if (exists $params{name}) { $self = Sys::Virt::Network::_lookup_by_name($con, $params{name}); } elsif (exists $params{uuid}) { if (length($params{uuid}) == 16) { $self = Sys::Virt::Network::_lookup_by_uuid($con, $params{uuid}); } elsif (length($params{uuid}) == 32 || length($params{uuid}) == 36) { $self = Sys::Virt::Network::_lookup_by_uuid_string($con, $params{uuid}); } else { die "UUID must be either 16 unsigned bytes, or 32/36 hex characters long"; } } elsif (exists $params{xml}) { if ($params{nocreate}) { $self = Sys::Virt::Network::_define_xml($con, $params{xml}); } else { $self = Sys::Virt::Network::_create_xml($con, $params{xml}); } } else { die "address, id or uuid parameters are required"; } bless $self, $class; return $self; } =item my $uuid = $net->get_uuid() Returns a 16 byte long string containing the raw globally unique identifier (UUID) for the network. =item my $uuid = $net->get_uuid_string() Returns a printable string representation of the raw UUID, in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'. =item my $name = $net->get_name() Returns a string with a locally unique name of the network =item $net->is_active() Returns a true value if the network is currently running =item $net->is_persistent() Returns a true value if the network has a persistent configuration file defined =item my $xml = $net->get_xml_description() Returns an XML document containing a complete description of the network's configuration =item $net->create() Start a network whose configuration was previously defined using the C method in L. =item $net->undefine() Remove the configuration associated with a network previously defined with the C method in L. If the network is running, you probably want to use the C or C methods instead. =item $net->destroy() Immediately terminate the machine, and remove it from the virtual machine monitor. The C<$net> handle is invalid after this call completes and should not be used again. =item $net->update($command, $section, $parentIndex, $xml, $flags=0) Update the network configuration with C<$xml>. The C<$section> parameter, which must be one of the XML SECTION CONSTANTS listed later, indicates what schema is used in C<$xml>. The C<$command> parameter determines what action is taken. Finally, the C<$flags> parameter can be use to control which config is affected. =item $net->get_bridge_name() Return the name of the bridge device associated with the virtual network =item $flag = $net->get_autostart(); Return a true value if the virtual network is configured to automatically start upon boot. Return false, otherwise =item $net->set_autostart($flag) Set the state of the autostart flag, which determines whether the virtual network will automatically start upon boot of the host OS. =back =head1 CONSTANTS This section documents constants that are used with various APIs described above =head2 LIST FILTERING The following constants are used to filter object lists =over 4 =item Sys::Virt::Network::LIST_ACTIVE Include networks which are active =item Sys::Virt::Network::LIST_INACTIVE Include networks which are not active =item Sys::Virt::Network::LIST_AUTOSTART Include networks which are set to autostart =item Sys::Virt::Network::LIST_NO_AUTOSTART Include networks which are not set to autostart =item Sys::Virt::Network::LIST_PERSISTENT Include networks which are persistent =item Sys::Virt::Network::LIST_TRANSIENT Include networks which are transient =back =head2 XML CONSTANTS The following constants are used when querying XML =over 4 =item Sys::Virt::Network::XML_INACTIVE Request the inactive XML, instead of the current possibly live config. =back =head1 XML SECTION CONSTANTS The following constants are used to refer to sections of the XML document =over 4 =item Sys::Virt::Network::SECTION_BRIDGE The bridge device element =item Sys::Virt::Network::SECTION_DNS_HOST The DNS host record section =item Sys::Virt::Network::SECTION_DNS_SRV The DNS SRV record section =item Sys::Virt::Network::SECTION_DNS_TXT The DNS TXT record section =item Sys::Virt::Network::SECTION_DOMAIN The domain name section =item Sys::Virt::Network::SECTION_FORWARD The forward device section =item Sys::Virt::Network::SECTION_FORWARD_INTERFACE The forward interface section =item Sys::Virt::Network::SECTION_FORWARD_PF The forward physical function section =item Sys::Virt::Network::SECTION_IP The IP address section =item Sys::Virt::Network::SECTION_IP_DHCP_HOST The IP address DHCP host section =item Sys::Virt::Network::SECTION_IP_DHCP_RANGE The IP address DHCP range section =item Sys::Virt::Network::SECTION_PORTGROUP The port group section =item Sys::Virt::Network::SECTION_NONE The top level domain element =back =head2 XML UPDATE FLAGS =over 4 =item Sys::Virt::Network::UPDATE_AFFECT_CURRENT Affect whatever the current object state is =item Sys::Virt::Network::UPDATE_AFFECT_CONFIG Always update the config file =item Sys::Virt::Network::UPDATE_AFFECT_LIVE Always update the live config =back =head2 XML UPDATE COMMANDS =over 4 =item Sys::Virt::Network::UPDATE_COMMAND_NONE No update =item Sys::Virt::Network::UPDATE_COMMAND_DELETE Remove the matching entry =item Sys::Virt::Network::UPDATE_COMMAND_MODIFY Modify the matching entry =item Sys::Virt::Network::UPDATE_COMMAND_ADD_FIRST Insert the matching entry at the start =item Sys::Virt::Network::UPDATE_COMMAND_ADD_LAST Insert the matching entry at the end =back =head2 EVENT ID CONSTANTS =over 4 =item Sys::Virt::Network::EVENT_ID_LIFECYCLE Network lifecycle events =back =head2 LIFECYCLE CHANGE EVENTS The following constants allow network lifecycle change events to be interpreted. The events contain both a state change, and a reason though the reason is currently unsed. =over 4 =item Sys::Virt::Network::EVENT_DEFINED Indicates that a persistent configuration has been defined for the network. =item Sys::Virt::Network::EVENT_STARTED The network has started running =item Sys::Virt::Network::EVENT_STOPPED The network has stopped running =item Sys::Virt::Network::EVENT_UNDEFINED The persistent configuration has gone away =back =cut 1; =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/Interface.pm0000644000076500007650000000707312267462203020102 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006-2009 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::Interface - Represent & manage a libvirt host network interface =head1 DESCRIPTION The C module represents a host network interface allowing configuration of IP addresses, bonding, vlans and bridges. =head1 METHODS =over 4 =cut package Sys::Virt::Interface; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; my $self; if (exists $params{name}) { $self = Sys::Virt::Interface::_lookup_by_name($con, $params{name}); } elsif (exists $params{mac}) { $self = Sys::Virt::Interface::_lookup_by_mac($con, $params{mac}); } elsif (exists $params{xml}) { $self = Sys::Virt::Interface::_define_xml($con, $params{xml}); } else { die "name, mac or xml parameters are required"; } bless $self, $class; return $self; } =item my $name = $iface->get_name() Returns a string with a locally unique name of the network =item $iface->is_active() Returns a true value if the interface is currently running =item my $name = $iface->get_mac() Returns a string with the hardware MAC address of the interface =item my $xml = $iface->get_xml_description() Returns an XML document containing a complete description of the network's configuration =item $iface->create() Start a network whose configuration was previously defined using the C method in L. =item $iface->undefine() Remove the configuration associated with a network previously defined with the C method in L. If the network is running, you probably want to use the C or C methods instead. =item $iface->destroy() Immediately terminate the machine, and remove it from the virtual machine monitor. The C<$iface> handle is invalid after this call completes and should not be used again. =back =head1 CONSTANTS =head1 CONSTANTS This section documents constants that are used with various APIs described above =head2 LIST FILTERING The following constants are used to filter object lists =over 4 =item Sys::Virt::Interface::LIST_ACTIVE Include interfaces that are active =item Sys::Virt::Interface::LIST_INACTIVE Include interfaces that are not active =back =head2 XML CONSTANTS The following constants are used when querying XML =over 4 =item Sys::Virt::Interface::XML_INACTIVE Request the inactive XML, instead of the current possibly live config. =back =cut 1; =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006-2009 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/StorageVol.pm0000644000076500007650000001650512267462203020267 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006-2009 Red Hat # Copyright (C) 2006-2009 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::StorageVol - Represent & manage a libvirt storage volume =head1 DESCRIPTION The C module represents a storage volume managed by libvirt. A storage volume is always associated with a containing storage pool (C). =head1 METHODS =over 4 =cut package Sys::Virt::StorageVol; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $self; if (exists $params{name}) { my $pool = exists $params{pool} ? $params{pool} : die "pool parameter is requried"; $self = Sys::Virt::StorageVol::_lookup_by_name($pool, $params{name}); } elsif (exists $params{key}) { my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; $self = Sys::Virt::StorageVol::_lookup_by_key($con, $params{key}); } elsif (exists $params{path}) { my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; $self = Sys::Virt::StorageVol::_lookup_by_path($con, $params{path}); } elsif (exists $params{xml}) { my $pool = exists $params{pool} ? $params{pool} : die "pool parameter is requried"; if ($params{clone}) { $self = Sys::Virt::StorageVol::_create_xml_from($pool, $params{xml}, $params{clone}, 0); } else { $self = Sys::Virt::StorageVol::_create_xml($pool, $params{xml}, 0); } } else { die "name, key, path or xml parameters are required"; } bless $self, $class; return $self; } =item my $name = $vol->get_name() Returns a string with a locally unique name of the storage vol =item my $name = $vol->get_key() Returns a string with a globally unique key for the storage vol =item my $name = $vol->get_path() Returns a string with a locally unique file path of the storage vol =item my $xml = $vol->get_xml_description() Returns an XML document containing a complete description of the storage vol's configuration =item $vol->delete($flags) Immediately delete the storage volume freeing its storage resources. The C parameter indicates any special action to be taken when deleting the volume. =item $vol->resize($newcapacity, $flags=0) Adjust the size of the storage volume. The C<$newcapacity> value semantics depend on the C<$flags> parameter. If C<$flags> specifies C then the C<$newcapacity> is relative to the current size. If C<$flags> specifies C then the C<$newcapacity> value is the amount of space to remove =item $vol->wipe($flags = 0) Clear the data in the storage volume to avoid future information leak. The C parameter is currently unused and defaults to zero. =item $vol->wipe_pattern($algorithm, $flags = 0) Clear the data in the storage volume to avoid future information leak. The C<$algorithm> parameter specifies the data pattern used to erase data, and should be one of the WIPE ALGORITHM CONSTANTS listed later. The C parameter is currently unused and defaults to zero. =item my $info = $vol->get_info() Retrieve live information about the storage volume. The returned C<$info> hash reference contains three keys. C indicates whether the volume is a file or block device. C provides the maximum logical size of the volume. C provides the current physical usage of the volume. The allocation may be less than the capacity for sparse, or grow-on-demand volumes. The allocation may also be larger than the capacity, if there is a metadata overhead for the volume format. =item $vol->download($st, $offset, $length); Download data from C<$vol> using the stream C<$st>. If C<$offset> and C<$length> are non-zero, then restrict data to the specified volume byte range. =item $vol->upload($st, $offset, $length); Upload data to C<$vol> using the stream C<$st>. If C<$offset> and C<$length> are non-zero, then restrict data to the specified volume byte range. =back =head1 CONSTANTS The following sets of constants are useful when dealing with storage volumes =head2 VOLUME TYPES The following constants are useful for interpreting the C field in the hash returned by the C method =over 4 =item Sys::Virt::StorageVol::TYPE_FILE The volume is a plain file =item Sys::Virt::StorageVol::TYPE_BLOCK The volume is a block device =item Sys::Virt::StorageVol::TYPE_DIR The volume is a directory =item Sys::Virt::StorageVol::TYPE_NETWORK The volume is a network source =item Sys::Virt::StorageVol::TYPE_NETDIR The volume is a network directory =back =head2 CREATE MODES The following constants are useful for the C parameter of the C method =over 4 =item Sys::Virt::StorageVol::CREATE_PREALLOC_METADATA Preallocate header metadata when creating the volume. =back =head2 DELETE MODES The following constants are useful for the C parameter of the C method =over 4 =item Sys::Virt::StorageVol::DELETE_NORMAL Do a plain delete without any attempt to scrub data. =item Sys::Virt::StorageVol::DELETE_ZEROED Zero out current allocated blocks when deleteing the volume =back =head2 WIPE ALGORITHM CONSTANTS The following constants specify the algorithm for erasing data =over 4 =item Sys::Virt::StorageVol::WIPE_ALG_BSI 9-pass method recommended by the German Center of Security in Information Technologies =item Sys::Virt::StorageVol::WIPE_ALG_DOD 4-pass Dod 5220.22-M section, 8-306 procedure =item Sys::Virt::StorageVol::WIPE_ALG_GUTMANN The canonical 35-pass sequence =item Sys::Virt::StorageVol::WIPE_ALG_NNSA 4-pass NNSA Policy Letter NAP-14.1-C (XVI-8) =item Sys::Virt::StorageVol::WIPE_ALG_PFITZNER7 7-pass random =item Sys::Virt::StorageVol::WIPE_ALG_PFITZNER33 33-pass random =item Sys::Virt::StorageVol::WIPE_ALG_RANDOM 1-pass random =item Sys::Virt::StorageVol::WIPE_ALG_SCHNEIER 7-pass method described by Bruce Schneier in "Applied Cryptography" (1996) =item Sys::Virt::StorageVol::WIPE_ALG_ZERO 1-pass, all zeroes =back VOLUME RESIZE CONSTANTS The following constants control how storage volumes can be resized =over 4 =item Sys::Virt::StorageVol::RESIZE_ALLOCATE Fully allocate the extra space required during resize =item Sys::Virt::StorageVol::RESIZE_DELTA Treat the new capacity as a delta to the current capacity =item Sys::Virt::StorageVol::RESIZE_SHRINK Treat the new capacity as an amount to remove from the capacity =back =cut 1; =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006-2009 Red Hat Copyright (C) 2006-2009 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/Secret.pm0000644000076500007650000001157212267462203017426 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::Secret - Represent & manage a libvirt secret =head1 DESCRIPTION The C module represents a secret managed by the virtual machine monitor. =head1 METHODS =over 4 =cut package Sys::Virt::Secret; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; my $self; if (exists $params{usageID} || exists $params{usageType}) { die "usageID parameter must be provided with usageType" unless exists $params{usageID}; die "usageType parameter must be provided with usageID" unless exists $params{usageType}; $self = Sys::Virt::Secret::_lookup_by_usage($con, $params{usageType}, $params{usageID}); } elsif (exists $params{uuid}) { if (length($params{uuid}) == 16) { $self = Sys::Virt::Secret::_lookup_by_uuid($con, $params{uuid}); } elsif (length($params{uuid}) == 32 || length($params{uuid}) == 36) { $self = Sys::Virt::Secret::_lookup_by_uuid_string($con, $params{uuid}); } else { die "UUID must be either 16 unsigned bytes, or 32/36 hex characters long"; } } elsif (exists $params{xml}) { $self = Sys::Virt::Secret::_define_xml($con, $params{xml}); } else { die "usageID, xml or uuid parameters are required"; } bless $self, $class; return $self; } =item my $uuid = $sec->get_uuid() Returns a 16 byte long string containing the raw globally unique identifier (UUID) for the secret. =item my $uuid = $sec->get_uuid_string() Returns a printable string representation of the raw UUID, in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'. =item my $type = $sec->get_usage_type() Returns the usage type of this secret. The usage type determines the format of the unique identifier for this secret. =item my $id = $sec->get_usage_id() Returns the identifier of the object with which the secret is to be used. For secrets with a usage type of volume, the identifier is the fully qualfied path. =item my $xml = $sec->get_xml_description() Returns an XML document containing a complete description of the secret's configuration =item $sec->undefine() Remove the configuration associated with a secret previously defined with the C method in L. =item $bytes = $sec->get_value() Returns the raw bytes for the value of this secret, or undef if there is no value stored with the secret. =item $sec->set_value($bytes) Sets the value for the secret to be C<$bytes>. =back =head1 CONSTANTS This section documents constants that are used with various APIs described above =head2 SECRET USAGE TYPE The following constants refer to the different usage types =over 4 =item Sys::Virt::Secret::USAGE_TYPE_NONE The constant for secrets which are not assigned for use with a particular object =item Sys::Virt::Secret::USAGE_TYPE_VOLUME The constant for secrets which are to be used for storage volume encryption. The usage ID for secrets will refer to the fully qualified volume path. =item Sys::Virt::Secret::USAGE_TYPE_CEPH The constant for secrets which are to be used for authenticating to CEPH storage volumes. The usage ID for secrets will refer to the server name. =item Sys::Virt::Secret::USAGE_TYPE_ISCSI The constant for secrets which are to be used for authenticating to iSCSI storage volumes. The usage ID for secrets will refer to the server name. =back =head2 LIST FILTERING The following constants are used to filter object lists =over 4 =item Sys::Virt::Secret::LIST_EPHEMERAL Include any secrets marked as ephemeral =item Sys::Virt::Secret::LIST_NO_EPHEMERAL Include any secrets not marked as ephemeral =item Sys::Virt::Secret::LIST_PRIVATE Include any secrets marked as private =item Sys::Virt::Secret::LIST_NO_PRIVATE Include any secrets not marked as private =back =cut 1; =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006-2009 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/DomainSnapshot.pm0000644000076500007650000001614212267462203021126 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::DomainSnapshot - Represent & manage a libvirt guest domain =head1 DESCRIPTION The C module represents a guest domain managed by the virtual machine monitor. =head1 METHODS =over 4 =cut package Sys::Virt::DomainSnapshot; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $dom = exists $params{domain} ? $params{domain} : die "domain parameter is required"; my $self; if (exists $params{name}) { $self = Sys::Virt::DomainSnapshot::_lookup_by_name($dom, $params{name}); } elsif (exists $params{xml}) { $self = Sys::Virt::DomainSnapshot::_create_xml($dom, $params{xml}, $params{flags} ? $params{flags} : 0); } else { die "name or xml parameters are required"; } bless $self, $class; return $self; } =item my $str = $domss->get_name() Return the name of the snapshot =item my $xml = $domss->get_xml_description($flags) Returns an XML document containing a complete description of the domain's configuration. =item $domss->delete($flags) Deletes this snapshot object & its data. The optional C<$flags> parameter controls what should be deleted via the C constants. =item $domss->revert_to($flags) Revert the domain to the state associated with this snapshot. The optional C<$flags> control the state of the vm after the revert via the C constants. =item $parentss = $domss->get_parent(); Return the parent of the snapshot, if any =item $res = $domss->is_current() Returns a true value if this is the current snapshot. False otherwise. =item $res = $domss->has_metadata() Returns a true value if this snapshot has metadata associated with it. =item $count = $domss->num_of_child_snapshots() Return the number of saved snapshots which are children of this snapshot =item @names = $domss->list_child_snapshot_names() List the names of all saved snapshots which are children of this snapshot . The names can be used with the C =item @snapshots = $domss->list_child_snapshots() Return a list of all snapshots that are children of this snapshot. The elements in the returned list are instances of the L class. This method requires O(n) RPC calls, so the C method is recommended as a more efficient alternative. =cut sub list_child_snapshots { my $self = shift; my $nnames = $self->num_of_child_snapshots(); my @names = $self->list_child_snapshot_names($nnames); my @snapshots; foreach my $name (@names) { eval { push @snapshots, Sys::Virt::DomainSnapshot->_new(domain => $self, name => $name); }; if ($@) { # nada - snapshot went away before we could look it up }; } return @snapshots; } =item my @snapshots = $domss->list_all_children($flags) Return a list of all domain snapshots that are children of this snapshot. The elements in the returned list are instances of the L class. The C<$flags> parameter can be used to filter the list of return domain snapshots. =back =head1 CONSTANTS =head2 SNAPSHOT CREATION The following constants are useful when creating snapshots =over 4 =item Sys::Virt::DomainSnapshot::CREATE_CURRENT Set the defined snapshot to be the current snapshot =item Sys::Virt::DomainSnapshot::CREATE_DISK_ONLY Only snapshot the disk, not the memory state =item Sys::Virt::DomainSnapshot::CREATE_HALT Stop the guest after creating the snapshot =item Sys::Virt::DomainSnapshot::CREATE_NO_METADATA Do not save any metadata for the snapshot =item Sys::Virt::DomainSnapshot::CREATE_REDEFINE Replace/set the metadata with the snapshot =item Sys::Virt::DomainSnapshot::CREATE_QUIESCE Quiesce the guest disks while taking the snapshot =item Sys::Virt::DomainSnapshot::CREATE_REUSE_EXT Reuse the existing snapshot data files (if any) =item Sys::Virt::DomainSnapshot::CREATE_ATOMIC Create multiple disk snapshots atomically =item Sys::Virt::DomainSnapshot::CREATE_LIVE Create snapshot while the guest is running =back =head2 SNAPSHOT DELETION The following constants are useful when deleting snapshots =over 4 =item Sys::Virt::DomainSnapshot::DELETE_CHILDREN Recursively delete any child snapshots =item Sys::Virt::DomainSnapshot::DELETE_CHILDREN_ONLY Only delete the child snapshots =item Sys::Virt::DomainSnapshot::DELETE_METADATA_ONLY Only delete the snapshot metadata =back =head2 SNAPSHOT LIST The following constants are useful when listing snapshots =over 4 =item Sys::Virt::DomainSnapshot::LIST_METADATA Only list snapshots which have metadata =item Sys::Virt::DomainSnapshot::LIST_ROOTS Only list snapshots which are root nodes in the tree =item Sys::Virt::DomainSnapshot::LIST_DESCENDANTS Only list snapshots which are descendants of the current snapshot =item Sys::Virt::DomainSnapshot::LIST_LEAVES Only list leaf nodes in the snapshot tree =item Sys::Virt::DomainSnapshot::LIST_NO_LEAVES Only list non-leaf nodes in the snapshot tree =item Sys::Virt::DomainSnapshot::LIST_NO_METADATA Only list snapshots without metadata =item Sys::Virt::DomainSnapshot::LIST_ACTIVE Only list snapshots taken while the guest was running =item Sys::Virt::DomainSnapshot::LIST_INACTIVE Only list snapshots taken while the guest was inactive =item Sys::Virt::DomainSnapshot::LIST_EXTERNAL Only list snapshots stored in external disk images =item Sys::Virt::DomainSnapshot::LIST_INTERNAL Only list snapshots stored in internal disk images =item Sys::Virt::DomainSnapshot::LIST_DISK_ONLY Only list snapshots taken while the guest was running, which did not include memory state. =back =head2 SNAPSHOT REVERT The following constants are useful when reverting snapshots =over 4 =item Sys::Virt::DomainSnapshot::REVERT_PAUSED Leave the guest CPUs paused after reverting to the snapshot state =item Sys::Virt::DomainSnapshot::REVERT_RUNNING Start the guest CPUs after reverting to the snapshot state =item Sys::Virt::DomainSnapshot::REVERT_FORCE Force the snapshot to revert, even if it is risky to do so =back =over 4 =cut 1; =back =head1 AUTHORS Daniel P. Berrange =head1 COPYRIGHT Copyright (C) 2006 Red Hat Copyright (C) 2006-2007 Daniel P. Berrange =head1 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. =head1 SEE ALSO L, L, C =cut Sys-Virt-1.2.1/lib/Sys/Virt/Domain.pm0000644000076500007650000023020612267462203017405 0ustar berrangeberrange# -*- perl -*- # # Copyright (C) 2006 Red Hat # Copyright (C) 2006-2007 Daniel P. Berrange # # This program is free software; You can redistribute it and/or modify # it under either: # # a) the GNU General Public License as published by the Free # Software Foundation; either version 2, or (at your option) any # later version, # # or # # b) the "Artistic License" # # The file "LICENSE" distributed along with this file provides full # details of the terms and conditions of the two licenses. =pod =head1 NAME Sys::Virt::Domain - Represent & manage a libvirt guest domain =head1 DESCRIPTION The C module represents a guest domain managed by the virtual machine monitor. =head1 METHODS =over 4 =cut package Sys::Virt::Domain; use strict; use warnings; sub _new { my $proto = shift; my $class = ref($proto) || $proto; my %params = @_; my $con = exists $params{connection} ? $params{connection} : die "connection parameter is requried"; my $self; if (exists $params{name}) { $self = Sys::Virt::Domain::_lookup_by_name($con, $params{name}); } elsif (exists $params{id}) { $self = Sys::Virt::Domain::_lookup_by_id($con, $params{id}); } elsif (exists $params{uuid}) { if (length($params{uuid}) == 16) { $self = Sys::Virt::Domain::_lookup_by_uuid($con, $params{uuid}); } elsif (length($params{uuid}) == 32 || length($params{uuid}) == 36) { $self = Sys::Virt::Domain::_lookup_by_uuid_string($con, $params{uuid}); } else { die "UUID must be either 16 unsigned bytes, or 32/36 hex characters long"; } } elsif (exists $params{xml}) { if ($params{nocreate}) { $self = Sys::Virt::Domain::_define_xml($con, $params{xml}); } else { if (exists $params{fds}) { $self = Sys::Virt::Domain::_create_with_files($con, $params{xml}, $params{fds}, $params{flags}); } else { $self = Sys::Virt::Domain::_create($con, $params{xml}, $params{flags}); } } } else { die "address, id or uuid parameters are required"; } bless $self, $class; return $self; } =item my $id = $dom->get_id() Returns an integer with a locally unique identifier for the domain. =item my $uuid = $dom->get_uuid() Returns a 16 byte long string containing the raw globally unique identifier (UUID) for the domain. =item my $uuid = $dom->get_uuid_string() Returns a printable string representation of the raw UUID, in the format 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'. =item my $name = $dom->get_name() Returns a string with a locally unique name of the domain =item my $hostname = $dom->get_hostname() Returns a string representing the hostname of the guest =item my $str = $dom->get_metadata($type, $uri, $flags =0) Returns the metadata element of type C<$type> associated with the domain. If C<$type> is C then the C<$uri> parameter specifies the XML namespace to retrieve, otherwise C<$uri> should be C. The optional C<$flags> parameter defaults to zero. =item $dom->set_metadata($type, $val, $key, $uri, $flags=0) Sets the metadata element of type C<$type> to hold the value C<$val>. If C<$type> is C then the C<$key> and C<$uri> elements specify an XML namespace to use, otherwise they should both be C. The optional C<$flags> parameter defaults to zero. =item $dom->is_active() Returns a true value if the domain is currently running =item $dom->is_persistent() Returns a true value if the domain has a persistent configuration file defined =item $dom->is_updated() Returns a true value if the domain is running and has a persistent configuration file defined that is out of date compared to the current live config. =item my $xml = $dom->get_xml_description($flags=0) Returns an XML document containing a complete description of the domain's configuration. The optional $flags parameter controls generation of the XML document, defaulting to 0 if omitted. It can be one or more of the XML DUMP constants listed later in this document. =item my $type = $dom->get_os_type() Returns a string containing the name of the OS type running within the domain. =item $dom->create($flags) Start a domain whose configuration was previously defined using the C method in L. The C<$flags> parameter accepts one of the DOMAIN CREATION constants documented later, and defaults to 0 if omitted. =item $dom->create_with_files($fds, $flags) Start a domain whose configuration was previously defined using the C method in L. The C<$fds> parameter is an array of UNIX file descriptors which will be passed to the init process of the container. This is only supported with container based virtualization.The C<$flags> parameter accepts one of the DOMAIN CREATION constants documented later, and defaults to 0 if omitted. =item $dom->undefine() Remove the configuration associated with a domain previously defined with the C method in L. If the domain is running, you probably want to use the C or C methods instead. =item $dom->suspend() Temporarily stop execution of the domain, allowing later continuation by calling the C method. =item $dom->resume() Resume execution of a domain previously halted with the C method. =item $dom->pm_wakeup() Wakeup the guest from power management suspend state =item $dom->pm_suspend_for_duration($target, $duration, $flags=0) Tells the guest OS to enter the power management suspend state identified by C<$target>. The C<$target> parameter should be one of the NODE SUSPEND CONTANTS listed in C. The C<$duration> specifies when the guest should automatically wakeup. The C<$flags> parameter is optional and defaults to zero. =item $dom->save($filename) Take a snapshot of the domain's state and save the information to the file named in the C<$filename> parameter. The domain can later be restored from this file with the C method on the L object. =item $dom->managed_save($flags=0) 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. The C<$flags> parameter is unused and defaults to zero. =item $bool = $dom->has_managed_save_image($flags=0) Return a non-zero value if the domain has a managed save image that will be used at next start. The C<$flags> parameter is unused and defaults to zero. =item $dom->managed_save_remove($flags=0) Remove the current managed save image, causing the guest to perform a full boot next time it is started. The C<$flags> parameter is unused and defaults to zero. =item $dom->core_dump($filename[, $flags]) Trigger a core dump of the guest virtual machine, saving its memory image to C<$filename> so it can be analysed by tools such as C. The optional C<$flags> flags parameter is currently unused and if omitted will default to 0. =item $dom->destroy() Immediately poweroff the machine. This is equivalent to removing the power plug. The guest OS is given no time to cleanup / save state. For a clean poweroff sequence, use the C method instead. =item my $info = $dom->get_info() Returns a hash reference summarising the execution state of the domain. The elements of the hash are as follows: =over 4 =item maxMem The maximum memory allowed for this domain, in kilobytes =item memory The current memory allocated to the domain in kilobytes =item cpuTime The amount of CPU time used by the domain =item nrVirtCpu The current number of virtual CPUs enabled in the domain =item state The execution state of the machine, which will be one of the constants &Sys::Virt::Domain::STATE_*. =back =item my ($state, $reason) = $dom->get_state() Returns an array whose values specify the current state of the guest, and the reason for it being in that state. The C<$state> values are the same as for the C API, and the C<$reason> values come from: =over 4 =item Sys::Virt::Domain::STATE_CRASHED_UNKNOWN It is not known why the domain has crashed =item Sys::Virt::Domain::STATE_CRASHED_PANICKED The domain has crashed due to a kernel panic =item Sys::Virt::Domain::STATE_NOSTATE_UNKNOWN It is not known why the domain has no state =item Sys::Virt::Domain::STATE_PAUSED_DUMP The guest is paused due to a core dump operation =item Sys::Virt::Domain::STATE_PAUSED_FROM_SNAPSHOT The guest is paused due to a snapshot =item Sys::Virt::Domain::STATE_PAUSED_IOERROR The guest is paused due to an I/O error =item Sys::Virt::Domain::STATE_PAUSED_MIGRATION The guest is paused due to migration =item Sys::Virt::Domain::STATE_PAUSED_SAVE The guest is paused due to a save operation =item Sys::Virt::Domain::STATE_PAUSED_UNKNOWN It is not known why the domain has paused =item Sys::Virt::Domain::STATE_PAUSED_USER The guest is paused at admin request =item Sys::Virt::Domain::STATE_PAUSED_WATCHDOG The guest is paused due to the watchdog =item Sys::Virt::Domain::STATE_PAUSED_SHUTTING_DOWN The guest is paused while domain shutdown takes place =item Sys::Virt::Domain::STATE_PAUSED_SNAPSHOT The guest is paused while a snapshot takes place =item Sys::Virt::Domain::STATE_PAUSED_CRASHED The guest is paused due to a kernel panic =item Sys::Virt::Domain::STATE_RUNNING_BOOTED The guest is running after being booted =item Sys::Virt::Domain::STATE_RUNNING_FROM_SNAPSHOT The guest is running after restore from snapshot =item Sys::Virt::Domain::STATE_RUNNING_MIGRATED The guest is running after migration =item Sys::Virt::Domain::STATE_RUNNING_MIGRATION_CANCELED The guest is running after migration abort =item Sys::Virt::Domain::STATE_RUNNING_RESTORED The guest is running after restore from file =item Sys::Virt::Domain::STATE_RUNNING_SAVE_CANCELED The guest is running after save cancel =item Sys::Virt::Domain::STATE_RUNNING_UNKNOWN It is not known why the domain has started =item Sys::Virt::Domain::STATE_RUNNING_UNPAUSED The guest is running after a resume =item Sys::Virt::Domain::STATE_RUNNING_WAKEUP The guest is running after wakeup from power management suspend =item Sys::Virt::Domain::STATE_RUNNING_CRASHED The guest was restarted after crashing =item Sys::Virt::Domain::STATE_BLOCKED_UNKNOWN The guest is blocked for an unknown reason =item Sys::Virt::Domain::STATE_SHUTDOWN_UNKNOWN It is not known why the domain has shutdown =item Sys::Virt::Domain::STATE_SHUTDOWN_USER The guest is shutdown due to admin request =item Sys::Virt::Domain::STATE_SHUTOFF_CRASHED The guest is shutoff after a crash =item Sys::Virt::Domain::STATE_SHUTOFF_DESTROYED The guest is shutoff after being destroyed =item Sys::Virt::Domain::STATE_SHUTOFF_FAILED The guest is shutoff due to a virtualization failure =item Sys::Virt::Domain::STATE_SHUTOFF_FROM_SNAPSHOT The guest is shutoff after a snapshot =item Sys::Virt::Domain::STATE_SHUTOFF_MIGRATED The guest is shutoff after migration =item Sys::Virt::Domain::STATE_SHUTOFF_SAVED The guest is shutoff after a save =item Sys::Virt::Domain::STATE_SHUTOFF_SHUTDOWN The guest is shutoff due to controlled shutdown =item Sys::Virt::Domain::STATE_SHUTOFF_UNKNOWN It is not known why the domain has shutoff =item Sys::Virt::Domain::STATE_PMSUSPENDED_UNKNOWN It is not known why the domain was suspended to RAM =item Sys::Virt::Domain::STATE_PMSUSPENDED_DISK_UNKNOWN It is not known why the domain was suspended to disk =back =item my $info = $dom->get_control_info($flags=0) Returns a hash reference providing information about the control channel. The returned keys in the hash are =over 4 =item C One of the CONTROL INFO constants listed later =item C
Currently unsed, always 0. =item C The elapsed time since the control channel entered the current state. =back =item my @errs = $dom->get_disk_errors($flags=0) Returns a list of all disk errors that have occurred on the backing store for the guest's virtual disks. The returned array elements are hash references, containing two keys =over 4 =item C The path of the disk with an error =item C The error type =back =item $dom->send_key($keycodeset, $holdtime, \@keycodes, $flags=0) Sends a sequence of keycodes to the guest domain. The C<$keycodeset> should be one of the constants listed later in the KEYCODE SET section. C<$holdtiem> is the duration, in milliseconds, to keep the key pressed before releasing it and sending the next keycode. C<@keycodes> is an array reference containing the list of keycodes to send to the guest. The elements in the array should be keycode values from the specified keycode set. C<$flags> is currently unused. =item my $info = $dom->get_block_info($dev, $flags=0) Returns a hash reference summarising the disk usage of the host backing store for a guest block device. The C<$dev> parameter should be the path to the backing store on the host. C<$flags> is currently unused and defaults to 0 if omitted. The returned hash contains the following elements =over 4 =item capacity Logical size in bytes of the block device backing image * =item allocation Highest allocated extent in bytes of the block device backing image =item physical Physical size in bytes of the container of the backing image =back =item $dom->set_max_memory($mem) Set the maximum memory for the domain to the value C<$mem>. The value of the C<$mem> parameter is specified in kilobytes. =item $mem = $dom->get_max_memory() Returns the current maximum memory allowed for this domain in kilobytes. =item $dom->set_memory($mem, $flags) Set the current memory for the domain to the value C<$mem>. The value of the C<$mem> parameter is specified in kilobytes. This must be less than, or equal to the domain's max memory limit. The C<$flags> parameter can control whether the update affects the live guest, or inactive config, defaulting to modifying the current state. =item $dom->set_memory_stats_period($period, $flags) Set the period on which guests memory stats are refreshed, with C<$period> being a value in seconds. The C<$flags> parameter is currently unused. =item $dom->shutdown() Request that the guest OS perform a graceful shutdown and poweroff. This usually requires some form of cooperation from the guest operating system, such as responding to an ACPI signal, or a guest agent process. For an immediate, forceful poweroff, use the C method instead. =item $dom->reboot([$flags]) Request that the guest OS perform a graceful shutdown and optionally restart. The optional C<$flags> parameter is currently unused and if omitted defaults to zero. =item $dom->reset([$flags]) Perform a hardware reset of the virtual machine. The guest OS is given no opportunity to shutdown gracefully. The optional C<$flags> parameter is currently unused and if omitted defaults to zero. =item $dom->get_max_vcpus() Return the maximum number of vcpus that are configured for the domain =item $dom->attach_device($xml[, $flags]) Hotplug a new device whose configuration is given by C<$xml>, to the running guest. The optional <$flags> parameter defaults to 0, but can accept one of the device hotplug flags described later. =item $dom->detach_device($xml[, $flags]) Hotunplug a existing device whose configuration is given by C<$xml>, from the running guest. The optional <$flags> parameter defaults to 0, but can accept one of the device hotplug flags described later. =item $dom->update_device($xml[, $flags]) Update the configuration of an existing device. The new configuration is given by C<$xml>. The optional <$flags> parameter defaults to 0 but can accept one of the device hotplug flags described later. =item $data = $dom->block_peek($path, $offset, $size[, $flags]) Peek into the guest disk C<$path>, at byte C<$offset> capturing C<$size> bytes of data. The returned scalar may contain embedded NULLs. The optional C<$flags> parameter is currently unused and if omitted defaults to zero. =item $data = $dom->memory_peek($offset, $size[, $flags]) Peek into the guest memory at byte C<$offset> virtual address, capturing C<$size> bytes of memory. The return scalar may contain embedded NULLs. The optional C<$flags> parameter is currently unused and if omitted defaults to zero. =item $flag = $dom->get_autostart(); Return a true value if the guest domain is configured to automatically start upon boot. Return false, otherwise =item $dom->set_autostart($flag) Set the state of the autostart flag, which determines whether the guest will automatically start upon boot of the host OS =item $dom->set_vcpus($count, [$flags]) Set the number of virtual CPUs in the guest VM to C<$count>. The optional C<$flags> parameter can be used to control whether the setting changes the live config or inactive config. =item $count = $dom->get_vcpus([$flags]) Get the number of virtual CPUs in the guest VM. The optional C<$flags> parameter can be used to control whether to query the setting of the live config or inactive config. =item $type = $dom->get_scheduler_type() Return the scheduler type for the guest domain =item $stats = $dom->block_stats($path) Fetch the current I/O statistics for the block device given by C<$path>. The returned hash reference contains keys for =over 4 =item C Number of read requests =item C Number of bytes read =item C Number of write requests =item C Number of bytes written =item C Some kind of error count =back =item my $params = $dom->get_scheduler_parameters($flags=0) Return the set of scheduler tunable parameters for the guest, as a hash reference. The precise set of keys in the hash are specific to the hypervisor. =item $dom->set_scheduler_parameters($params, $flags=0) Update the set of scheduler tunable parameters. The value names for tunables vary, and can be discovered using the C call =item my $params = $dom->get_memory_parameters($flags=0) Return a hash reference containing the set of memory tunable parameters for the guest. The keys in the hash are one of the constants MEMORY PARAMETERS described later. The C<$flags> parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted. =item $dom->set_memory_parameters($params, $flags=0) Update the memory tunable parameters for the guest. The C<$params> should be a hash reference whose keys are one of the MEMORY PARAMETERS constants. The C<$flags> parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted. =item my $params = $dom->get_blkio_parameters($flags=0) Return a hash reference containing the set of blkio tunable parameters for the guest. The keys in the hash are one of the constants BLKIO PARAMETERS described later. The C<$flags> parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted. =item $dom->set_blkio_parameters($params, $flags=0) Update the blkio tunable parameters for the guest. The C<$params> should be a hash reference whose keys are one of the BLKIO PARAMETERS constants. The C<$flags> parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted. =item $stats = $dom->get_block_iotune($disk, $flags=0) Return a hash reference containing the set of blkio tunable parameters for the guest disk C<$disk>. The keys in the hash are one of the constants BLOCK IOTUNE PARAMETERS described later. =item $dom->set_block_iotune($disk, $params, $flags=0); Update the blkio tunable parameters for the guest disk C<$disk>. The C<$params> should be a hash reference whose keys are one of the BLOCK IOTUNE PARAMETERS constants. =item my $params = $dom->get_interface_parameters($intf, $flags=0) Return a hash reference containing the set of interface tunable parameters for the guest. The keys in the hash are one of the constants INTERFACE PARAMETERS described later. =item $dom->set_interface_parameters($intf, $params, $flags=0) Update the interface tunable parameters for the guest. The C<$params> should be a hash reference whose keys are one of the INTERFACE PARAMETERS constants. =item my $params = $dom->get_numa_parameters($flags=0) Return a hash reference containing the set of numa tunable parameters for the guest. The keys in the hash are one of the constants NUMA PARAMETERS described later. The C<$flags> parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted. =item $dom->set_numa_parameters($params, $flags=0) Update the numa tunable parameters for the guest. The C<$params> should be a hash reference whose keys are one of the NUMA PARAMETERS constants. The C<$flags> parameter accepts one or more the CONFIG OPTION constants documented later, and defaults to 0 if omitted. =item $dom->block_resize($disk, $newsize, $flags=0) Resize the disk C<$disk> to have new size C<$newsize> KB. If the disk is backed by a special image format, the actual resize is done by the hypervisor. If the disk is backed by a raw file, or block device, the resize must be done prior to invoking this API call, and it merely updates the hypervisor's view of the disk size. The following flags may be used =over 4 =item Sys::Virt::Domain::BLOCK_RESIZE_BYTES Treat C<$newsize> as if it were in bytes, rather than KB. =back =item $dom->interface_stats($path) Fetch the current I/O statistics for the block device given by C<$path>. The returned hash containins keys for =over 4 =item C Total bytes received =item C Total packets received =item C Total packets received with errors =item C Total packets drop at reception =item C Total bytes transmitted =item C Total packets transmitted =item C Total packets transmitted with errors =item C Total packets dropped at transmission. =back =item $dom->memory_stats($flags=0) Fetch the current memory statistics for the guest domain. The C<$flags> parameter is currently unused and can be omitted. The returned hash containins keys for =over 4 =item C Data read from swap space =item C Data written to swap space =item C Page fault involving disk I/O =item C Page fault not involving disk I/O =item C Memory not used by the system =item C Total memory seen by guest =back =item $info = $dom->get_security_label() Fetch information about the security label assigned to the guest domain. The returned hash reference has two keys, C gives the name of the security model in effect (eg C), while C