[Libguestfs] [PATCH] virt-inspector --fish: Fix incorrect '-a' parameter (RHBZ#512709)
Richard W.M. Jones
rjones at redhat.com
Mon Jul 20 14:12:51 UTC 2009
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/
-------------- next part --------------
>From 7a14e0509d5cc976deda9b5299f56930e0317502 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at trick.home.annexia.org>
Date: Mon, 20 Jul 2009 15:09:11 +0100
Subject: [PATCH] virt-inspector --fish: Fix incorrect '-a' parameter (RHBZ#512709)
virt-inspector --fish dom
virt-inspector --ro-fish dom
Both of the above commands give incorrect results if run on a
libvirt domain, eg:
$ virt-inspector --ro-fish RHEL54Betax64
==> --ro -a RHEL54Betax64 -m /dev/VolGroup00/LogVol00:/ -m /dev/sda1:/boot
^^^^^^^^^^^^^
This is because the current code just prints back the original @ARGV
parameters.
This patch fixes this by getting the image names instead.
---
inspector/virt-inspector.pl | 11 ++++++++---
perl/lib/Sys/Guestfs/Lib.pm | 12 ++++++------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/inspector/virt-inspector.pl b/inspector/virt-inspector.pl
index cd53bcb..09edbae 100755
--- a/inspector/virt-inspector.pl
+++ b/inspector/virt-inspector.pl
@@ -207,10 +207,15 @@ pod2usage (__"virt-inspector: no image or VM names given") if @ARGV == 0;
my $rw = 0;
$rw = 1 if $output eq "fish";
my $g;
+my @images;
if ($uri) {
- $g = open_guest (\@ARGV, rw => $rw, address => $uri);
+ my ($conn, $dom);
+ ($g, $conn, $dom, @images) =
+ open_guest (\@ARGV, rw => $rw, address => $uri);
} else {
- $g = open_guest (\@ARGV, rw => $rw);
+ my ($conn, $dom);
+ ($g, $conn, $dom, @images) =
+ open_guest (\@ARGV, rw => $rw);
}
$g->launch ();
@@ -302,7 +307,7 @@ if ($output eq "fish" || $output eq "ro-fish") {
print "--ro ";
}
- print "-a $_ " foreach @ARGV;
+ print "-a $_ " foreach @images;
my $mounts = $oses->{$root_dev}->{mounts};
# Have to mount / first. Luckily '/' is early in the ASCII
diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm
index f084090..a581def 100644
--- a/perl/lib/Sys/Guestfs/Lib.pm
+++ b/perl/lib/Sys/Guestfs/Lib.pm
@@ -78,7 +78,7 @@ use vars qw(@EXPORT_OK @ISA);
$g = open_guest ([$img1, $img2, ...], address => $uri, ...);
- ($g, $conn, $dom) = open_guest ($name);
+ ($g, $conn, $dom, @images) = open_guest ($name);
This function opens a libguestfs handle for either the libvirt domain
called C<$name>, or the disk image called C<$name>. Any disk images
@@ -108,10 +108,10 @@ passed through to C<Sys::Virt-E<gt>new> unchanged.
The implicit libvirt handle is closed after this function, I<unless>
you call the function in C<wantarray> context, in which case the
function returns a tuple of: the open libguestfs handle, the open
-libvirt handle, and the open libvirt domain handle. (This is useful
-if you want to do other things like pulling the XML description of the
-guest). Note that if this is a straight disk image, then C<$conn> and
-C<$dom> will be C<undef>.
+libvirt handle, and the open libvirt domain handle, and a list of
+images. (This is useful if you want to do other things like pulling
+the XML description of the guest). Note that if this is a straight
+disk image, then C<$conn> and C<$dom> will be C<undef>.
If the C<Sys::Virt> module is not available, then libvirt is bypassed,
and this function can only open disk images.
@@ -204,7 +204,7 @@ sub open_guest
}
}
- return wantarray ? ($g, $conn, $dom) : $g
+ return wantarray ? ($g, $conn, $dom, @images) : $g
}
=head2 get_partitions
--
1.6.2.5
More information about the Libguestfs
mailing list