git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix detection of optional libvirt support in virt-inspector.
[libguestfs.git]
/
inspector
/
virt-inspector.pl
diff --git
a/inspector/virt-inspector.pl
b/inspector/virt-inspector.pl
index
1d8a84b
..
6aa63ad
100755
(executable)
--- a/
inspector/virt-inspector.pl
+++ b/
inspector/virt-inspector.pl
@@
-27,6
+27,8
@@
use File::Temp qw/tempdir/;
# Optional:
eval "use Sys::Virt;";
# Optional:
eval "use Sys::Virt;";
+eval "use XML::XPath;";
+eval "use XML::XPath::XMLParser;";
=encoding utf8
=encoding utf8
@@
-145,7
+147,7
@@
If you select I<--fish> then we print a L<guestfish(1)> command
line which will automatically mount up the filesystems on the
correct mount points. Try this for example:
line which will automatically mount up the filesystems on the
correct mount points. Try this for example:
- eval `virt-inspector --fish guest.img`
+ guestfish $(virt-inspector --fish guest.img)
I<--ro-fish> is the same, but the I<--ro> option is passed to
guestfish so that the filesystems are mounted read-only.
I<--ro-fish> is the same, but the I<--ro> option is passed to
guestfish so that the filesystems are mounted read-only.
@@
-204,8
+206,10
@@
if (-e $ARGV[0]) {
}
}
} else {
}
}
} else {
- die "no libvirt support (install Sys::Virt)"
- unless exists $INC{"Sys/Virt.pm"};
+ die "virt-inspector: no libvirt support (install Sys::Virt, XML::XPath and XML::XPath::XMLParser)\n"
+ unless exists $INC{"Sys/Virt.pm"} &&
+ exists $INC{"XML/XPath.pm"} &&
+ exists $INC{"XML/XPath/XMLParser.pm"};
pod2usage ("$0: too many domains listed on command line") if @ARGV > 1;
pod2usage ("$0: too many domains listed on command line") if @ARGV > 1;
@@
-231,14
+235,9
@@
if (-e $ARGV[0]) {
# Get the names of the image(s).
my $xml = $dom->get_xml_description ();
# Get the names of the image(s).
my $xml = $dom->get_xml_description ();
- my $p = new XML::XPath::XMLParser (xml => $xml);
- my $disks = $p->find ("//devices/disk");
- print "disks:\n";
- foreach ($disks->get_nodelist) {
- print XML::XPath::XMLParser::as_string($_);
- }
-
- die "XXX"
+ my $p = XML::XPath->new (xml => $xml);
+ my @disks = $p->findnodes ('//devices/disk/source/@dev');
+ @images = map { $_->getData } @disks;
}
# We've now got the list of @images, so feed them to libguestfs.
}
# We've now got the list of @images, so feed them to libguestfs.
@@
-299,7
+298,7
@@
L<guestfish(1)> command line parameters, so that you can go in
afterwards and inspect the guest with everything mounted in the
right place. For example:
afterwards and inspect the guest with everything mounted in the
right place. For example:
- eval `virt-inspector --ro-fish guest.img`
+ guestfish $(virt-inspector --ro-fish guest.img)
==> guestfish --ro -a guest.img -m /dev/VG/LV:/ -m /dev/sda1:/boot
=cut
==> guestfish --ro -a guest.img -m /dev/VG/LV:/ -m /dev/sda1:/boot
=cut
@@
-905,18
+904,17
@@
if ($output eq "fish" || $output eq "ro-fish") {
my $root_dev = $osdevs[0];
my $root_dev = $osdevs[0];
- print "guestfish";
if ($output eq "ro-fish") {
if ($output eq "ro-fish") {
- print "
--ro
";
+ print "
--ro
";
}
}
- print "
-a $_
" foreach @images;
+ print "
-a $_
" foreach @images;
my $mounts = $oses{$root_dev}->{mounts};
# Have to mount / first. Luckily '/' is early in the ASCII
# character set, so this should be OK.
foreach (sort keys %$mounts) {
my $mounts = $oses{$root_dev}->{mounts};
# Have to mount / first. Luckily '/' is early in the ASCII
# character set, so this should be OK.
foreach (sort keys %$mounts) {
- print "
-m $mounts->{$_}:$_
" if $_ ne "swap";
+ print "
-m $mounts->{$_}:$_
" if $_ ne "swap";
}
print "\n"
}
}
print "\n"
}