| 1 |
# -*- perl -*- |
| 2 |
# |
| 3 |
# Copyright (C) 2006 Red Hat |
| 4 |
# Copyright (C) 2006-2007 Daniel P. Berrange |
| 5 |
# |
| 6 |
# This program is free software; You can redistribute it and/or modify |
| 7 |
# it under either: |
| 8 |
# |
| 9 |
# a) the GNU General Public License as published by the Free |
| 10 |
# Software Foundation; either version 2, or (at your option) any |
| 11 |
# later version, |
| 12 |
# |
| 13 |
# or |
| 14 |
# |
| 15 |
# b) the "Artistic License" |
| 16 |
# |
| 17 |
# The file "LICENSE" distributed along with this file provides full |
| 18 |
# details of the terms and conditions of the two licenses. |
| 19 |
|
| 20 |
=pod |
| 21 |
|
| 22 |
=head1 NAME |
| 23 |
|
| 24 |
Sys::Virt - Represent and manage a libvirt hypervisor connection |
| 25 |
|
| 26 |
=head1 SYNOPSIS |
| 27 |
|
| 28 |
my $conn = Sys::Virt->new(uri => $uri); |
| 29 |
|
| 30 |
my @domains = $conn->list_domains(); |
| 31 |
|
| 32 |
foreach my $dom (@domains) { |
| 33 |
print "Domain ", $dom->get_id, " ", $dom->get_name, "\n"; |
| 34 |
} |
| 35 |
|
| 36 |
=head1 DESCRIPTION |
| 37 |
|
| 38 |
The Sys::Virt module provides a Perl XS binding to the libvirt |
| 39 |
virtual machine management APIs. This allows machines running |
| 40 |
within arbitrary virtualization containers to be managed with |
| 41 |
a consistent API. |
| 42 |
|
| 43 |
=head1 CALLBACK HANDLING |
| 44 |
|
| 45 |
Each callback registration routine returns a C<$callbackID> (except for |
| 46 |
C<domain_event_register> and C<register_close_callback>). This return value |
| 47 |
must be retained and used for callback deregistration. |
| 48 |
|
| 49 |
B<IMPORTANT:> All callbacks must be deregistered (including the ones |
| 50 |
registered using C<domain_event_register> and C<register_close_callback>); |
| 51 |
failing to do so prevents the C<Sys::Virt> object from being garbage collected |
| 52 |
and the connection to C<libvirtd> from being closed. |
| 53 |
|
| 54 |
=head1 ERROR HANDLING |
| 55 |
|
| 56 |
Any operations in the Sys::Virt API which have failure scenarios |
| 57 |
will result in an instance of the L<Sys::Virt::Error> module being |
| 58 |
thrown. To catch these errors, simply wrap the method in an eval |
| 59 |
block: |
| 60 |
|
| 61 |
eval { my $conn = Sys::Virt->new(uri => $uri); }; |
| 62 |
if ($@) { |
| 63 |
print STDERR "Unable to open connection to $addr" . $@->message . "\n"; |
| 64 |
} |
| 65 |
|
| 66 |
For details of the information contained in the error objects, |
| 67 |
consult the L<Sys::Virt::Error> manual page. |
| 68 |
|
| 69 |
=head1 METHODS |
| 70 |
|
| 71 |
=over 4 |
| 72 |
|
| 73 |
=cut |
| 74 |
|
| 75 |
package Sys::Virt; |
| 76 |
|
| 77 |
use strict; |
| 78 |
use warnings; |
| 79 |
|
| 80 |
use Sys::Virt::Error; |
| 81 |
use Sys::Virt::Domain; |
| 82 |
use Sys::Virt::Network; |
| 83 |
use Sys::Virt::NetworkPort; |
| 84 |
use Sys::Virt::StoragePool; |
| 85 |
use Sys::Virt::StorageVol; |
| 86 |
use Sys::Virt::NodeDevice; |
| 87 |
use Sys::Virt::Interface; |
| 88 |
use Sys::Virt::Secret; |
| 89 |
use Sys::Virt::NWFilter; |
| 90 |
use Sys::Virt::NWFilterBinding; |
| 91 |
use Sys::Virt::DomainSnapshot; |
| 92 |
use Sys::Virt::DomainCheckpoint; |
| 93 |
use Sys::Virt::Stream; |
| 94 |
|
| 95 |
our $VERSION = '12.7.0'; |
| 96 |
require XSLoader; |
| 97 |
XSLoader::load('Sys::Virt', $VERSION); |
| 98 |
|
| 99 |
=item my $conn = Sys::Virt->new(uri => $uri, readonly => $ro, flags => $flags); |
| 100 |
|
| 101 |
Attach to the virtualization host identified by C<uri>. The |
| 102 |
C<uri> parameter may be omitted, in which case the default connection made |
| 103 |
will be to the local Xen hypervisor. Some example URIs include: |
| 104 |
|
| 105 |
=over 4 |
| 106 |
|
| 107 |
=item xen:/// |
| 108 |
|
| 109 |
Xen on the local machine |
| 110 |
|
| 111 |
=item test:///default |
| 112 |
|
| 113 |
Dummy "in memory" driver for test suites |
| 114 |
|
| 115 |
=item qemu:///system |
| 116 |
|
| 117 |
System-wide driver for QEMU / KVM virtualization |
| 118 |
|
| 119 |
=item qemu:///session |
| 120 |
|
| 121 |
Per-user driver for QEMU virtualization |
| 122 |
|
| 123 |
=item qemu+tls://somehost/system |
| 124 |
|
| 125 |
System-wide QEMU driver on C<somehost> using TLS security |
| 126 |
|
| 127 |
=item xen+tcp://somehost/ |
| 128 |
|
| 129 |
Xen driver on C<somehost> using TCP / SASL security |
| 130 |
|
| 131 |
=back |
| 132 |
|
| 133 |
For further details consult C<http://libvirt.org/uri.html> |
| 134 |
|
| 135 |
If the optional C<readonly> parameter is supplied, then an unprivileged |
| 136 |
connection to the hypervisor will be attempted. If it is not supplied, then it |
| 137 |
defaults to making a fully privileged connection to the hypervisor. If the |
| 138 |
calling application is not running as root, it may be necessary to |
| 139 |
provide authentication callbacks. |
| 140 |
|
| 141 |
If the optional C<auth> parameter is set to a non-zero value, |
| 142 |
authentication will be enabled during connection, using the |
| 143 |
default set of credential gathering callbacks. The default |
| 144 |
callbacks prompt for credentials on the console, so are not |
| 145 |
suitable for graphical applications. For such apps a custom |
| 146 |
implementation should be supplied. The C<credlist> parameter |
| 147 |
should be an array reference listing the set of credential |
| 148 |
types that will be supported. The credential constants in |
| 149 |
this module can be used as values in this list. The C<callback> |
| 150 |
parameter should be a subroutine reference containing the |
| 151 |
code necessary to gather the credentials. When invoked it |
| 152 |
will be supplied with a single parameter, an array reference |
| 153 |
of requested credentials. The elements of the array are |
| 154 |
hash references, with keys C<type> giving the type of |
| 155 |
credential, C<prompt> giving a user descriptive user |
| 156 |
prompt, C<challenge> giving name of the credential |
| 157 |
required. The answer should be collected from the user, and |
| 158 |
returned by setting the C<result> key. This key may already |
| 159 |
be set with a default result if applicable |
| 160 |
|
| 161 |
As a simple example returning hardcoded credentials |
| 162 |
|
| 163 |
my $uri = "qemu+tcp://192.168.122.1/system"; |
| 164 |
my $username = "test"; |
| 165 |
my $password = "123456"; |
| 166 |
|
| 167 |
my $con = Sys::Virt->new(uri => $uri, |
| 168 |
auth => 1, |
| 169 |
credlist => [ |
| 170 |
Sys::Virt::CRED_AUTHNAME, |
| 171 |
Sys::Virt::CRED_PASSPHRASE, |
| 172 |
], |
| 173 |
callback => |
| 174 |
sub { |
| 175 |
my $creds = shift; |
| 176 |
|
| 177 |
foreach my $cred (@{$creds}) { |
| 178 |
if ($cred->{type} == Sys::Virt::CRED_AUTHNAME) { |
| 179 |
$cred->{result} = $username; |
| 180 |
} |
| 181 |
if ($cred->{type} == Sys::Virt::CRED_PASSPHRASE) { |
| 182 |
$cred->{result} = $password; |
| 183 |
} |
| 184 |
} |
| 185 |
return 0; |
| 186 |
}); |
| 187 |
|
| 188 |
|
| 189 |
For backwards compatibility with earlier releases, the C<address> |
| 190 |
parameter is accepted as a synonym for the C<uri> parameter. The |
| 191 |
use of C<uri> is recommended for all newly written code. |
| 192 |
|
| 193 |
=cut |
| 194 |
|
| 195 |
sub new { |
| 196 |
my $proto = shift; |
| 197 |
my $class = ref($proto) || $proto; |
| 198 |
my %params = @_; |
| 199 |
|
| 200 |
my $uri = exists $params{address} ? $params{address} : exists $params{uri} ? $params{uri} : undef; |
| 201 |
my $flags = exists $params{flags} ? $params{flags} : 0; |
| 202 |
if ($params{readonly}) { |
| 203 |
$flags |= &Sys::Virt::CONNECT_RO; |
| 204 |
} |
| 205 |
my $auth = exists $params{auth} ? $params{auth} : 0; |
| 206 |
|
| 207 |
my $authcb = exists $params{callback} ? $params{callback} : undef; |
| 208 |
my $credlist = exists $params{credlist} ? $params{credlist} : undef; |
| 209 |
|
| 210 |
my $self; |
| 211 |
|
| 212 |
if ($auth) { |
| 213 |
$self = Sys::Virt::_open_auth($uri, $credlist, $authcb, $flags); |
| 214 |
} else { |
| 215 |
$self = Sys::Virt::_open($uri, $flags); |
| 216 |
} |
| 217 |
|
| 218 |
bless $self, $class; |
| 219 |
|
| 220 |
return $self; |
| 221 |
} |
| 222 |
|
| 223 |
=item $conn->set_identity($identity, $flags=0) |
| 224 |
|
| 225 |
Change the identity that is used for access control over the |
| 226 |
connection. Normally the remote daemon will use the identity |
| 227 |
associated with the UNIX domain socket that the app opens. |
| 228 |
Only a privileged client is usually able to override this. |
| 229 |
The C<$identity> should be a hash reference whose keys are |
| 230 |
one of the IDENTITY constants. The C<$flags> parameter is |
| 231 |
currently unused, and defaults to 0 if omitted. |
| 232 |
|
| 233 |
=item my $st = $conn->new_stream($flags) |
| 234 |
|
| 235 |
Create a new stream, with the given flags |
| 236 |
|
| 237 |
=cut |
| 238 |
|
| 239 |
sub new_stream { |
| 240 |
my $self = shift; |
| 241 |
my $flags = shift || 0; |
| 242 |
|
| 243 |
return Sys::Virt::Stream->_new(connection => $self, flags => $flags); |
| 244 |
} |
| 245 |
|
| 246 |
|
| 247 |
=item my $dom = $conn->create_domain($xml, $flags=0); |
| 248 |
|
| 249 |
Create a new domain based on the XML description passed into the C<$xml> |
| 250 |
parameter. The returned object is an instance of the L<Sys::Virt::Domain> |
| 251 |
class. This method is not available with unprivileged connections to |
| 252 |
the hypervisor. The C<$flags> parameter accepts one of the DOMAIN CREATION |
| 253 |
constants documented in L<Sys::Virt::Domain>, and defaults to 0 if omitted. |
| 254 |
|
| 255 |
=cut |
| 256 |
|
| 257 |
sub create_domain { |
| 258 |
my $self = shift; |
| 259 |
my $xml = shift; |
| 260 |
my $flags = shift || 0; |
| 261 |
|
| 262 |
return Sys::Virt::Domain->_new(connection => $self, xml => $xml, flags => $flags); |
| 263 |
} |
| 264 |
|
| 265 |
=item my $dom = $conn->create_domain_with_files($xml, $fds, $flags=0); |
| 266 |
|
| 267 |
Create a new domain based on the XML description passed into the C<$xml> |
| 268 |
parameter. The returned object is an instance of the L<Sys::Virt::Domain> |
| 269 |
class. This method is not available with unprivileged connections to |
| 270 |
the hypervisor. The C<$fds> parameter is an array of UNIX file descriptors |
| 271 |
which will be passed to the init process of the container. This is |
| 272 |
only supported with container based virtualization. The C<$flags> |
| 273 |
parameter accepts one of the DOMAIN CREATION constants documented |
| 274 |
in L<Sys::Virt::Domain>, and defaults to 0 if omitted. |
| 275 |
|
| 276 |
=cut |
| 277 |
|
| 278 |
sub create_domain_with_files { |
| 279 |
my $self = shift; |
| 280 |
my $xml = shift; |
| 281 |
my $fds = shift; |
| 282 |
my $flags = shift || 0; |
| 283 |
|
| 284 |
return Sys::Virt::Domain->_new(connection => $self, xml => $xml, |
| 285 |
fds => $fds, flags => $flags); |
| 286 |
} |
| 287 |
|
| 288 |
=item my $dom = $conn->define_domain($xml, $flags=0); |
| 289 |
|
| 290 |
Defines, but does not start, a new domain based on the XML description |
| 291 |
passed into the C<$xml> parameter. The returned object is an instance |
| 292 |
of the L<Sys::Virt::Domain> class. This method is not available with |
| 293 |
unprivileged connections to the hypervisor. The defined domain can be later started |
| 294 |
by calling the C<create> method on the returned C<Sys::Virt::Domain> |
| 295 |
object. The C<$flags> parameter accepts one of the DOMAIN DEFINE constants |
| 296 |
documented in L<Sys::Virt::Domain>, and defaults to 0 if omitted. |
| 297 |
|
| 298 |
=cut |
| 299 |
|
| 300 |
sub define_domain { |
| 301 |
my $self = shift; |
| 302 |
my $xml = shift; |
| 303 |
my $flags = shift || 0; |
| 304 |
|
| 305 |
return Sys::Virt::Domain->_new(connection => $self, xml => $xml, nocreate => 1, flags => $flags); |
| 306 |
} |
| 307 |
|
| 308 |
=item my $net = $conn->create_network($xml, $flags=0); |
| 309 |
|
| 310 |
Create a new network based on the XML description passed into the C<$xml> |
| 311 |
parameter. The returned object is an instance of the L<Sys::Virt::Network> |
| 312 |
class. This method is not available with unprivileged connections to |
| 313 |
the hypervisor. The C<$flags> parameter accepts one of the NETWORK CREATION |
| 314 |
constants documented in L<Sys::Virt::Network>, and defaults to 0 if omitted. |
| 315 |
|
| 316 |
=cut |
| 317 |
|
| 318 |
sub create_network { |
| 319 |
my $self = shift; |
| 320 |
my $xml = shift; |
| 321 |
my $flags = shift || 0; |
| 322 |
|
| 323 |
return Sys::Virt::Network->_new(connection => $self, xml => $xml, flags => $flags); |
| 324 |
} |
| 325 |
|
| 326 |
=item my $net = $conn->define_network($xml, $flags=0); |
| 327 |
|
| 328 |
Defines, but does not start, a new network based on the XML description |
| 329 |
passed into the C<$xml> parameter. The returned object is an instance |
| 330 |
of the L<Sys::Virt::Network> class. This method is not available with |
| 331 |
unprivileged connections to the hypervisor. The defined network can be later started |
| 332 |
by calling the C<create> method on the returned C<Sys::Virt::Network> |
| 333 |
object. The C<$flags> parameter accepts one of the NETWORK DEFINE constants |
| 334 |
documented in L<Sys::Virt::Network>, and defaults to 0 if omitted. |
| 335 |
|
| 336 |
=cut |
| 337 |
|
| 338 |
sub define_network { |
| 339 |
my $self = shift; |
| 340 |
my $xml = shift; |
| 341 |
my $flags = shift || 0; |
| 342 |
|
| 343 |
return Sys::Virt::Network->_new(connection => $self, xml => $xml, nocreate => 1, flags => $flags); |
| 344 |
} |
| 345 |
|
| 346 |
=item my $nwfilter = $conn->define_nwfilter($xml, $flags=0); |
| 347 |
|
| 348 |
Defines a new network filter based on the XML description |
| 349 |
passed into the C<$xml> parameter. The returned object is an instance |
| 350 |
of the L<Sys::Virt::NWFilter> class. This method is not available with |
| 351 |
unprivileged connections to the hypervisor. The C<$flags> parameter accepts |
| 352 |
one of the NWFILTER DEFINE constants documented in L<Sys::Virt::NWFilter>, |
| 353 |
and defaults to 0 if omitted. |
| 354 |
|
| 355 |
=cut |
| 356 |
|
| 357 |
sub define_nwfilter { |
| 358 |
my $self = shift; |
| 359 |
my $xml = shift; |
| 360 |
my $flags = shift || 0; |
| 361 |
|
| 362 |
return Sys::Virt::NWFilter->_new(connection => $self, xml => $xml, nocreate => 1, flags => $flags); |
| 363 |
} |
| 364 |
|
| 365 |
=item my $binding = $conn->create_nwfilter_binding($xml, $flags=0); |
| 366 |
|
| 367 |
Create a new network filter binding based on the XML description passed into the C<$xml> |
| 368 |
parameter. The returned object is an instance of the L<Sys::Virt::NWFilterBinding> |
| 369 |
class. The C<$flags> parameter accepts one of the NETWORK FILTER BINDING |
| 370 |
CREATION constants documented in L<Sys::Virt::NWFilterBinding>, and defaults to |
| 371 |
0 if omitted. |
| 372 |
|
| 373 |
=cut |
| 374 |
|
| 375 |
sub create_nwfilter_binding { |
| 376 |
my $self = shift; |
| 377 |
my $xml = shift; |
| 378 |
my $flags = shift || 0; |
| 379 |
|
| 380 |
return Sys::Virt::NWFilterBinding->_new(connection => $self, xml => $xml, flags => $flags); |
| 381 |
} |
| 382 |
|
| 383 |
=item my $secret = $conn->define_secret($xml, $flags=0); |
| 384 |
|
| 385 |
Defines a new secret based on the XML description |
| 386 |
passed into the C<$xml> parameter. The returned object is an instance |
| 387 |
of the L<Sys::Virt::Secret> class. This method is not available with |
| 388 |
unprivileged connections to the hypervisor. The C<$flags> parameter |
| 389 |
accepts one of the SECRET DEFINE constants documented in |
| 390 |
L<Sys::Virt::Secret>, and defaults to 0 if omitted. |
| 391 |
|
| 392 |
=cut |
| 393 |
|
| 394 |
sub define_secret { |
| 395 |
my $self = shift; |
| 396 |
my $xml = shift; |
| 397 |
my $flags = shift || 0; |
| 398 |
|
| 399 |
return Sys::Virt::Secret->_new(connection => $self, xml => $xml, nocreate => 1, flags => $flags); |
| 400 |
} |
| 401 |
|
| 402 |
=item my $pool = $conn->create_storage_pool($xml); |
| 403 |
|
| 404 |
Create a new storage pool based on the XML description passed into the C<$xml> |
| 405 |
parameter. The returned object is an instance of the L<Sys::Virt::StoragePool> |
| 406 |
class. This method is not available with unprivileged connections to |
| 407 |
the hypervisor. |
| 408 |
|
| 409 |
=cut |
| 410 |
|
| 411 |
sub create_storage_pool { |
| 412 |
my $self = shift; |
| 413 |
my $xml = shift; |
| 414 |
|
| 415 |
return Sys::Virt::StoragePool->_new(connection => $self, xml => $xml); |
| 416 |
} |
| 417 |
|
| 418 |
=item my $pool = $conn->define_storage_pool($xml, $flags=0); |
| 419 |
|
| 420 |
Defines, but does not start, a new storage pol based on the XML description |
| 421 |
passed into the C<$xml> parameter. The returned object is an instance |
| 422 |
of the L<Sys::Virt::StoragePool> class. This method is not available with |
| 423 |
unprivileged connections to the hypervisor. The defined pool can be later started |
| 424 |
by calling the C<create> method on the returned C<Sys::Virt::StoragePool> |
| 425 |
object. The C<$flags> parameter accepts one of the STORAGE POOL DEFINE |
| 426 |
constants documented in L<Sys::Virt::StoragePool>, and defaults to 0 if omitted. |
| 427 |
|
| 428 |
=cut |
| 429 |
|
| 430 |
sub define_storage_pool { |
| 431 |
my $self = shift; |
| 432 |
my $xml = shift; |
| 433 |
my $flags = shift || 0; |
| 434 |
|
| 435 |
return Sys::Virt::StoragePool->_new(connection => $self, xml => $xml, nocreate => 1, flags => $flags); |
| 436 |
} |
| 437 |
|
| 438 |
=item my $pool = $conn->create_interface($xml); |
| 439 |
|
| 440 |
Create a new interface based on the XML description passed into the C<$xml> |
| 441 |
parameter. The returned object is an instance of the L<Sys::Virt::Interface> |
| 442 |
class. This method is not available with unprivileged connections to |
| 443 |
the hypervisor. |
| 444 |
|
| 445 |
=cut |
| 446 |
|
| 447 |
sub create_interface { |
| 448 |
my $self = shift; |
| 449 |
my $xml = shift; |
| 450 |
|
| 451 |
return Sys::Virt::Interface->_new(connection => $self, xml => $xml); |
| 452 |
} |
| 453 |
|
| 454 |
=item my $iface = $conn->define_interface($xml, $flags=0); |
| 455 |
|
| 456 |
Defines, but does not start, a new interface based on the XML description |
| 457 |
passed into the C<$xml> parameter. The returned object is an instance |
| 458 |
of the L<Sys::Virt::Interface> class. This method is not available with |
| 459 |
unprivileged connections to the hypervisor. The defined interface can be later started |
| 460 |
by calling the C<create> method on the returned C<Sys::Virt::Interface> |
| 461 |
object. The C<$flags> parameter accepts one of the INTERFACE DEFINE constants |
| 462 |
documented in L<Sys::Virt::Interface>, and defaults to 0 if omitted. |
| 463 |
|
| 464 |
|
| 465 |
=cut |
| 466 |
|
| 467 |
sub define_interface { |
| 468 |
my $self = shift; |
| 469 |
my $xml = shift; |
| 470 |
my $flags = shift || 0; |
| 471 |
|
| 472 |
return Sys::Virt::Interface->_new(connection => $self, xml => $xml, nocreate => 1, flags => $flags); |
| 473 |
} |
| 474 |
|
| 475 |
=item my $dev = $conn->create_node_device($xml, $flags=0); |
| 476 |
|
| 477 |
Create a new virtual node device based on the XML description passed into the |
| 478 |
C<$xml> parameter. The returned object is an instance of the |
| 479 |
L<Sys::Virt::NodeDevice> class. This method is not available with unprivileged |
| 480 |
connections to the hypervisor. The C<$flags> parameter accepts one of the NODE |
| 481 |
DEVICE CREATION constants documented in L<Sys::Virt::NodeDevice>, and defaults |
| 482 |
to 0 if omitted. |
| 483 |
|
| 484 |
=cut |
| 485 |
|
| 486 |
sub create_node_device { |
| 487 |
my $self = shift; |
| 488 |
my $xml = shift; |
| 489 |
my $flags = shift || 0; |
| 490 |
|
| 491 |
return Sys::Virt::NodeDevice->_new(connection => $self, xml => $xml, flags => $flags); |
| 492 |
} |
| 493 |
|
| 494 |
=item my $dev = $conn->define_node_device($xml, $flags=0); |
| 495 |
|
| 496 |
Defines, but does not start, a new node dev based on the XML description |
| 497 |
passed into the C<$xml> parameter. The returned object is an instance |
| 498 |
of the L<Sys::Virt::NodeDevice> class. This method is not available with |
| 499 |
unprivileged connections to the hypervisor. The defined node device can |
| 500 |
be later started by calling the C<create> method on the returned |
| 501 |
C<Sys::Virt::NodeDevice> object. The C<$flags> parameter accepts one of the |
| 502 |
NODE DEVICE DEFINE constants documented in L<Sys::Virt::NodeDevice>, and |
| 503 |
defaults to 0 if omitted. |
| 504 |
|
| 505 |
=cut |
| 506 |
|
| 507 |
sub define_node_device { |
| 508 |
my $self = shift; |
| 509 |
my $xml = shift; |
| 510 |
my $flags = shift || 0; |
| 511 |
|
| 512 |
return Sys::Virt::NodeDevice->_new(connection => $self, xml => $xml, flags => $flags, nocreate => 1); |
| 513 |
} |
| 514 |
|
| 515 |
|
| 516 |
=item my @doms = $conn->list_domains() |
| 517 |
|
| 518 |
Return a list of all running domains currently known to the hypervisor. The elements |
| 519 |
in the returned list are instances of the L<Sys::Virt::Domain> class. This |
| 520 |
method requires O(n) RPC calls, so the C<list_all_domains> method is |
| 521 |
recommended as a more efficient alternative. |
| 522 |
|
| 523 |
=cut |
| 524 |
|
| 525 |
sub list_domains { |
| 526 |
my $self = shift; |
| 527 |
|
| 528 |
my $nids = $self->num_of_domains(); |
| 529 |
my @ids = $self->list_domain_ids($nids); |
| 530 |
my @domains; |
| 531 |
foreach my $id (@ids) { |
| 532 |
eval { |
| 533 |
push @domains, Sys::Virt::Domain->_new(connection => $self, id => $id); |
| 534 |
}; |
| 535 |
if ($@) { |
| 536 |
# nada - domain went away before we could look it up |
| 537 |
}; |
| 538 |
} |
| 539 |
return @domains; |
| 540 |
} |
| 541 |
|
| 542 |
=item my $nids = $conn->num_of_domains() |
| 543 |
|
| 544 |
Return the number of running domains known to the hypervisor. This can be |
| 545 |
used as the C<maxids> parameter to C<list_domain_ids>. |
| 546 |
|
| 547 |
=item my @domIDs = $conn->list_domain_ids($maxids) |
| 548 |
|
| 549 |
Return a list of all domain IDs currently known to the hypervisor. The IDs can |
| 550 |
be used with the C<get_domain_by_id> method. |
| 551 |
|
| 552 |
=item my @doms = $conn->list_defined_domains() |
| 553 |
|
| 554 |
Return a list of all domains defined, but not currently running, on the |
| 555 |
hypervisor. The elements in the returned list are instances of the |
| 556 |
L<Sys::Virt::Domain> class. This method requires O(n) RPC calls, so the |
| 557 |
C<list_all_domains> method is recommended as a more efficient alternative. |
| 558 |
|
| 559 |
=cut |
| 560 |
|
| 561 |
sub list_defined_domains { |
| 562 |
my $self = shift; |
| 563 |
|
| 564 |
my $nnames = $self->num_of_defined_domains(); |
| 565 |
my @names = $self->list_defined_domain_names($nnames); |
| 566 |
|
| 567 |
my @domains; |
| 568 |
foreach my $name (@names) { |
| 569 |
eval { |
| 570 |
push @domains, Sys::Virt::Domain->_new(connection => $self, name => $name); |
| 571 |
}; |
| 572 |
if ($@) { |
| 573 |
# nada - domain went away before we could look it up |
| 574 |
}; |
| 575 |
} |
| 576 |
return @domains; |
| 577 |
} |
| 578 |
|
| 579 |
=item my $ndoms = $conn->num_of_defined_domains() |
| 580 |
|
| 581 |
Return the number of running domains known to the hypervisor. This can be |
| 582 |
used as the C<maxnames> parameter to C<list_defined_domain_names>. |
| 583 |
|
| 584 |
=item my @names = $conn->list_defined_domain_names($maxnames) |
| 585 |
|
| 586 |
Return a list of names of all domains defined, but not currently running, on |
| 587 |
the hypervisor. The names can be used with the C<get_domain_by_name> method. |
| 588 |
|
| 589 |
=item my @doms = $conn->list_all_domains($flags) |
| 590 |
|
| 591 |
Return a list of all domains currently known to the hypervisor, whether |
| 592 |
running or shutoff. The elements in the returned list are instances |
| 593 |
of the L<Sys::Virt::Domain> class. The C<$flags> parameter can be |
| 594 |
used to filter the list of returned domains. |
| 595 |
|
| 596 |
=item my @nets = $conn->list_networks() |
| 597 |
|
| 598 |
Return a list of all networks currently known to the hypervisor. The elements |
| 599 |
in the returned list are instances of the L<Sys::Virt::Network> class. |
| 600 |
This method requires O(n) RPC calls, so the C<list_all_networks> method |
| 601 |
is recommended as a more efficient alternative. |
| 602 |
|
| 603 |
=cut |
| 604 |
|
| 605 |
sub list_networks { |
| 606 |
my $self = shift; |
| 607 |
|
| 608 |
my $nnames = $self->num_of_networks(); |
| 609 |
my @names = $self->list_network_names($nnames); |
| 610 |
|
| 611 |
my @networks; |
| 612 |
foreach my $name (@names) { |
| 613 |
eval { |
| 614 |
push @networks, Sys::Virt::Network->_new(connection => $self, name => $name); |
| 615 |
}; |
| 616 |
if ($@) { |
| 617 |
# nada - network went away before we could look it up |
| 618 |
}; |
| 619 |
} |
| 620 |
return @networks; |
| 621 |
} |
| 622 |
|
| 623 |
=item my $nnets = $conn->num_of_networks() |
| 624 |
|
| 625 |
Return the number of running networks known to the hypervisor. This can be |
| 626 |
used as the C<maxids> parameter to C<list_network_ids>. |
| 627 |
|
| 628 |
=item my @netNames = $conn->list_network_names($maxnames) |
| 629 |
|
| 630 |
Return a list of all network names currently known to the hypervisor. The names can |
| 631 |
be used with the C<get_network_by_name> method. |
| 632 |
|
| 633 |
=item my @nets = $conn->list_defined_networks() |
| 634 |
|
| 635 |
Return a list of all networks defined, but not currently running, on the |
| 636 |
hypervisor. The elements in the returned list are instances of the |
| 637 |
L<Sys::Virt::Network> class. This method requires O(n) RPC calls, so the |
| 638 |
C<list_all_networks> method is recommended as a more efficient alternative. |
| 639 |
|
| 640 |
=cut |
| 641 |
|
| 642 |
sub list_defined_networks { |
| 643 |
my $self = shift; |
| 644 |
|
| 645 |
my $nnames = $self->num_of_defined_networks(); |
| 646 |
my @names = $self->list_defined_network_names($nnames); |
| 647 |
|
| 648 |
my @networks; |
| 649 |
foreach my $name (@names) { |
| 650 |
eval { |
| 651 |
push @networks, Sys::Virt::Network->_new(connection => $self, name => $name); |
| 652 |
}; |
| 653 |
if ($@) { |
| 654 |
# nada - network went away before we could look it up |
| 655 |
}; |
| 656 |
} |
| 657 |
return @networks; |
| 658 |
} |
| 659 |
|
| 660 |
=item my $nnets = $conn->num_of_defined_networks() |
| 661 |
|
| 662 |
Return the number of running networks known to the host. This can be |
| 663 |
used as the C<maxnames> parameter to C<list_defined_network_names>. |
| 664 |
|
| 665 |
=item my @names = $conn->list_defined_network_names($maxnames) |
| 666 |
|
| 667 |
Return a list of names of all networks defined, but not currently running, on |
| 668 |
the host. The names can be used with the C<get_network_by_name> method. |
| 669 |
|
| 670 |
=item my @nets = $conn->list_all_networks($flags) |
| 671 |
|
| 672 |
Return a list of all networks currently known to the hypervisor, whether |
| 673 |
running or shutoff. The elements in the returned list are instances |
| 674 |
of the L<Sys::Virt::Network> class. The C<$flags> parameter can be |
| 675 |
used to filter the list of returned networks. |
| 676 |
|
| 677 |
=item my @pools = $conn->list_storage_pools() |
| 678 |
|
| 679 |
Return a list of all storage pools currently known to the host. The elements |
| 680 |
in the returned list are instances of the L<Sys::Virt::StoragePool> class. |
| 681 |
This method requires O(n) RPC calls, so the C<list_all_storage_pools> method |
| 682 |
is recommended as a more efficient alternative. |
| 683 |
|
| 684 |
=cut |
| 685 |
|
| 686 |
sub list_storage_pools { |
| 687 |
my $self = shift; |
| 688 |
|
| 689 |
my $nnames = $self->num_of_storage_pools(); |
| 690 |
my @names = $self->list_storage_pool_names($nnames); |
| 691 |
|
| 692 |
my @pools; |
| 693 |
foreach my $name (@names) { |
| 694 |
eval { |
| 695 |
push @pools, Sys::Virt::StoragePool->_new(connection => $self, name => $name); |
| 696 |
}; |
| 697 |
if ($@) { |
| 698 |
# nada - storage pool went away before we could look it up |
| 699 |
}; |
| 700 |
} |
| 701 |
return @pools; |
| 702 |
} |
| 703 |
|
| 704 |
=item my $npools = $conn->num_of_storage_pools() |
| 705 |
|
| 706 |
Return the number of running storage pools known to the hypervisor. This can be |
| 707 |
used as the C<maxids> parameter to C<list_storage_pool_names>. |
| 708 |
|
| 709 |
=item my @poolNames = $conn->list_storage_pool_names($maxnames) |
| 710 |
|
| 711 |
Return a list of all storage pool names currently known to the hypervisor. The IDs can |
| 712 |
be used with the C<get_network_by_id> method. |
| 713 |
|
| 714 |
=item my @pools = $conn->list_defined_storage_pools() |
| 715 |
|
| 716 |
Return a list of all storage pools defined, but not currently running, on the |
| 717 |
host. The elements in the returned list are instances of the |
| 718 |
L<Sys::Virt::StoragePool> class. This method requires O(n) RPC calls, so the |
| 719 |
C<list_all_storage_pools> method is recommended as a more efficient alternative. |
| 720 |
|
| 721 |
=cut |
| 722 |
|
| 723 |
sub list_defined_storage_pools { |
| 724 |
my $self = shift; |
| 725 |
|
| 726 |
my $nnames = $self->num_of_defined_storage_pools(); |
| 727 |
my @names = $self->list_defined_storage_pool_names($nnames); |
| 728 |
|
| 729 |
my @pools; |
| 730 |
foreach my $name (@names) { |
| 731 |
eval { |
| 732 |
push @pools, Sys::Virt::StoragePool->_new(connection => $self, name => $name); |
| 733 |
}; |
| 734 |
if ($@) { |
| 735 |
# nada - storage pool went away before we could look it up |
| 736 |
}; |
| 737 |
} |
| 738 |
return @pools; |
| 739 |
} |
| 740 |
|
| 741 |
=item my $npools = $conn->num_of_defined_storage_pools() |
| 742 |
|
| 743 |
Return the number of running networks known to the host. This can be |
| 744 |
used as the C<maxnames> parameter to C<list_defined_storage_pool_names>. |
| 745 |
|
| 746 |
=item my @names = $conn->list_defined_storage_pool_names($maxnames) |
| 747 |
|
| 748 |
Return a list of names of all storage pools defined, but not currently running, on |
| 749 |
the host. The names can be used with the C<get_storage_pool_by_name> method. |
| 750 |
|
| 751 |
=item my @pools = $conn->list_all_storage_pools($flags) |
| 752 |
|
| 753 |
Return a list of all storage pools currently known to the hypervisor, whether |
| 754 |
running or shutoff. The elements in the returned list are instances |
| 755 |
of the L<Sys::Virt::StoragePool> class. The C<$flags> parameter can be |
| 756 |
used to filter the list of returned pools. |
| 757 |
|
| 758 |
=item my @devs = $conn->list_node_devices($capability) |
| 759 |
|
| 760 |
Return a list of all devices currently known to the host OS. The elements |
| 761 |
in the returned list are instances of the L<Sys::Virt::NodeDevice> class. |
| 762 |
The optional C<capability> parameter allows the list to be restricted to |
| 763 |
only devices with a particular capability type. This method requires O(n) |
| 764 |
RPC calls, so the C<list_all_node_devices> method is recommended as a |
| 765 |
more efficient alternative. |
| 766 |
|
| 767 |
=cut |
| 768 |
|
| 769 |
sub list_node_devices { |
| 770 |
my $self = shift; |
| 771 |
my $cap = shift; |
| 772 |
|
| 773 |
my $nnames = $self->num_of_node_devices($cap); |
| 774 |
my @names = $self->list_node_device_names($cap, $nnames); |
| 775 |
|
| 776 |
my @devs; |
| 777 |
foreach my $name (@names) { |
| 778 |
eval { |
| 779 |
push @devs, Sys::Virt::NodeDevice->_new(connection => $self, name => $name); |
| 780 |
}; |
| 781 |
if ($@) { |
| 782 |
# nada - device went away before we could look it up |
| 783 |
}; |
| 784 |
} |
| 785 |
return @devs; |
| 786 |
} |
| 787 |
|
| 788 |
=item my $ndevs = $conn->num_of_node_devices($capability[, $flags]) |
| 789 |
|
| 790 |
Return the number of host devices known to the hypervisor. This can be |
| 791 |
used as the C<maxids> parameter to C<list_node_device_names>. |
| 792 |
The C<capability> parameter allows the list to be restricted to |
| 793 |
only devices with a particular capability type, and should be left |
| 794 |
as C<undef> if the full list is required. The optional <flags> |
| 795 |
parameter is currently unused and defaults to 0 if omitted. |
| 796 |
|
| 797 |
=item my @devNames = $conn->list_node_device_names($capability, $maxnames[, $flags]) |
| 798 |
|
| 799 |
Return a list of all host device names currently known to the hypervisor. The names can |
| 800 |
be used with the C<get_node_device_by_name> method. |
| 801 |
The C<capability> parameter allows the list to be restricted to |
| 802 |
only devices with a particular capability type, and should be left |
| 803 |
as C<undef> if the full list is required. The optional <flags> |
| 804 |
parameter is currently unused and defaults to 0 if omitted. |
| 805 |
|
| 806 |
=item my @devs = $conn->list_all_node_devices($flags) |
| 807 |
|
| 808 |
Return a list of all node devices currently known to the hypervisor. The |
| 809 |
elements in the returned list are instances of the |
| 810 |
L<Sys::Virt::NodeDevice> class. The C<$flags> parameter can be |
| 811 |
used to filter the list of returned devices. |
| 812 |
|
| 813 |
=item my @ifaces = $conn->list_interfaces() |
| 814 |
|
| 815 |
Return a list of all network interfaces currently known to the hypervisor. The elements |
| 816 |
in the returned list are instances of the L<Sys::Virt::Interface> class. |
| 817 |
This method requires O(n) RPC calls, so the C<list_all_interfaces> method is |
| 818 |
recommended as a more efficient alternative. |
| 819 |
|
| 820 |
=cut |
| 821 |
|
| 822 |
sub list_interfaces { |
| 823 |
my $self = shift; |
| 824 |
|
| 825 |
my $nnames = $self->num_of_interfaces(); |
| 826 |
my @names = $self->list_interface_names($nnames); |
| 827 |
|
| 828 |
my @interfaces; |
| 829 |
foreach my $name (@names) { |
| 830 |
eval { |
| 831 |
push @interfaces, Sys::Virt::Interface->_new(connection => $self, name => $name); |
| 832 |
}; |
| 833 |
if ($@) { |
| 834 |
# nada - interface went away before we could look it up |
| 835 |
}; |
| 836 |
} |
| 837 |
return @interfaces; |
| 838 |
} |
| 839 |
|
| 840 |
=item my $nifaces = $conn->num_of_interfaces() |
| 841 |
|
| 842 |
Return the number of running interfaces known to the hypervisor. This can be |
| 843 |
used as the C<maxnames> parameter to C<list_interface_names>. |
| 844 |
|
| 845 |
=item my @names = $conn->list_interface_names($maxnames) |
| 846 |
|
| 847 |
Return a list of all interface names currently known to the hypervisor. The names can |
| 848 |
be used with the C<get_interface_by_name> method. |
| 849 |
|
| 850 |
=item my @ifaces = $conn->list_defined_interfaces() |
| 851 |
|
| 852 |
Return a list of all network interfaces currently known to the hypervisor. The elements |
| 853 |
in the returned list are instances of the L<Sys::Virt::Interface> class. |
| 854 |
This method requires O(n) RPC calls, so the C<list_all_interfaces> method is |
| 855 |
recommended as a more efficient alternative. |
| 856 |
|
| 857 |
=cut |
| 858 |
|
| 859 |
sub list_defined_interfaces { |
| 860 |
my $self = shift; |
| 861 |
|
| 862 |
my $nnames = $self->num_of_defined_interfaces(); |
| 863 |
my @names = $self->list_defined_interface_names($nnames); |
| 864 |
|
| 865 |
my @interfaces; |
| 866 |
foreach my $name (@names) { |
| 867 |
eval { |
| 868 |
push @interfaces, Sys::Virt::Interface->_new(connection => $self, name => $name); |
| 869 |
}; |
| 870 |
if ($@) { |
| 871 |
# nada - interface went away before we could look it up |
| 872 |
}; |
| 873 |
} |
| 874 |
return @interfaces; |
| 875 |
} |
| 876 |
|
| 877 |
=item my $nifaces = $conn->num_of_defined_interfaces() |
| 878 |
|
| 879 |
Return the number of inactive interfaces known to the hypervisor. This can be |
| 880 |
used as the C<maxnames> parameter to C<list_defined_interface_names>. |
| 881 |
|
| 882 |
=item my @names = $conn->list_defined_interface_names($maxnames) |
| 883 |
|
| 884 |
Return a list of inactive interface names currently known to the hypervisor. The names can |
| 885 |
be used with the C<get_interface_by_name> method. |
| 886 |
|
| 887 |
=item my @ifaces = $conn->list_all_interfaces($flags) |
| 888 |
|
| 889 |
Return a list of all interfaces currently known to the hypervisor, whether |
| 890 |
running or shutoff. The elements in the returned list are instances |
| 891 |
of the L<Sys::Virt::Interface> class. The C<$flags> parameter can be |
| 892 |
used to filter the list of returned interfaces. |
| 893 |
|
| 894 |
=item my @ifaces = $conn->list_secrets() |
| 895 |
|
| 896 |
Return a list of all secrets currently known to the hypervisor. The elements |
| 897 |
in the returned list are instances of the L<Sys::Virt::Secret> class. |
| 898 |
This method requires O(n) RPC calls, so the C<list_all_secrets> method |
| 899 |
is recommended as a more efficient alternative. |
| 900 |
|
| 901 |
=cut |
| 902 |
|
| 903 |
sub list_secrets { |
| 904 |
my $self = shift; |
| 905 |
|
| 906 |
my $nuuids = $self->num_of_secrets(); |
| 907 |
my @uuids = $self->list_secret_uuids($nuuids); |
| 908 |
|
| 909 |
my @secrets; |
| 910 |
foreach my $uuid (@uuids) { |
| 911 |
eval { |
| 912 |
push @secrets, Sys::Virt::Secret->_new(connection => $self, uuid => $uuid); |
| 913 |
}; |
| 914 |
if ($@) { |
| 915 |
# nada - secret went away before we could look it up |
| 916 |
}; |
| 917 |
} |
| 918 |
return @secrets; |
| 919 |
} |
| 920 |
|
| 921 |
=item my $nuuids = $conn->num_of_secrets() |
| 922 |
|
| 923 |
Return the number of secrets known to the hypervisor. This can be |
| 924 |
used as the C<maxuuids> parameter to C<list_secrets>. |
| 925 |
|
| 926 |
=item my @uuids = $conn->list_secret_uuids($maxuuids) |
| 927 |
|
| 928 |
Return a list of all secret uuids currently known to the hypervisor. The uuids can |
| 929 |
be used with the C<get_secret_by_uuid> method. |
| 930 |
|
| 931 |
=item my @secrets = $conn->list_all_secrets($flags) |
| 932 |
|
| 933 |
Return a list of all secrets currently known to the hypervisor. The elements |
| 934 |
in the returned list are instances of the L<Sys::Virt::Network> class. |
| 935 |
The C<$flags> parameter can be used to filter the list of returned |
| 936 |
secrets. |
| 937 |
|
| 938 |
=item my @nwfilters = $conn->list_nwfilters() |
| 939 |
|
| 940 |
Return a list of all nwfilters currently known to the hypervisor. The elements |
| 941 |
in the returned list are instances of the L<Sys::Virt::NWFilter> class. |
| 942 |
This method requires O(n) RPC calls, so the C<list_all_nwfilters> method |
| 943 |
is recommended as a more efficient alternative. |
| 944 |
|
| 945 |
=cut |
| 946 |
|
| 947 |
sub list_nwfilters { |
| 948 |
my $self = shift; |
| 949 |
|
| 950 |
my $nnames = $self->num_of_nwfilters(); |
| 951 |
my @names = $self->list_nwfilter_names($nnames); |
| 952 |
|
| 953 |
my @nwfilters; |
| 954 |
foreach my $name (@names) { |
| 955 |
eval { |
| 956 |
push @nwfilters, Sys::Virt::NWFilter->_new(connection => $self, name => $name); |
| 957 |
}; |
| 958 |
if ($@) { |
| 959 |
# nada - nwfilter went away before we could look it up |
| 960 |
}; |
| 961 |
} |
| 962 |
return @nwfilters; |
| 963 |
} |
| 964 |
|
| 965 |
=item my $nnwfilters = $conn->num_of_nwfilters() |
| 966 |
|
| 967 |
Return the number of running nwfilters known to the hypervisor. This can be |
| 968 |
used as the C<maxids> parameter to C<list_nwfilter_names>. |
| 969 |
|
| 970 |
=item my @filterNames = $conn->list_nwfilter_names($maxnames) |
| 971 |
|
| 972 |
Return a list of all nwfilter names currently known to the hypervisor. The names can |
| 973 |
be used with the C<get_nwfilter_by_name> method. |
| 974 |
|
| 975 |
=item my @nwfilters = $conn->list_all_nwfilters($flags) |
| 976 |
|
| 977 |
Return a list of all nwfilters currently known to the hypervisor. The elements |
| 978 |
in the returned list are instances of the L<Sys::Virt::NWFilter> class. |
| 979 |
The C<$flags> parameter is currently unused and defaults to zero. |
| 980 |
|
| 981 |
=item my @bindings = $conn->list_all_nwfilter_bindings($flags) |
| 982 |
|
| 983 |
Return a list of all nwfilter bindings currently known to the hypervisor. The |
| 984 |
elements in the returned list are instances of the L<Sys::Virt::NWFilterBinding> |
| 985 |
class. The C<$flags> parameter is currently unused and defaults to zero. |
| 986 |
|
| 987 |
=item $conn->define_save_image_xml($file, $dxml, $flags=0) |
| 988 |
|
| 989 |
Update the XML associated with a virtual machine's save image. The C<$file> |
| 990 |
parameter is the fully qualified path to the save image XML, while C<$dxml> |
| 991 |
is the new XML document to write. The C<$flags> parameter is currently |
| 992 |
unused and defaults to zero. |
| 993 |
|
| 994 |
=item $xml = $conn->get_save_image_xml_description($file, $flags=1) |
| 995 |
|
| 996 |
Retrieve the current XML configuration associated with the virtual |
| 997 |
machine's save image identified by C<$file>. The C<$flags> parameter |
| 998 |
accepts the same constants as C<Sys::Virt::Domain::managed_save_get_xml_description>. |
| 999 |
|
| 1000 |
=item my $dom = $conn->get_domain_by_name($name) |
| 1001 |
|
| 1002 |
Return the domain with a name of C<$name>. The returned object is |
| 1003 |
an instance of the L<Sys::Virt::Domain> class. |
| 1004 |
|
| 1005 |
=cut |
| 1006 |
|
| 1007 |
sub get_domain_by_name { |
| 1008 |
my $self = shift; |
| 1009 |
my $name = shift; |
| 1010 |
|
| 1011 |
return Sys::Virt::Domain->_new(connection => $self, name => $name); |
| 1012 |
} |
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
=item my $dom = $conn->get_domain_by_id($id) |
| 1017 |
|
| 1018 |
Return the domain with a local id of C<$id>. The returned object is |
| 1019 |
an instance of the L<Sys::Virt::Domain> class. |
| 1020 |
|
| 1021 |
=cut |
| 1022 |
|
| 1023 |
sub get_domain_by_id { |
| 1024 |
my $self = shift; |
| 1025 |
my $id = shift; |
| 1026 |
|
| 1027 |
return Sys::Virt::Domain->_new(connection => $self, id => $id); |
| 1028 |
} |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
=item my $dom = $conn->get_domain_by_uuid($uuid) |
| 1033 |
|
| 1034 |
Return the domain with a globally unique id of C<$uuid>. The returned object is |
| 1035 |
an instance of the L<Sys::Virt::Domain> class. |
| 1036 |
|
| 1037 |
=cut |
| 1038 |
|
| 1039 |
sub get_domain_by_uuid { |
| 1040 |
my $self = shift; |
| 1041 |
my $uuid = shift; |
| 1042 |
|
| 1043 |
return Sys::Virt::Domain->_new(connection => $self, uuid => $uuid); |
| 1044 |
} |
| 1045 |
|
| 1046 |
=item my $net = $conn->get_network_by_name($name) |
| 1047 |
|
| 1048 |
Return the network with a name of C<$name>. The returned object is |
| 1049 |
an instance of the L<Sys::Virt::Network> class. |
| 1050 |
|
| 1051 |
=cut |
| 1052 |
|
| 1053 |
sub get_network_by_name { |
| 1054 |
my $self = shift; |
| 1055 |
my $name = shift; |
| 1056 |
|
| 1057 |
return Sys::Virt::Network->_new(connection => $self, name => $name); |
| 1058 |
} |
| 1059 |
|
| 1060 |
|
| 1061 |
=item my $net = $conn->get_network_by_uuid($uuid) |
| 1062 |
|
| 1063 |
Return the network with a globally unique id of C<$uuid>. The returned object is |
| 1064 |
an instance of the L<Sys::Virt::Network> class. |
| 1065 |
|
| 1066 |
=cut |
| 1067 |
|
| 1068 |
sub get_network_by_uuid { |
| 1069 |
my $self = shift; |
| 1070 |
my $uuid = shift; |
| 1071 |
|
| 1072 |
return Sys::Virt::Network->_new(connection => $self, uuid => $uuid); |
| 1073 |
} |
| 1074 |
|
| 1075 |
=item my $pool = $conn->get_storage_pool_by_name($name) |
| 1076 |
|
| 1077 |
Return the storage pool with a name of C<$name>. The returned object is |
| 1078 |
an instance of the L<Sys::Virt::StoragePool> class. |
| 1079 |
|
| 1080 |
=cut |
| 1081 |
|
| 1082 |
sub get_storage_pool_by_name { |
| 1083 |
my $self = shift; |
| 1084 |
my $name = shift; |
| 1085 |
|
| 1086 |
return Sys::Virt::StoragePool->_new(connection => $self, name => $name); |
| 1087 |
} |
| 1088 |
|
| 1089 |
|
| 1090 |
=item my $pool = $conn->get_storage_pool_by_uuid($uuid) |
| 1091 |
|
| 1092 |
Return the storage pool with a globally unique id of C<$uuid>. The returned object is |
| 1093 |
an instance of the L<Sys::Virt::StoragePool> class. |
| 1094 |
|
| 1095 |
=cut |
| 1096 |
|
| 1097 |
sub get_storage_pool_by_uuid { |
| 1098 |
my $self = shift; |
| 1099 |
my $uuid = shift; |
| 1100 |
|
| 1101 |
return Sys::Virt::StoragePool->_new(connection => $self, uuid => $uuid); |
| 1102 |
} |
| 1103 |
|
| 1104 |
|
| 1105 |
=item my $pool = $conn->get_storage_pool_by_volume($vol) |
| 1106 |
|
| 1107 |
Return the storage pool with a storage volume C<$vol>. The C<$vol> parameter |
| 1108 |
must be an instance of the L<Sys::Virt::StorageVol> class. The returned object is |
| 1109 |
an instance of the L<Sys::Virt::StoragePool> class. |
| 1110 |
|
| 1111 |
=cut |
| 1112 |
|
| 1113 |
sub get_storage_pool_by_volume { |
| 1114 |
my $self = shift; |
| 1115 |
my $volume = shift; |
| 1116 |
|
| 1117 |
return Sys::Virt::StoragePool->_new(connection => $self, volume => $volume); |
| 1118 |
} |
| 1119 |
|
| 1120 |
|
| 1121 |
=item my $pool = $conn->get_storage_pool_by_target_path($path) |
| 1122 |
|
| 1123 |
Return the storage pool with a target path of C<$path>. The returned object is |
| 1124 |
an instance of the L<Sys::Virt::StoragePool> class. |
| 1125 |
|
| 1126 |
=cut |
| 1127 |
|
| 1128 |
sub get_storage_pool_by_target_path { |
| 1129 |
my $self = shift; |
| 1130 |
my $path = shift; |
| 1131 |
|
| 1132 |
return Sys::Virt::StoragePool->_new(connection => $self, target_path => $path); |
| 1133 |
} |
| 1134 |
|
| 1135 |
|
| 1136 |
=item my $vol = $conn->get_storage_volume_by_path($path) |
| 1137 |
|
| 1138 |
Return the storage volume with a location of C<$path>. The returned object is |
| 1139 |
an instance of the L<Sys::Virt::StorageVol> class. |
| 1140 |
|
| 1141 |
=cut |
| 1142 |
|
| 1143 |
sub get_storage_volume_by_path { |
| 1144 |
my $self = shift; |
| 1145 |
my $path = shift; |
| 1146 |
|
| 1147 |
return Sys::Virt::StorageVol->_new(connection => $self, path => $path); |
| 1148 |
} |
| 1149 |
|
| 1150 |
|
| 1151 |
=item my $vol = $conn->get_storage_volume_by_key($key) |
| 1152 |
|
| 1153 |
Return the storage volume with a globally unique id of C<$key>. The returned object is |
| 1154 |
an instance of the L<Sys::Virt::StorageVol> class. |
| 1155 |
|
| 1156 |
=cut |
| 1157 |
|
| 1158 |
sub get_storage_volume_by_key { |
| 1159 |
my $self = shift; |
| 1160 |
my $key = shift; |
| 1161 |
|
| 1162 |
return Sys::Virt::StorageVol->_new(connection => $self, key => $key); |
| 1163 |
} |
| 1164 |
|
| 1165 |
=item my $dev = $conn->get_node_device_by_name($name) |
| 1166 |
|
| 1167 |
Return the node device with a name of C<$name>. The returned object is |
| 1168 |
an instance of the L<Sys::Virt::NodeDevice> class. |
| 1169 |
|
| 1170 |
=cut |
| 1171 |
|
| 1172 |
sub get_node_device_by_name { |
| 1173 |
my $self = shift; |
| 1174 |
my $name = shift; |
| 1175 |
|
| 1176 |
return Sys::Virt::NodeDevice->_new(connection => $self, name => $name); |
| 1177 |
} |
| 1178 |
|
| 1179 |
|
| 1180 |
=item my $dev = $conn->get_node_device_scsihost_by_wwn($wwnn, $wwpn, $flags=0) |
| 1181 |
|
| 1182 |
Return the node device which is a SCSI host identified by C<$wwnn> and C<$wwpn>. |
| 1183 |
The C<$flags> parameter is unused and defaults to zero. The returned object is |
| 1184 |
an instance of the L<Sys::Virt::NodeDevice> class. |
| 1185 |
|
| 1186 |
=cut |
| 1187 |
|
| 1188 |
sub get_node_device_scsihost_by_wwn { |
| 1189 |
my $self = shift; |
| 1190 |
my $wwnn = shift; |
| 1191 |
my $wwpn = shift; |
| 1192 |
|
| 1193 |
return Sys::Virt::NodeDevice->_new(connection => $self, |
| 1194 |
wwnn => $wwnn, |
| 1195 |
wwpn => $wwpn); |
| 1196 |
} |
| 1197 |
|
| 1198 |
|
| 1199 |
=item my $iface = $conn->get_interface_by_name($name) |
| 1200 |
|
| 1201 |
Return the interface with a name of C<$name>. The returned object is |
| 1202 |
an instance of the L<Sys::Virt::Interface> class. |
| 1203 |
|
| 1204 |
=cut |
| 1205 |
|
| 1206 |
sub get_interface_by_name { |
| 1207 |
my $self = shift; |
| 1208 |
my $name = shift; |
| 1209 |
|
| 1210 |
return Sys::Virt::Interface->_new(connection => $self, name => $name); |
| 1211 |
} |
| 1212 |
|
| 1213 |
|
| 1214 |
=item my $iface = $conn->get_interface_by_mac($mac) |
| 1215 |
|
| 1216 |
Return the interface with a MAC address of C<$mac>. The returned object is |
| 1217 |
an instance of the L<Sys::Virt::Interface> class. |
| 1218 |
|
| 1219 |
=cut |
| 1220 |
|
| 1221 |
sub get_interface_by_mac { |
| 1222 |
my $self = shift; |
| 1223 |
my $mac = shift; |
| 1224 |
|
| 1225 |
return Sys::Virt::Interface->_new(connection => $self, mac => $mac); |
| 1226 |
} |
| 1227 |
|
| 1228 |
|
| 1229 |
=item my $sec = $conn->get_secret_by_uuid($uuid) |
| 1230 |
|
| 1231 |
Return the secret with a globally unique id of C<$uuid>. The returned object is |
| 1232 |
an instance of the L<Sys::Virt::Secret> class. |
| 1233 |
|
| 1234 |
=cut |
| 1235 |
|
| 1236 |
sub get_secret_by_uuid { |
| 1237 |
my $self = shift; |
| 1238 |
my $uuid = shift; |
| 1239 |
|
| 1240 |
return Sys::Virt::Secret->_new(connection => $self, uuid => $uuid); |
| 1241 |
} |
| 1242 |
|
| 1243 |
=item my $sec = $conn->get_secret_by_usage($usageType, $usageID) |
| 1244 |
|
| 1245 |
Return the secret with a usage type of C<$usageType>, identified |
| 1246 |
by C<$usageID>. The returned object is an instance of the |
| 1247 |
L<Sys::Virt::Secret> class. |
| 1248 |
|
| 1249 |
=cut |
| 1250 |
|
| 1251 |
sub get_secret_by_usage { |
| 1252 |
my $self = shift; |
| 1253 |
my $type = shift; |
| 1254 |
my $id = shift; |
| 1255 |
|
| 1256 |
return Sys::Virt::Secret->_new(connection => $self, |
| 1257 |
usageType => $type, |
| 1258 |
usageID => $id); |
| 1259 |
} |
| 1260 |
|
| 1261 |
=item my $nwfilter = $conn->get_nwfilter_by_name($name) |
| 1262 |
|
| 1263 |
Return the domain with a name of C<$name>. The returned object is |
| 1264 |
an instance of the L<Sys::Virt::NWFilter> class. |
| 1265 |
|
| 1266 |
=cut |
| 1267 |
|
| 1268 |
sub get_nwfilter_by_name { |
| 1269 |
my $self = shift; |
| 1270 |
my $name = shift; |
| 1271 |
|
| 1272 |
return Sys::Virt::NWFilter->_new(connection => $self, name => $name); |
| 1273 |
} |
| 1274 |
|
| 1275 |
|
| 1276 |
=item my $nwfilter = $conn->get_nwfilter_by_uuid($uuid) |
| 1277 |
|
| 1278 |
Return the nwfilter with a globally unique id of C<$uuid>. The returned object is |
| 1279 |
an instance of the L<Sys::Virt::NWFilter> class. |
| 1280 |
|
| 1281 |
=cut |
| 1282 |
|
| 1283 |
sub get_nwfilter_by_uuid { |
| 1284 |
my $self = shift; |
| 1285 |
my $uuid = shift; |
| 1286 |
|
| 1287 |
return Sys::Virt::NWFilter->_new(connection => $self, uuid => $uuid); |
| 1288 |
} |
| 1289 |
|
| 1290 |
=item my $binding = $conn->get_nwfilter_binding_by_port_dev($name) |
| 1291 |
|
| 1292 |
Return the network filter binding for the port device C<$name>. The returned object is |
| 1293 |
an instance of the L<Sys::Virt::NWFilterBinding> class. |
| 1294 |
|
| 1295 |
=cut |
| 1296 |
|
| 1297 |
sub get_nwfilter_binding_by_port_dev { |
| 1298 |
my $self = shift; |
| 1299 |
my $name = shift; |
| 1300 |
|
| 1301 |
return Sys::Virt::NWFilterBinding->_new(connection => $self, portdev => $name); |
| 1302 |
} |
| 1303 |
|
| 1304 |
|
| 1305 |
=item my $xml = $conn->find_storage_pool_sources($type, $srcspec[, $flags]) |
| 1306 |
|
| 1307 |
Probe for available storage pool sources for the pool of type C<$type>. |
| 1308 |
The C<$srcspec> parameter can be C<undef>, or a parameter to refine the |
| 1309 |
discovery process, for example a server hostname for NFS discovery. The |
| 1310 |
C<$flags> parameter is optional, and if omitted defaults to zero. The |
| 1311 |
returned scalar is an XML document describing the discovered storage |
| 1312 |
pool sources. |
| 1313 |
|
| 1314 |
=item my @stats = $conn->get_all_domain_stats($stats, \@doms=undef, $flags=0); |
| 1315 |
|
| 1316 |
Get a list of all statistics for domains known to the hypervisor. |
| 1317 |
The C<$stats> parameter controls which data fields to return and |
| 1318 |
should be a combination of the DOMAIN STATS FIELD CONSTANTS. |
| 1319 |
|
| 1320 |
The optional C<@doms> parameter is a list of Sys::Virt::Domain objects |
| 1321 |
to return stats for. If this is undefined, then all domains will be |
| 1322 |
returned. The C<$flags> method can be used to filter the list of |
| 1323 |
returned domains. |
| 1324 |
|
| 1325 |
The return data for the method is a list, one element for each domain. |
| 1326 |
The element will be a hash with two keys, C<dom> pointing to an instance |
| 1327 |
of C<Sys::Virt::Domain> and C<data> pointing to another hash reference |
| 1328 |
containing the actual statistics. |
| 1329 |
|
| 1330 |
=item $conn->interface_change_begin($flags) |
| 1331 |
|
| 1332 |
Begin a transaction for changing the configuration of one or more |
| 1333 |
network interfaces |
| 1334 |
|
| 1335 |
=item $conn->interface_change_commit($flags) |
| 1336 |
|
| 1337 |
Complete a transaction for changing the configuration of one or more |
| 1338 |
network interfaces |
| 1339 |
|
| 1340 |
=item $conn->interface_change_rollback($flags) |
| 1341 |
|
| 1342 |
Abort a transaction for changing the configuration of one or more |
| 1343 |
network interfaces |
| 1344 |
|
| 1345 |
=item $conn->restore_domain($savefile, $dxml=undef, $params=undef, $flags=0) |
| 1346 |
|
| 1347 |
Recreate a domain from the saved state file given in the C<$savefile> |
| 1348 |
parameter. The optional C<$dxml> parameter can be used to alter portions of the |
| 1349 |
domain XML. The C<$params> parameter is a hash reference whose keys is a subset |
| 1350 |
of the SAVE / RESTORE PARAMETER CONSTANTS. The C<$flags> parameter accepts one |
| 1351 |
of the SAVE / RESTORE FLAG CONSTANTS described later and defaults to zero. |
| 1352 |
|
| 1353 |
=item $conn->get_max_vcpus($domtype) |
| 1354 |
|
| 1355 |
Return the maximum number of vcpus that can be configured for a domain |
| 1356 |
of type C<$domtype> |
| 1357 |
|
| 1358 |
=item my $hostname = $conn->get_hostname() |
| 1359 |
|
| 1360 |
Return the name of the host with which this connection is associated. |
| 1361 |
|
| 1362 |
=item my $uri = $conn->get_uri() |
| 1363 |
|
| 1364 |
Return the URI associated with the open connection. This may be different |
| 1365 |
from the URI used when initially connecting to libvirt, when 'auto-probing' |
| 1366 |
or drivers occurs. |
| 1367 |
|
| 1368 |
=item my $xml = $conn->get_sysinfo() |
| 1369 |
|
| 1370 |
Return an XML documenting representing the host system information, |
| 1371 |
typically obtained from SMBIOS tables. |
| 1372 |
|
| 1373 |
=item my $type = $conn->get_type() |
| 1374 |
|
| 1375 |
Return the type of virtualization backend accessed by this hypervisor object. Currently |
| 1376 |
the only supported type is C<Xen>. |
| 1377 |
|
| 1378 |
=item my $xml = $conn->domain_xml_from_native($format, $config); |
| 1379 |
|
| 1380 |
Convert the native hypervisor configuration C<$config> which is in format |
| 1381 |
<$format> into libvirrt domain XML. Valid values of C<$format> vary between |
| 1382 |
hypervisor drivers. |
| 1383 |
|
| 1384 |
=item my $config = $conn->domain_xml_to_native($format, $xml) |
| 1385 |
|
| 1386 |
Convert the libvirt domain XML configuration C<$xml> to a native hypervisor |
| 1387 |
configuration in format C<$format> |
| 1388 |
|
| 1389 |
=item my $ver = $conn->get_version() |
| 1390 |
|
| 1391 |
Return the complete version number as a string encoded in the |
| 1392 |
formula C<(major * 1000000) + (minor * 1000) + micro>. |
| 1393 |
|
| 1394 |
=item my $ver = $conn->get_major_version |
| 1395 |
|
| 1396 |
Return the major version number of the libvirt library. |
| 1397 |
|
| 1398 |
=cut |
| 1399 |
|
| 1400 |
sub get_major_version { |
| 1401 |
my $self = shift; |
| 1402 |
my $ver = $self->get_version; |
| 1403 |
return ($ver - ($ver % 1000000))/1000000; |
| 1404 |
} |
| 1405 |
|
| 1406 |
|
| 1407 |
=item my $ver = $conn->get_minor_version |
| 1408 |
|
| 1409 |
Return the minor version number of the libvirt library. |
| 1410 |
|
| 1411 |
=cut |
| 1412 |
|
| 1413 |
sub get_minor_version { |
| 1414 |
my $self = shift; |
| 1415 |
my $ver = $self->get_version; |
| 1416 |
my $mver = $ver % 1000000; |
| 1417 |
return ($mver - ($mver % 1000)) / 1000; |
| 1418 |
} |
| 1419 |
|
| 1420 |
=item my $ver = $conn->get_micro_version |
| 1421 |
|
| 1422 |
Return the micro version number of the libvirt library. |
| 1423 |
|
| 1424 |
=cut |
| 1425 |
|
| 1426 |
sub get_micro_version { |
| 1427 |
my $self = shift; |
| 1428 |
return $self->get_version % 1000; |
| 1429 |
} |
| 1430 |
|
| 1431 |
sub get_version { |
| 1432 |
my $self = shift; |
| 1433 |
if (defined $self) { |
| 1434 |
return $self->_get_conn_version; |
| 1435 |
} else { |
| 1436 |
return &Sys::Virt::_get_library_version(); |
| 1437 |
} |
| 1438 |
} |
| 1439 |
|
| 1440 |
=item my $ver = $conn->get_library_version |
| 1441 |
|
| 1442 |
Return the version number of the API associated with |
| 1443 |
the active connection. This differs from C<get_version> |
| 1444 |
in that if the connection is to a remote libvirtd |
| 1445 |
daemon, it will return the API version of the remote |
| 1446 |
libvirt, rather than the local client. |
| 1447 |
|
| 1448 |
=cut |
| 1449 |
|
| 1450 |
sub get_library_version { |
| 1451 |
my $self = shift; |
| 1452 |
return $self->_get_conn_library_version; |
| 1453 |
} |
| 1454 |
|
| 1455 |
1; |
| 1456 |
|
| 1457 |
=pod |
| 1458 |
|
| 1459 |
=item $conn->is_secure() |
| 1460 |
|
| 1461 |
Returns a true value if the current connection is secure against |
| 1462 |
network interception. This implies either use of UNIX sockets, |
| 1463 |
or encryption with a TCP stream. |
| 1464 |
|
| 1465 |
=item $conn->is_encrypted() |
| 1466 |
|
| 1467 |
Returns a true value if the current connection data stream is |
| 1468 |
encrypted. |
| 1469 |
|
| 1470 |
=item $conn->is_alive() |
| 1471 |
|
| 1472 |
Returns a true value if the connection is alive, as determined |
| 1473 |
by keep-alive packets or other recent RPC traffic. |
| 1474 |
|
| 1475 |
=item $conn->set_keep_alive($interval, $count) |
| 1476 |
|
| 1477 |
Change the operation of the keep alive protocol to send C<$count> |
| 1478 |
packets spaced C<$interval> seconds apart before considering the |
| 1479 |
connection dead. |
| 1480 |
|
| 1481 |
=item my $info = $con->get_node_info() |
| 1482 |
|
| 1483 |
Returns a hash reference summarising the capabilities of the host |
| 1484 |
node. The elements of the hash are as follows: |
| 1485 |
|
| 1486 |
=over 4 |
| 1487 |
|
| 1488 |
=item memory |
| 1489 |
|
| 1490 |
The amount of physical memory in the host |
| 1491 |
|
| 1492 |
=item model |
| 1493 |
|
| 1494 |
The model of the CPU, eg x86_64 |
| 1495 |
|
| 1496 |
=item cpus |
| 1497 |
|
| 1498 |
The total number of logical CPUs. |
| 1499 |
|
| 1500 |
=item mhz |
| 1501 |
|
| 1502 |
The peak MHZ of the CPU |
| 1503 |
|
| 1504 |
=item nodes |
| 1505 |
|
| 1506 |
The number of NUMA cells |
| 1507 |
|
| 1508 |
=item sockets |
| 1509 |
|
| 1510 |
The number of CPU sockets |
| 1511 |
|
| 1512 |
=item cores |
| 1513 |
|
| 1514 |
The number of cores per socket |
| 1515 |
|
| 1516 |
=item threads |
| 1517 |
|
| 1518 |
The number of threads per core |
| 1519 |
|
| 1520 |
=back |
| 1521 |
|
| 1522 |
NB, more accurate information about the total number of CPUs |
| 1523 |
and those online can be obtained using the C<get_node_cpu_map> |
| 1524 |
method. |
| 1525 |
|
| 1526 |
=item my ($totcpus, $onlinemap, $totonline) = $con->get_node_cpu_map(); |
| 1527 |
|
| 1528 |
Returns an array containing information about the CPUs available |
| 1529 |
on the host. The first element, C<totcpus>, specifies the total |
| 1530 |
number of CPUs available to the host regardless of their online |
| 1531 |
stat. The second element, C<onlinemap>, provides a bitmap detailing |
| 1532 |
which CPUs are currently online. The third element, C<totonline>, |
| 1533 |
specifies the total number of online CPUs. The values in the bitmap |
| 1534 |
can be extracted using the C<unpack> method as follows: |
| 1535 |
|
| 1536 |
my @onlinemap = split(//, unpack("b*", $onlinemap)); |
| 1537 |
|
| 1538 |
=item my $info = $con->get_node_cpu_stats($cpuNum=-1, $flags=0) |
| 1539 |
|
| 1540 |
Returns a hash reference providing information about the host |
| 1541 |
CPU statistics. If <$cpuNum> is omitted, it defaults to C<Sys::Virt::NODE_CPU_STATS_ALL_CPUS> |
| 1542 |
which causes it to return cumulative information for all |
| 1543 |
CPUs in the host. If C<$cpuNum> is zero or larger, it returns |
| 1544 |
information just for the specified number. The C<$flags> |
| 1545 |
parameter is currently unused and defaults to zero. The |
| 1546 |
fields in the returned hash reference are |
| 1547 |
|
| 1548 |
=over 4 |
| 1549 |
|
| 1550 |
=item kernel |
| 1551 |
|
| 1552 |
The time spent in kernelspace |
| 1553 |
|
| 1554 |
=item user |
| 1555 |
|
| 1556 |
The time spent in userspace |
| 1557 |
|
| 1558 |
=item idle |
| 1559 |
|
| 1560 |
The idle time |
| 1561 |
|
| 1562 |
=item iowait |
| 1563 |
|
| 1564 |
The I/O wait time |
| 1565 |
|
| 1566 |
=item utilization |
| 1567 |
|
| 1568 |
The overall percentage utilization. |
| 1569 |
|
| 1570 |
=back |
| 1571 |
|
| 1572 |
=item my $info = $con->get_node_memory_stats($cellNum=-1, $flags=0) |
| 1573 |
|
| 1574 |
Returns a hash reference providing information about the host |
| 1575 |
memory statistics. If <$cellNum> is omitted, it defaults to C<Sys::Virt::NODE_MEMORY_STATS_ALL_CELLS> |
| 1576 |
which causes it to return cumulative information for all |
| 1577 |
NUMA cells in the host. If C<$cellNum> is zero or larger, it |
| 1578 |
returns information just for the specified number. The C<$flags> |
| 1579 |
parameter is currently unused and defaults to zero. The |
| 1580 |
fields in the returned hash reference are |
| 1581 |
|
| 1582 |
=over 4 |
| 1583 |
|
| 1584 |
=item total |
| 1585 |
|
| 1586 |
The total memory |
| 1587 |
|
| 1588 |
=item free |
| 1589 |
|
| 1590 |
The free memory |
| 1591 |
|
| 1592 |
=item buffers |
| 1593 |
|
| 1594 |
The memory consumed by buffers |
| 1595 |
|
| 1596 |
=item cached |
| 1597 |
|
| 1598 |
The memory consumed for cache |
| 1599 |
|
| 1600 |
=back |
| 1601 |
|
| 1602 |
=item my $params = $conn->get_node_memory_parameters($flags=0) |
| 1603 |
|
| 1604 |
Return a hash reference containing the set of memory tunable |
| 1605 |
parameters for the node. The keys in the hash are one of the |
| 1606 |
constants MEMORY PARAMETERS described later. The C<$flags> |
| 1607 |
parameter is currently unused, and defaults to 0 if omitted. |
| 1608 |
|
| 1609 |
=item $conn->set_node_memory_parameters($params, $flags=0) |
| 1610 |
|
| 1611 |
Update the memory tunable parameters for the node. The |
| 1612 |
C<$params> should be a hash reference whose keys are one |
| 1613 |
of the MEMORY PARAMETERS constants. The C<$flags> |
| 1614 |
parameter is currently unused, and defaults to 0 if omitted. |
| 1615 |
|
| 1616 |
|
| 1617 |
=item $info = $conn->get_node_sev_info($flags=0) |
| 1618 |
|
| 1619 |
Get the AMD SEV information for the host. C<$flags> is |
| 1620 |
currently unused and defaults to 0 if omitted. The returned |
| 1621 |
hash contains the following keys: |
| 1622 |
|
| 1623 |
=over 4 |
| 1624 |
|
| 1625 |
=item Sys::Virt::SEV_CBITPOS |
| 1626 |
|
| 1627 |
The CBit position |
| 1628 |
|
| 1629 |
=item Sys::Virt::SEV_CERT_CHAIN |
| 1630 |
|
| 1631 |
The certificate chain |
| 1632 |
|
| 1633 |
=item Sys::Virt::SEV_PDH |
| 1634 |
|
| 1635 |
Platform diffie-hellman key |
| 1636 |
|
| 1637 |
=item Sys::Virt::SEV_REDUCED_PHYS_BITS |
| 1638 |
|
| 1639 |
The number of physical address bits used by SEV |
| 1640 |
|
| 1641 |
=item Sys::Virt::SEV_MAX_GUESTS |
| 1642 |
|
| 1643 |
Maximum number of SEV guests that can be launched |
| 1644 |
|
| 1645 |
=item Sys::Virt::SEV_MAX_ES_GUESTS |
| 1646 |
|
| 1647 |
Maximum number of SEV-ES guests that can be launched |
| 1648 |
|
| 1649 |
=item Sys::Virt::SEV_CPU0_ID |
| 1650 |
|
| 1651 |
The SEV firmware ID for CPU 0 |
| 1652 |
|
| 1653 |
=back |
| 1654 |
|
| 1655 |
=item $conn->node_suspend_for_duration($target, $duration, $flags=0) |
| 1656 |
|
| 1657 |
Suspend the the host, using mode C<$target> which is one of the NODE |
| 1658 |
SUSPEND constants listed later. The C<$duration> parameter controls |
| 1659 |
how long the node is suspended for before waking up. |
| 1660 |
|
| 1661 |
=item $conn->domain_event_register($callback) |
| 1662 |
|
| 1663 |
Register a callback to received notifications of domain state change |
| 1664 |
events. Only a single callback can be registered with each connection |
| 1665 |
instance. The callback will be invoked with four parameters, an |
| 1666 |
instance of C<Sys::Virt> for the connection, an instance of C<Sys::Virt::Domain> |
| 1667 |
for the domain changing state, and a C<event> and C<detail> arguments, |
| 1668 |
corresponding to the event constants defined in the C<Sys::Virt::Domain> |
| 1669 |
module. Before discarding the connection object, the callback must be |
| 1670 |
deregistered, otherwise the connection object memory will never be |
| 1671 |
released in garbage collection. |
| 1672 |
|
| 1673 |
=item $conn->domain_event_deregister() |
| 1674 |
|
| 1675 |
Unregister a callback, allowing the connection object to be garbage |
| 1676 |
collected. |
| 1677 |
|
| 1678 |
=item $callbackID = $conn->domain_event_register_any($dom, $eventID, $callback) |
| 1679 |
|
| 1680 |
Register a callback to received notifications of domain events. |
| 1681 |
The C<$dom> parameter can be C<undef> to request events on all |
| 1682 |
known domains, or a specific C<Sys::Virt::Domain> object to |
| 1683 |
filter events. The C<$eventID> parameter is one of the EVENT ID |
| 1684 |
constants described later in this document. The C<$callback> is |
| 1685 |
a subroutine reference that will receive the events. |
| 1686 |
|
| 1687 |
All callbacks receive a C<Sys::Virt> connection as the first parameter |
| 1688 |
and a C<Sys::Virt::Domain> object indicating the domain on which the |
| 1689 |
event occurred as the second parameter. Subsequent parameters vary |
| 1690 |
according to the event type |
| 1691 |
|
| 1692 |
=over |
| 1693 |
|
| 1694 |
=item EVENT_ID_LIFECYCLE |
| 1695 |
|
| 1696 |
Extra C<event> and C<detail> parameters defining the lifecycle |
| 1697 |
transition that occurred. |
| 1698 |
|
| 1699 |
=item EVENT_ID_REBOOT |
| 1700 |
|
| 1701 |
No extra parameters |
| 1702 |
|
| 1703 |
=item EVENT_ID_RTC_CHANGE |
| 1704 |
|
| 1705 |
The C<utcoffset> gives the offset from UTC in seconds |
| 1706 |
|
| 1707 |
=item EVENT_ID_WATCHDOG |
| 1708 |
|
| 1709 |
The C<action> defines the action that is taken as a result |
| 1710 |
of the watchdog triggering. One of the WATCHDOG constants |
| 1711 |
described later |
| 1712 |
|
| 1713 |
=item EVENT_ID_IO_ERROR |
| 1714 |
|
| 1715 |
The C<srcPath> is the file on the host which had the error. |
| 1716 |
The C<devAlias> is the unique device alias from the guest |
| 1717 |
configuration associated with C<srcPath>. The C<action> is |
| 1718 |
the action taken as a result of the error, one of the |
| 1719 |
IO ERROR constants described later |
| 1720 |
|
| 1721 |
=item EVENT_ID_GRAPHICS |
| 1722 |
|
| 1723 |
The C<phase> is the stage of the connection, one of the GRAPHICS |
| 1724 |
PHASE constants described later. The C<local> and C<remote> |
| 1725 |
parameters follow with the details of the local and remote |
| 1726 |
network addresses. The C<authScheme> describes how the user |
| 1727 |
was authenticated (if at all). Finally C<identities> is an |
| 1728 |
array ref containing authenticated identities for the user, |
| 1729 |
if any. |
| 1730 |
|
| 1731 |
=back |
| 1732 |
|
| 1733 |
The return value is a unique callback ID that must be used when |
| 1734 |
unregistering the event. |
| 1735 |
|
| 1736 |
|
| 1737 |
=item $conn->domain_event_deregister_any($callbackID) |
| 1738 |
|
| 1739 |
Unregister a callback, associated with the C<$callbackID> previously |
| 1740 |
obtained from C<domain_event_register_any>. |
| 1741 |
|
| 1742 |
=item $callbackID = $conn->network_event_register_any($net, $eventID, $callback) |
| 1743 |
|
| 1744 |
Register a callback to received notifications of network events. |
| 1745 |
The C<$net> parameter can be C<undef> to request events on all |
| 1746 |
known networks, or a specific C<Sys::Virt::Network> object to |
| 1747 |
filter events. The C<$eventID> parameter is one of the EVENT ID |
| 1748 |
constants described later in this document. The C<$callback> is |
| 1749 |
a subroutine reference that will receive the events. |
| 1750 |
|
| 1751 |
All callbacks receive a C<Sys::Virt> connection as the first parameter |
| 1752 |
and a C<Sys::Virt::Network> object indicating the network on which the |
| 1753 |
event occurred as the second parameter. Subsequent parameters vary |
| 1754 |
according to the event type |
| 1755 |
|
| 1756 |
=over |
| 1757 |
|
| 1758 |
=item EVENT_ID_LIFECYCLE |
| 1759 |
|
| 1760 |
Extra C<event> and C<detail> parameters defining the lifecycle |
| 1761 |
transition that occurred. |
| 1762 |
|
| 1763 |
=back |
| 1764 |
|
| 1765 |
The return value is a unique callback ID that must be used when |
| 1766 |
unregistering the event. |
| 1767 |
|
| 1768 |
|
| 1769 |
=item $conn->network_event_deregister_any($callbackID) |
| 1770 |
|
| 1771 |
Unregister a callback, associated with the C<$callbackID> previously |
| 1772 |
obtained from C<network_event_register_any>. |
| 1773 |
|
| 1774 |
=item $callbackID = $conn->storage_pool_event_register_any($pool, $eventID, $callback) |
| 1775 |
|
| 1776 |
Register a callback to received notifications of storage pool events. |
| 1777 |
The C<$pool> parameter can be C<undef> to request events on all |
| 1778 |
known storage pools, or a specific C<Sys::Virt::StoragePool> object |
| 1779 |
to filter events. The C<$eventID> parameter is one of the EVENT ID |
| 1780 |
constants described later in this document. The C<$callback> is |
| 1781 |
a subroutine reference that will receive the events. |
| 1782 |
|
| 1783 |
All callbacks receive a C<Sys::Virt> connection as the first parameter |
| 1784 |
and a C<Sys::Virt::StoragePool> object indicating the storage pool on |
| 1785 |
which the event occurred as the second parameter. Subsequent parameters |
| 1786 |
vary according to the event type |
| 1787 |
|
| 1788 |
=over |
| 1789 |
|
| 1790 |
=item EVENT_ID_LIFECYCLE |
| 1791 |
|
| 1792 |
Extra C<event> and C<detail> parameters defining the lifecycle |
| 1793 |
transition that occurred. |
| 1794 |
|
| 1795 |
=item EVENT_ID_REFRESH |
| 1796 |
|
| 1797 |
No extra parameters. |
| 1798 |
|
| 1799 |
=back |
| 1800 |
|
| 1801 |
The return value is a unique callback ID that must be used when |
| 1802 |
unregistering the event. |
| 1803 |
|
| 1804 |
|
| 1805 |
=item $conn->storage_pool_event_deregister_any($callbackID) |
| 1806 |
|
| 1807 |
Unregister a callback, associated with the C<$callbackID> previously |
| 1808 |
obtained from C<storage_pool_event_register_any>. |
| 1809 |
|
| 1810 |
=item $callbackID = $conn->node_device_event_register_any($dev, $eventID, $callback) |
| 1811 |
|
| 1812 |
Register a callback to received notifications of node device events. |
| 1813 |
The C<$dev> parameter can be C<undef> to request events on all |
| 1814 |
known node devices, or a specific C<Sys::Virt::NodeDevice> object |
| 1815 |
to filter events. The C<$eventID> parameter is one of the EVENT ID |
| 1816 |
constants described later in this document. The C<$callback> is |
| 1817 |
a subroutine reference that will receive the events. |
| 1818 |
|
| 1819 |
All callbacks receive a C<Sys::Virt> connection as the first parameter |
| 1820 |
and a C<Sys::Virt::NodeDevice> object indicating the node device on |
| 1821 |
which the event occurred as the second parameter. Subsequent parameters |
| 1822 |
vary according to the event type |
| 1823 |
|
| 1824 |
=over |
| 1825 |
|
| 1826 |
=item EVENT_ID_LIFECYCLE |
| 1827 |
|
| 1828 |
Extra C<event> and C<detail> parameters defining the lifecycle |
| 1829 |
transition that occurred. |
| 1830 |
|
| 1831 |
=back |
| 1832 |
|
| 1833 |
The return value is a unique callback ID that must be used when |
| 1834 |
unregistering the event. |
| 1835 |
|
| 1836 |
|
| 1837 |
=item $conn->node_device_event_deregister_any($callbackID) |
| 1838 |
|
| 1839 |
Unregister a callback, associated with the C<$callbackID> previously |
| 1840 |
obtained from C<node_device_event_register_any>. |
| 1841 |
|
| 1842 |
=item $callbackID = $conn->secret_event_register_any($secret, $eventID, $callback) |
| 1843 |
|
| 1844 |
Register a callback to received notifications of secret events. |
| 1845 |
The C<$secret> parameter can be C<undef> to request events on all |
| 1846 |
known secrets, or a specific C<Sys::Virt::Secret> object to |
| 1847 |
filter events. The C<$eventID> parameter is one of the EVENT ID |
| 1848 |
constants described later in this document. The C<$callback> is |
| 1849 |
a subroutine reference that will receive the events. |
| 1850 |
|
| 1851 |
All callbacks receive a C<Sys::Virt> connection as the first parameter |
| 1852 |
and a C<Sys::Virt::Secret> object indicating the secret on which the |
| 1853 |
event occurred as the second parameter. Subsequent parameters vary |
| 1854 |
according to the event type |
| 1855 |
|
| 1856 |
=over |
| 1857 |
|
| 1858 |
=item EVENT_ID_LIFECYCLE |
| 1859 |
|
| 1860 |
Extra C<event> and C<detail> parameters defining the lifecycle |
| 1861 |
transition that occurred. |
| 1862 |
|
| 1863 |
=item EVENT_ID_VALUE_CHANGED |
| 1864 |
|
| 1865 |
No extra parameters. |
| 1866 |
|
| 1867 |
=back |
| 1868 |
|
| 1869 |
The return value is a unique callback ID that must be used when |
| 1870 |
unregistering the event. |
| 1871 |
|
| 1872 |
|
| 1873 |
=item $conn->secret_event_deregister_any($callbackID) |
| 1874 |
|
| 1875 |
Unregister a callback, associated with the C<$callbackID> previously |
| 1876 |
obtained from C<secret_event_register_any>. |
| 1877 |
|
| 1878 |
=item $conn->register_close_callback($coderef); |
| 1879 |
|
| 1880 |
Register a callback to be invoked when the connection is closed. |
| 1881 |
The callback will be invoked with two parameters, the C<$conn> |
| 1882 |
it was registered against, and the reason for the close event. |
| 1883 |
The reason value will be one of the C<CLOSE REASON CONSTANTS> |
| 1884 |
listed later in this document. |
| 1885 |
|
| 1886 |
=item $conn->unregister_close_callback(); |
| 1887 |
|
| 1888 |
Remove the previously registered close callback. |
| 1889 |
|
| 1890 |
=item my $xml = $con->baseline_cpu(\@xml, $flags=0) |
| 1891 |
|
| 1892 |
Given an array ref whose elements are XML documents describing host CPUs, |
| 1893 |
compute the baseline CPU model that is operable across all hosts. The |
| 1894 |
XML for the baseline CPU model is returned. The optional C<$flags> |
| 1895 |
parameter can take one of |
| 1896 |
|
| 1897 |
=over 4 |
| 1898 |
|
| 1899 |
=item Sys::Virt::BASELINE_CPU_EXPAND_FEATURES |
| 1900 |
|
| 1901 |
Expand the CPU definition to list all feature flags, even those |
| 1902 |
implied by the model name. |
| 1903 |
|
| 1904 |
=item Sys::Virt::BASELINE_CPU_MIGRATABLE |
| 1905 |
|
| 1906 |
Only include features which can be live migrated. |
| 1907 |
|
| 1908 |
=item Sys::Virt::BASELINE_CPU_IGNORE_HOST |
| 1909 |
|
| 1910 |
When multiple CPU definitions are available, do not make the result |
| 1911 |
dependent on the current host CPU. |
| 1912 |
|
| 1913 |
=back |
| 1914 |
|
| 1915 |
=item my $xml = $con->baseline_hypervisor_cpu($emulator, $arch, $machine, $virttype, \@xml, $flags=0) |
| 1916 |
|
| 1917 |
Given an array ref whose elements are XML documents describing host CPUs, |
| 1918 |
compute the baseline CPU model that is operable across all hosts. The |
| 1919 |
XML for the baseline CPU model is returned. Either C<$emulator> or C<$arch> |
| 1920 |
must be a valid string referring to an emulator binary or an |
| 1921 |
architecture name respectively. The C<$machine> parameter is |
| 1922 |
an optional name of a guest machine, and C<$virttype> is an |
| 1923 |
optional name of the virtualization type. The optional C<$flags> |
| 1924 |
parameter accepts the same values as C<baseline_cpu>. |
| 1925 |
|
| 1926 |
=item @names = $con->get_cpu_model_names($arch, $flags=0) |
| 1927 |
|
| 1928 |
Get a list of valid CPU models names for the architecture |
| 1929 |
given by C<$arch>. The C<$arch> value should be one of the |
| 1930 |
architectures listed in the capabilities XML document. |
| 1931 |
The C<$flags> parameter is currently unused and defaults |
| 1932 |
to 0. |
| 1933 |
|
| 1934 |
=item my $info = $con->get_node_security_model() |
| 1935 |
|
| 1936 |
Returns a hash reference summarising the security model of the |
| 1937 |
host node. There are two keys in the hash, C<model> specifying |
| 1938 |
the name of the security model (eg 'selinux') and C<doi> |
| 1939 |
specifying the 'domain of interpretation' for security labels. |
| 1940 |
|
| 1941 |
=item my $xml = $con->get_capabilities(); |
| 1942 |
|
| 1943 |
Returns an XML document describing the hypervisor capabilities |
| 1944 |
|
| 1945 |
=item my $xml = $con->get_domain_capabilities($emulator, $arch, $machine, $virttype, flags=0); |
| 1946 |
|
| 1947 |
Returns an XML document describing the capabilities of the |
| 1948 |
requested guest configuration. Either C<$emulator> or C<$arch> |
| 1949 |
must be a valid string referring to an emulator binary or an |
| 1950 |
architecture name respectively. The C<$machine> parameter is |
| 1951 |
an optional name of a guest machine, and C<$virttype> is an |
| 1952 |
optional name of the virtualization type. C<$flags> defaults |
| 1953 |
to zero, and accepts one or more of the following constants: |
| 1954 |
|
| 1955 |
=over 4 |
| 1956 |
|
| 1957 |
=item $Sys::Virt::DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES |
| 1958 |
|
| 1959 |
Disable deprecated features when reporting CPU model information. |
| 1960 |
|
| 1961 |
=item $Sys::Virt::DOMAIN_CAPABILITIES_EXPAND_CPU_FEATURES |
| 1962 |
|
| 1963 |
Expand base CPU features implied by the model name. |
| 1964 |
|
| 1965 |
=item $Sys::Virt::DOMAIN_CAPABILITIES_SUPPORTED_CPU_FEATURES |
| 1966 |
|
| 1967 |
Report all CPU features supported on the host, even those that |
| 1968 |
will not be enabled by host-model CPU mode. |
| 1969 |
|
| 1970 |
=back |
| 1971 |
|
| 1972 |
=item my $xml = $con->get_storage_pool_capabilities($flags=0); |
| 1973 |
|
| 1974 |
Returns an XML document describing the storage pool driver |
| 1975 |
capabilities (e.g. which storage pool types are supported and so |
| 1976 |
on). C<$flags> is currently unused and defaults to zero. |
| 1977 |
|
| 1978 |
=item my $result = $con->compare_cpu($xml, $flags=0); |
| 1979 |
|
| 1980 |
Checks whether the CPU definition in C<$xml> is compatible with the |
| 1981 |
current hypervisor connection. This can be used to determine whether |
| 1982 |
it is safe to migrate a guest to this host. The returned result is |
| 1983 |
one of the constants listed later The optional C<$flags> parameter |
| 1984 |
can take one of the following constants |
| 1985 |
|
| 1986 |
=over 4 |
| 1987 |
|
| 1988 |
=item Sys::Virt::COMPARE_CPU_FAIL_INCOMPATIBLE |
| 1989 |
|
| 1990 |
Raise a fatal error if the CPUs are not compatible, instead of |
| 1991 |
just returning a special error code. |
| 1992 |
|
| 1993 |
=item Sys::Virt::COMPARE_CPU_VALIDATE_XML |
| 1994 |
|
| 1995 |
Validate input XML document against the RNG schema. |
| 1996 |
|
| 1997 |
=back |
| 1998 |
|
| 1999 |
=item my $result = $con->compare_hypervisor_cpu($emulator, $arch, $machine, $virttype, $xml, $flags=0); |
| 2000 |
|
| 2001 |
Checks whether the CPU definition in C<$xml> is compatible with the |
| 2002 |
current hypervisor connection. This can be used to determine whether |
| 2003 |
it is safe to migrate a guest to this host. Either C<$emulator> or C<$arch> |
| 2004 |
must be a valid string referring to an emulator binary or an |
| 2005 |
architecture name respectively. The C<$machine> parameter is |
| 2006 |
an optional name of a guest machine, and C<$virttype> is an |
| 2007 |
optional name of the virtualization type. The returned result is |
| 2008 |
one of the constants listed later The optional C<$flags> parameter |
| 2009 |
can take the same values as the C<compare_cpu> method. |
| 2010 |
|
| 2011 |
=item $mem = $con->get_node_free_memory(); |
| 2012 |
|
| 2013 |
Returns the current free memory on the host |
| 2014 |
|
| 2015 |
=item @mem = $con->get_node_cells_free_memory($start, $end); |
| 2016 |
|
| 2017 |
Returns the free memory on each NUMA cell between C<$start> and C<$end>. |
| 2018 |
|
| 2019 |
=item @pages = $con->get_node_free_pages(\@pagesizes, $start, $end); |
| 2020 |
|
| 2021 |
Returns information about the number of pages free on each NUMA cell |
| 2022 |
between C<$start> and C<$end> inclusive. The C<@pagesizes> parameter |
| 2023 |
should be an arrayref specifying which pages sizes information should |
| 2024 |
be returned for. Information about supported page sizes is available |
| 2025 |
in the capabilities XML. The returned array has an element for each |
| 2026 |
NUMA cell requested. The elements are hash references with two keys, |
| 2027 |
'cell' specifies the NUMA cell number and 'pages' specifies the |
| 2028 |
free page information for that cell. The 'pages' value is another |
| 2029 |
hash reference where the keys are the page sizes and the values |
| 2030 |
are the free count for that size. |
| 2031 |
|
| 2032 |
=item $con->node_alloc_pages(\@pages, $start, $end, $flags=0) |
| 2033 |
|
| 2034 |
Allocate further huge pages for the reserved dev. The C<\@pages> |
| 2035 |
parameter is an array reference with one entry per page size to |
| 2036 |
allocate for. Each entry is a further array reference where the |
| 2037 |
first element is the page size and the second element is the |
| 2038 |
page count. The same number of pages will be allocated on each |
| 2039 |
NUMA node in the range C<$start> to C<$end> inclusive. The |
| 2040 |
C<$flags> parameter accepts two constants |
| 2041 |
|
| 2042 |
=over 4 |
| 2043 |
|
| 2044 |
=item Sys::Virt::NODE_ALLOC_PAGES_ADD |
| 2045 |
|
| 2046 |
The requested number of pages will be added to the existing huge |
| 2047 |
page reservation. |
| 2048 |
|
| 2049 |
=item Sys::Virt::NODE_ALLOC_PAGES_SET |
| 2050 |
|
| 2051 |
The huge page reservation will be set to exactly the requested |
| 2052 |
number |
| 2053 |
|
| 2054 |
=back |
| 2055 |
|
| 2056 |
=back |
| 2057 |
|
| 2058 |
=head1 CONSTANTS |
| 2059 |
|
| 2060 |
The following sets of constants are useful when dealing with APIs |
| 2061 |
in this package |
| 2062 |
|
| 2063 |
=head2 CONNECTION |
| 2064 |
|
| 2065 |
When opening a connection the following constants can be used: |
| 2066 |
|
| 2067 |
=over 4 |
| 2068 |
|
| 2069 |
=item Sys::Virt::CONNECT_RO |
| 2070 |
|
| 2071 |
Request a read-only connection |
| 2072 |
|
| 2073 |
=item Sys::Virt::CONNECT_NO_ALIASES |
| 2074 |
|
| 2075 |
Prevent the resolution of URI aliases |
| 2076 |
|
| 2077 |
=back |
| 2078 |
|
| 2079 |
=head2 CREDENTIAL TYPES |
| 2080 |
|
| 2081 |
When providing authentication callbacks, the following constants |
| 2082 |
indicate the type of credential being requested |
| 2083 |
|
| 2084 |
=over 4 |
| 2085 |
|
| 2086 |
=item Sys::Virt::CRED_AUTHNAME |
| 2087 |
|
| 2088 |
Identity to act as |
| 2089 |
|
| 2090 |
=item Sys::Virt::CRED_USERNAME |
| 2091 |
|
| 2092 |
Identity to authorize as |
| 2093 |
|
| 2094 |
=item Sys::Virt::CRED_CNONCE |
| 2095 |
|
| 2096 |
Client supplies a nonce |
| 2097 |
|
| 2098 |
=item Sys::Virt::CRED_REALM |
| 2099 |
|
| 2100 |
Authentication realm |
| 2101 |
|
| 2102 |
=item Sys::Virt::CRED_ECHOPROMPT |
| 2103 |
|
| 2104 |
Challenge response non-secret |
| 2105 |
|
| 2106 |
=item Sys::Virt::CRED_NOECHOPROMPT |
| 2107 |
|
| 2108 |
Challenge response secret |
| 2109 |
|
| 2110 |
=item Sys::Virt::CRED_PASSPHRASE |
| 2111 |
|
| 2112 |
Passphrase secret |
| 2113 |
|
| 2114 |
=item Sys::Virt::CRED_LANGUAGE |
| 2115 |
|
| 2116 |
RFC 1766 language code |
| 2117 |
|
| 2118 |
=item Sys::Virt::CRED_EXTERNAL |
| 2119 |
|
| 2120 |
Externally provided credential |
| 2121 |
|
| 2122 |
=back |
| 2123 |
|
| 2124 |
=head2 IDENTITY CONSTANTS |
| 2125 |
|
| 2126 |
The following constants are useful to change the connection identity |
| 2127 |
|
| 2128 |
=over 4 |
| 2129 |
|
| 2130 |
=item Sys::Virt::IDENTITY_USER_NAME |
| 2131 |
|
| 2132 |
The process user name |
| 2133 |
|
| 2134 |
=item Sys::Virt::IDENTITY_UNIX_USER_ID |
| 2135 |
|
| 2136 |
The process UNIX user ID |
| 2137 |
|
| 2138 |
=item Sys::Virt::IDENTITY_GROUP_NAME |
| 2139 |
|
| 2140 |
The process group name |
| 2141 |
|
| 2142 |
=item Sys::Virt::IDENTITY_UNIX_GROUP_ID |
| 2143 |
|
| 2144 |
The process UNIX group ID |
| 2145 |
|
| 2146 |
=item Sys::Virt::IDENTITY_PROCESS_ID |
| 2147 |
|
| 2148 |
The process ID. |
| 2149 |
|
| 2150 |
=item Sys::Virt::IDENTITY_PROCESS_TIME |
| 2151 |
|
| 2152 |
The process start time. |
| 2153 |
|
| 2154 |
=item Sys::Virt::IDENTITY_SASL_USER_NAME |
| 2155 |
|
| 2156 |
The SASL authenticated user name |
| 2157 |
|
| 2158 |
=item Sys::Virt::IDENTITY_X509_DISTINGUISHED_NAME |
| 2159 |
|
| 2160 |
The X509 certificate distinguished name for the TLS connection |
| 2161 |
|
| 2162 |
=item Sys::Virt::IDENTITY_SELINUX_CONTEXT |
| 2163 |
|
| 2164 |
The SELinux process context |
| 2165 |
|
| 2166 |
=back |
| 2167 |
|
| 2168 |
=head2 CPU COMPARISON CONSTANTS |
| 2169 |
|
| 2170 |
=over 4 |
| 2171 |
|
| 2172 |
=item Sys::Virt::CPU_COMPARE_INCOMPATIBLE |
| 2173 |
|
| 2174 |
This host is missing one or more CPU features in the CPU |
| 2175 |
description |
| 2176 |
|
| 2177 |
=item Sys::Virt::CPU_COMPARE_IDENTICAL |
| 2178 |
|
| 2179 |
The host has an identical CPU description |
| 2180 |
|
| 2181 |
=item Sys::Virt::CPU_COMPARE_SUPERSET |
| 2182 |
|
| 2183 |
The host offers a superset of the CPU descriptoon |
| 2184 |
|
| 2185 |
=back |
| 2186 |
|
| 2187 |
=head2 NODE SUSPEND CONSTANTS |
| 2188 |
|
| 2189 |
=over 4 |
| 2190 |
|
| 2191 |
=item Sys::Virt::NODE_SUSPEND_TARGET_MEM |
| 2192 |
|
| 2193 |
Suspends to memory (equivalent of S3 on x86 architectures) |
| 2194 |
|
| 2195 |
=item Sys::Virt::NODE_SUSPEND_TARGET_DISK |
| 2196 |
|
| 2197 |
Suspends to disk (equivalent of S5 on x86 architectures) |
| 2198 |
|
| 2199 |
=item Sys::Virt::NODE_SUSPEND_TARGET_HYBRID |
| 2200 |
|
| 2201 |
Suspends to memory and disk (equivalent of S3+S5 on x86 architectures) |
| 2202 |
|
| 2203 |
=back |
| 2204 |
|
| 2205 |
=head2 NODE VCPU CONSTANTS |
| 2206 |
|
| 2207 |
=over 4 |
| 2208 |
|
| 2209 |
=item Sys::Virt::NODE_CPU_STATS_ALL_CPUS |
| 2210 |
|
| 2211 |
Request statistics for all CPUs |
| 2212 |
|
| 2213 |
=back |
| 2214 |
|
| 2215 |
=head2 NODE MEMORY CONSTANTS |
| 2216 |
|
| 2217 |
=over 4 |
| 2218 |
|
| 2219 |
=item Sys::Virt::NODE_MEMORY_STATS_ALL_CELLS |
| 2220 |
|
| 2221 |
Request statistics for all memory cells |
| 2222 |
|
| 2223 |
=back |
| 2224 |
|
| 2225 |
=head2 MEMORY PARAMETERS |
| 2226 |
|
| 2227 |
The following constants are used to name memory |
| 2228 |
parameters of the node |
| 2229 |
|
| 2230 |
=over 4 |
| 2231 |
|
| 2232 |
=item Sys::Virt::NODE_MEMORY_SHARED_FULL_SCANS |
| 2233 |
|
| 2234 |
How many times all mergeable areas have been scanned. |
| 2235 |
|
| 2236 |
=item Sys::Virt::NODE_MEMORY_SHARED_PAGES_SHARED |
| 2237 |
|
| 2238 |
How many the shared memory pages are being used. |
| 2239 |
|
| 2240 |
=item Sys::Virt::NODE_MEMORY_SHARED_PAGES_SHARING |
| 2241 |
|
| 2242 |
How many sites are sharing the pages |
| 2243 |
|
| 2244 |
=item Sys::Virt::NODE_MEMORY_SHARED_PAGES_TO_SCAN |
| 2245 |
|
| 2246 |
How many present pages to scan before the shared memory service goes to sleep |
| 2247 |
|
| 2248 |
=item Sys::Virt::NODE_MEMORY_SHARED_PAGES_UNSHARED |
| 2249 |
|
| 2250 |
How many pages unique but repeatedly checked for merging. |
| 2251 |
|
| 2252 |
=item Sys::Virt::NODE_MEMORY_SHARED_PAGES_VOLATILE |
| 2253 |
|
| 2254 |
How many pages changing too fast to be placed in a tree. |
| 2255 |
|
| 2256 |
=item Sys::Virt::NODE_MEMORY_SHARED_SLEEP_MILLISECS |
| 2257 |
|
| 2258 |
How many milliseconds the shared memory service should sleep before next scan. |
| 2259 |
|
| 2260 |
=item Sys::Virt::NODE_MEMORY_SHARED_MERGE_ACROSS_NODES |
| 2261 |
|
| 2262 |
Whether pages can be merged across NUMA nodes |
| 2263 |
|
| 2264 |
=back |
| 2265 |
|
| 2266 |
=head2 CLOSE REASON CONSTANTS |
| 2267 |
|
| 2268 |
The following constants related to the connection close callback, |
| 2269 |
describe the reason for the closing of the connection. |
| 2270 |
|
| 2271 |
=over 4 |
| 2272 |
|
| 2273 |
=item Sys::Virt::CLOSE_REASON_CLIENT |
| 2274 |
|
| 2275 |
The client application requested the connection be closed |
| 2276 |
|
| 2277 |
=item Sys::Virt::CLOSE_REASON_EOF |
| 2278 |
|
| 2279 |
End-of-file was encountered reading data from the connection |
| 2280 |
|
| 2281 |
=item Sys::Virt::CLOSE_REASON_ERROR |
| 2282 |
|
| 2283 |
An I/O error was encountered reading/writing data from/to the |
| 2284 |
connection |
| 2285 |
|
| 2286 |
=item Sys::Virt::CLOSE_REASON_KEEPALIVE |
| 2287 |
|
| 2288 |
The connection keepalive timer triggered due to lack of response |
| 2289 |
from the server |
| 2290 |
|
| 2291 |
=back |
| 2292 |
|
| 2293 |
=head2 CPU STATS CONSTANTS |
| 2294 |
|
| 2295 |
The following constants provide the names of known CPU stats fields |
| 2296 |
|
| 2297 |
=over 4 |
| 2298 |
|
| 2299 |
=item Sys::Virt::NODE_CPU_STATS_IDLE |
| 2300 |
|
| 2301 |
Time spent idle |
| 2302 |
|
| 2303 |
=item Sys::Virt::NODE_CPU_STATS_IOWAIT |
| 2304 |
|
| 2305 |
Time spent waiting for I/O to complete |
| 2306 |
|
| 2307 |
=item Sys::Virt::NODE_CPU_STATS_KERNEL |
| 2308 |
|
| 2309 |
Time spent executing kernel code |
| 2310 |
|
| 2311 |
=item Sys::Virt::NODE_CPU_STATS_USER |
| 2312 |
|
| 2313 |
Time spent executing user code |
| 2314 |
|
| 2315 |
=item Sys::Virt::NODE_CPU_STATS_INTR |
| 2316 |
|
| 2317 |
Time spent processing interrupts |
| 2318 |
|
| 2319 |
=item Sys::Virt::NODE_CPU_STATS_UTILIZATION |
| 2320 |
|
| 2321 |
Percentage utilization of the CPU. |
| 2322 |
|
| 2323 |
=item Sys::Virt::NODE_CPU_STATS_GUEST |
| 2324 |
|
| 2325 |
Time spent running guest virtual CPUs |
| 2326 |
|
| 2327 |
=back |
| 2328 |
|
| 2329 |
=head2 MEMORY STAS CONSTANTS |
| 2330 |
|
| 2331 |
The following constants provide the names of known memory stats fields |
| 2332 |
|
| 2333 |
=over 4 |
| 2334 |
|
| 2335 |
=item Sys::Virt::NODE_MEMORY_STATS_AVAILABLE |
| 2336 |
|
| 2337 |
The amount of memory available. It is only returned in case C<$cellNum> |
| 2338 |
parameter of C<get_node_memory_stats> equals NODE_MEMORY_STATS_ALL_CELLS. |
| 2339 |
|
| 2340 |
=item Sys::Virt::NODE_MEMORY_STATS_BUFFERS |
| 2341 |
|
| 2342 |
The amount of memory consumed by I/O buffers |
| 2343 |
|
| 2344 |
=item Sys::Virt::NODE_MEMORY_STATS_CACHED |
| 2345 |
|
| 2346 |
The amount of memory consumed by disk cache |
| 2347 |
|
| 2348 |
=item Sys::Virt::NODE_MEMORY_STATS_FREE |
| 2349 |
|
| 2350 |
The amount of free memory |
| 2351 |
|
| 2352 |
=item Sys::Virt::NODE_MEMORY_STATS_TOTAL |
| 2353 |
|
| 2354 |
The total amount of memory |
| 2355 |
|
| 2356 |
=back |
| 2357 |
|
| 2358 |
=head2 IP address constants |
| 2359 |
|
| 2360 |
The following constants are used to interpret IP address types |
| 2361 |
|
| 2362 |
=over 4 |
| 2363 |
|
| 2364 |
=item Sys::Virt::IP_ADDR_TYPE_IPV4 |
| 2365 |
|
| 2366 |
An IPv4 address type |
| 2367 |
|
| 2368 |
=item Sys::Virt::IP_ADDR_TYPE_IPV6 |
| 2369 |
|
| 2370 |
An IPv6 address type |
| 2371 |
|
| 2372 |
=back |
| 2373 |
|
| 2374 |
=head1 BUGS |
| 2375 |
|
| 2376 |
Hopefully none, but the XS code needs to be audited to ensure it |
| 2377 |
is not leaking memory. |
| 2378 |
|
| 2379 |
=head1 AUTHORS |
| 2380 |
|
| 2381 |
Daniel P. Berrange <[email protected]> |
| 2382 |
|
| 2383 |
=head1 COPYRIGHT |
| 2384 |
|
| 2385 |
Copyright (C) 2006-2009 Red Hat |
| 2386 |
Copyright (C) 2006-2009 Daniel P. Berrange |
| 2387 |
|
| 2388 |
=head1 LICENSE |
| 2389 |
|
| 2390 |
This program is free software; you can redistribute it and/or modify |
| 2391 |
it under the terms of either the GNU General Public License as published |
| 2392 |
by the Free Software Foundation (either version 2 of the License, or at |
| 2393 |
your option any later version), or, the Artistic License, as specified |
| 2394 |
in the Perl README file. |
| 2395 |
|
| 2396 |
=head1 SEE ALSO |
| 2397 |
|
| 2398 |
L<Sys::Virt::Domain>, L<Sys::Virt::Network>, L<Sys::Virt::StoragePool>, |
| 2399 |
L<Sys::Virt::StorageVol>, L<Sys::Virt::Error>, C<http://libvirt.org> |
| 2400 |
|
| 2401 |
=cut |