perl: Remove use of Sys::Guestfs::Lib::open_guest function.

This obsolete function does all sorts of libvirt/XML things, which can
now be replaced by using ordinary API calls; especially $g->add_domain.
This commit is contained in:
Richard W.M. Jones
2013-04-02 13:11:33 +01:00
parent ecda39bed4
commit 2287b988ee
5 changed files with 51 additions and 25 deletions

View File

@@ -21,10 +21,11 @@
use strict;
use Sys::Guestfs;
use Sys::Guestfs::Lib qw(open_guest);
$ENV{FAKE_LIBVIRT_XML} = "rhbz701814-faked.xml";
my $abs_srcdir = $ENV{abs_srcdir};
my $g = open_guest (["winxppro"],
address => "test://$abs_srcdir/rhbz701814-node.xml");
my $uri = "test://$abs_srcdir/rhbz701814-node.xml";
my $g = Sys::Guestfs->new ();
$g->add_domain ("winxppro", libvirturi => $uri, readonly => 1);

View File

@@ -20,7 +20,6 @@ use warnings;
use strict;
use Sys::Guestfs;
use Sys::Guestfs::Lib qw(open_guest);
use Pod::Usage;
use Getopt::Long;
use Locale::TextDomain 'libguestfs';
@@ -150,11 +149,17 @@ if ($version) {
pod2usage (__"virt-list-filesystems: no image or VM name given")
if @ARGV <= 0;
my $g;
if ($uri) {
$g = open_guest (\@ARGV, address => $uri, format => $format);
} else {
$g = open_guest (\@ARGV, format => $format);
my $g = Sys::Guestfs->new ();
my @args = (readonly => 1);
push @args, format => $format if defined $format;
if (-e $ARGV[0]) {
$g->add_drive ($_, @args) foreach @ARGV;
}
else {
push @args, libvirturi => $uri if defined $uri;
$g->add_domain ($_, @args) foreach @ARGV;
}
$g->launch ();

View File

@@ -20,7 +20,6 @@ use warnings;
use strict;
use Sys::Guestfs;
use Sys::Guestfs::Lib qw(open_guest);
use Pod::Usage;
use Getopt::Long;
use Locale::TextDomain 'libguestfs';
@@ -162,11 +161,17 @@ if ($version) {
pod2usage (__"virt-list-partitions: no image or VM name given")
if @ARGV <= 0;
my $g;
if ($uri) {
$g = open_guest (\@ARGV, address => $uri, format => $format);
} else {
$g = open_guest (\@ARGV, format => $format);
my $g = Sys::Guestfs->new ();
my @args = (readonly => 1);
push @args, format => $format if defined $format;
if (-e $ARGV[0]) {
$g->add_drive ($_, @args) foreach @ARGV;
}
else {
push @args, libvirturi => $uri if defined $uri;
$g->add_domain ($_, @args) foreach @ARGV;
}
$g->launch ();

View File

@@ -20,7 +20,6 @@ use warnings;
use strict;
use Sys::Guestfs;
use Sys::Guestfs::Lib qw(open_guest);
use Pod::Usage;
use Getopt::Long;
use File::Basename;
@@ -240,12 +239,20 @@ die __x("virt-tar: {dir}: directory name must start with '/' character\n",
dir => $directory)
unless substr ($directory, 0, 1) eq "/";
my @args = (\@ARGV);
push @args, address => $uri if $uri;
push @args, rw => 1 if $mode eq "u";
my @args = ();
push @args, readonly => 1 unless $mode eq "u";
push @args, format => $format if defined $format;
my $g = open_guest (@args);
my $g = Sys::Guestfs->new ();
if (-e $ARGV[0]) {
$g->add_drive ($_, @args) foreach @ARGV;
}
else {
push @args, libvirturi => $uri if defined $uri;
$g->add_domain ($_, @args) foreach @ARGV;
}
$g->launch ();
my @roots = $g->inspect_os ();

View File

@@ -20,7 +20,6 @@ use warnings;
use strict;
use Sys::Guestfs;
use Sys::Guestfs::Lib qw(open_guest);
use Win::Hivex;
use Win::Hivex::Regedit qw(reg_import reg_export);
@@ -247,11 +246,20 @@ my $domname_or_image = shift @ARGV;
warn "launching libguestfs ..." if $debug;
my @lib_args = ([$domname_or_image]);
push @lib_args, address => $uri if $uri;
push @lib_args, rw => 1 if $merge;
my @lib_args = ();
push @lib_args, readonly => 1 unless $merge;
push @lib_args, format => $format if defined $format;
my $g = open_guest (@lib_args);
my $g = Sys::Guestfs->new ();
if (-e $domname_or_image) {
$g->add_drive ($domname_or_image, @lib_args);
}
else {
push @lib_args, libvirturi => $uri if defined $uri;
$g->add_domain ($domname_or_image, @lib_args);
}
$g->launch ();
warn "inspecting guest ..." if $debug;