/usr/lib/perl5/Sys/Virt/DomainSnapshot.pm is in libsys-virt-perl 1.2.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | # -*- perl -*-
#
# Copyright (C) 2006 Red Hat
# Copyright (C) 2006-2007 Daniel P. Berrange
#
# This program is free software; You can redistribute it and/or modify
# it under either:
#
# a) the GNU General Public License as published by the Free
# Software Foundation; either version 2, or (at your option) any
# later version,
#
# or
#
# b) the "Artistic License"
#
# The file "LICENSE" distributed along with this file provides full
# details of the terms and conditions of the two licenses.
=pod
=head1 NAME
Sys::Virt::DomainSnapshot - Represent & manage a libvirt guest domain
=head1 DESCRIPTION
The C<Sys::Virt::DomainSnapshot> module represents a guest domain managed
by the virtual machine monitor.
=head1 METHODS
=over 4
=cut
package Sys::Virt::DomainSnapshot;
use strict;
use warnings;
sub _new {
my $proto = shift;
my $class = ref($proto) || $proto;
my %params = @_;
my $dom = exists $params{domain} ? $params{domain} : die "domain parameter is required";
my $self;
if (exists $params{name}) {
$self = Sys::Virt::DomainSnapshot::_lookup_by_name($dom, $params{name});
} elsif (exists $params{xml}) {
$self = Sys::Virt::DomainSnapshot::_create_xml($dom, $params{xml}, $params{flags} ? $params{flags} : 0);
} else {
die "name or xml parameters are required";
}
bless $self, $class;
return $self;
}
=item my $str = $domss->get_name()
Return the name of the snapshot
=item my $xml = $domss->get_xml_description($flags)
Returns an XML document containing a complete description of
the domain's configuration.
=item $domss->delete($flags)
Deletes this snapshot object & its data. The optional C<$flags> parameter controls
what should be deleted via the C<Sys::Virt::DomainSnapshot::DELETE_*>
constants.
=item $domss->revert_to($flags)
Revert the domain to the state associated with this snapshot. The optional
C<$flags> control the state of the vm after the revert via the
C<Sys::Virt::DomainSnapshot::REVERT_*> constants.
=item $parentss = $domss->get_parent();
Return the parent of the snapshot, if any
=item $res = $domss->is_current()
Returns a true value if this is the current snapshot. False otherwise.
=item $res = $domss->has_metadata()
Returns a true value if this snapshot has metadata associated with
it.
=item $count = $domss->num_of_child_snapshots()
Return the number of saved snapshots which are children of this snapshot
=item @names = $domss->list_child_snapshot_names()
List the names of all saved snapshots which are children of this
snapshot . The names can be used with the C<lookup_snapshot_by_name>
=item @snapshots = $domss->list_child_snapshots()
Return a list of all snapshots that are children of this snapshot. The elements
in the returned list are instances of the L<Sys::Virt::DomainSnapshot> class.
This method requires O(n) RPC calls, so the C<list_all_children> method is
recommended as a more efficient alternative.
=cut
sub list_child_snapshots {
my $self = shift;
my $nnames = $self->num_of_child_snapshots();
my @names = $self->list_child_snapshot_names($nnames);
my @snapshots;
foreach my $name (@names) {
eval {
push @snapshots, Sys::Virt::DomainSnapshot->_new(domain => $self, name => $name);
};
if ($@) {
# nada - snapshot went away before we could look it up
};
}
return @snapshots;
}
=item my @snapshots = $domss->list_all_children($flags)
Return a list of all domain snapshots that are children of this
snapshot. The elements in the returned list are instances of the
L<Sys::Virt::DomainSnapshot> class. The C<$flags> parameter can be
used to filter the list of return domain snapshots.
=back
=head1 CONSTANTS
=head2 SNAPSHOT CREATION
The following constants are useful when creating snapshots
=over 4
=item Sys::Virt::DomainSnapshot::CREATE_CURRENT
Set the defined snapshot to be the current snapshot
=item Sys::Virt::DomainSnapshot::CREATE_DISK_ONLY
Only snapshot the disk, not the memory state
=item Sys::Virt::DomainSnapshot::CREATE_HALT
Stop the guest after creating the snapshot
=item Sys::Virt::DomainSnapshot::CREATE_NO_METADATA
Do not save any metadata for the snapshot
=item Sys::Virt::DomainSnapshot::CREATE_REDEFINE
Replace/set the metadata with the snapshot
=item Sys::Virt::DomainSnapshot::CREATE_QUIESCE
Quiesce the guest disks while taking the snapshot
=item Sys::Virt::DomainSnapshot::CREATE_REUSE_EXT
Reuse the existing snapshot data files (if any)
=item Sys::Virt::DomainSnapshot::CREATE_ATOMIC
Create multiple disk snapshots atomically
=item Sys::Virt::DomainSnapshot::CREATE_LIVE
Create snapshot while the guest is running
=back
=head2 SNAPSHOT DELETION
The following constants are useful when deleting snapshots
=over 4
=item Sys::Virt::DomainSnapshot::DELETE_CHILDREN
Recursively delete any child snapshots
=item Sys::Virt::DomainSnapshot::DELETE_CHILDREN_ONLY
Only delete the child snapshots
=item Sys::Virt::DomainSnapshot::DELETE_METADATA_ONLY
Only delete the snapshot metadata
=back
=head2 SNAPSHOT LIST
The following constants are useful when listing snapshots
=over 4
=item Sys::Virt::DomainSnapshot::LIST_METADATA
Only list snapshots which have metadata
=item Sys::Virt::DomainSnapshot::LIST_ROOTS
Only list snapshots which are root nodes in the tree
=item Sys::Virt::DomainSnapshot::LIST_DESCENDANTS
Only list snapshots which are descendants of the current
snapshot
=item Sys::Virt::DomainSnapshot::LIST_LEAVES
Only list leaf nodes in the snapshot tree
=item Sys::Virt::DomainSnapshot::LIST_NO_LEAVES
Only list non-leaf nodes in the snapshot tree
=item Sys::Virt::DomainSnapshot::LIST_NO_METADATA
Only list snapshots without metadata
=item Sys::Virt::DomainSnapshot::LIST_ACTIVE
Only list snapshots taken while the guest was running
=item Sys::Virt::DomainSnapshot::LIST_INACTIVE
Only list snapshots taken while the guest was inactive
=item Sys::Virt::DomainSnapshot::LIST_EXTERNAL
Only list snapshots stored in external disk images
=item Sys::Virt::DomainSnapshot::LIST_INTERNAL
Only list snapshots stored in internal disk images
=item Sys::Virt::DomainSnapshot::LIST_DISK_ONLY
Only list snapshots taken while the guest was running,
which did not include memory state.
=back
=head2 SNAPSHOT REVERT
The following constants are useful when reverting snapshots
=over 4
=item Sys::Virt::DomainSnapshot::REVERT_PAUSED
Leave the guest CPUs paused after reverting to the snapshot state
=item Sys::Virt::DomainSnapshot::REVERT_RUNNING
Start the guest CPUs after reverting to the snapshot state
=item Sys::Virt::DomainSnapshot::REVERT_FORCE
Force the snapshot to revert, even if it is risky to do so
=back
=over 4
=cut
1;
=back
=head1 AUTHORS
Daniel P. Berrange <berrange@redhat.com>
=head1 COPYRIGHT
Copyright (C) 2006 Red Hat
Copyright (C) 2006-2007 Daniel P. Berrange
=head1 LICENSE
This program is free software; you can redistribute it and/or modify
it under the terms of either the GNU General Public License as published
by the Free Software Foundation (either version 2 of the License, or at
your option any later version), or, the Artistic License, as specified
in the Perl README file.
=head1 SEE ALSO
L<Sys::Virt>, L<Sys::Virt::Error>, C<http://libvirt.org>
=cut
|