Commit 75b5f220 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add an example for using save/restore

parent 4894143d
use strict;
use warnings;
use Sys::Virt;
my $xml = <<EOF;
<domain type='kvm'>
<type arch='i686'>hvm</type>
<boot dev='network'/>
<clock offset='utc'/>
<serial type='pty'>
<target port='0'/>
my $conn = Sys::Virt->new(uri => "qemu:///session");
print "Starting a transient guest\n";
my $dom = $conn->create_domain($xml);
print "Saving the guest\n";
my $curxml = $dom->get_xml_description();
$dom->save("perl-demo.img", $curxml, Sys::Virt::Domain::SAVE_BYPASS_CACHE);
my $newxml = $conn->get_save_image_xml_description("perl-demo.img");
print $newxml;
print "Restoring the guest\n";
$conn->restore_domain("perl-demo.img", $newxml, Sys::Virt::Domain::SAVE_BYPASS_CACHE);
print "Destroying the guest\n";
$dom = $conn->get_domain_by_name("perl-demo");
unlink "perl-demo.img";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment