summaryrefslogtreecommitdiffstats
path: root/inspector/virt-inspector
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-10-28 22:29:43 +0100
committerRichard W.M. Jones <rjones@redhat.com>2010-10-28 22:30:55 +0100
commit237627df37b97c18362755f646bbe1c4b05ee692 (patch)
tree54194b3fcf5d170eae442a2dfb7392ce230bb277 /inspector/virt-inspector
parent4c5ca903b52ccc785a3d879da8506be248b0d6f7 (diff)
downloadlibguestfs-237627df37b97c18362755f646bbe1c4b05ee692.tar.gz
libguestfs-237627df37b97c18362755f646bbe1c4b05ee692.tar.xz
libguestfs-237627df37b97c18362755f646bbe1c4b05ee692.zip
inspector: Return canonical block device paths in XML.
Diffstat (limited to 'inspector/virt-inspector')
-rwxr-xr-xinspector/virt-inspector20
1 files changed, 17 insertions, 3 deletions
diff --git a/inspector/virt-inspector b/inspector/virt-inspector
index 24501fb3..a53c76a9 100755
--- a/inspector/virt-inspector
+++ b/inspector/virt-inspector
@@ -162,7 +162,7 @@ foreach $root (@roots) {
$xml->startTag ("operatingsystem");
# Basic OS fields.
- $xml->dataElement (root => $root);
+ $xml->dataElement (root => canonicalize ($root));
my ($s, $distro, $major_version);
$s = $g->inspect_get_type ($root);
@@ -210,7 +210,8 @@ sub output_mountpoints
$xml->startTag ("mountpoints");
foreach (@$fskeys) {
- $xml->dataElement ("mountpoint", $_, dev => $fshash->{$_});
+ $xml->dataElement ("mountpoint", $_,
+ dev => canonicalize ($fshash->{$_}));
}
$xml->endTag ("mountpoints");
}
@@ -224,7 +225,8 @@ sub output_filesystems
my @fses = $g->inspect_get_filesystems ($root);
foreach (@fses) {
- $xml->startTag ("filesystem", dev => $_);
+ $xml->startTag ("filesystem",
+ dev => canonicalize ($_));
eval {
my $type = $g->vfs_type ($_);
@@ -347,6 +349,18 @@ sub output_applications_rpm
}
}
+# The reverse of device name translation, see
+# BLOCK DEVICE NAMING in guestfs(3).
+sub canonicalize
+{
+ local $_ = shift;
+
+ if (m{^/dev/[hv]d([a-z]\d)$}) {
+ return "/dev/sd$1";
+ }
+ $_;
+}
+
=head1 SHELL QUOTING
Libvirt guest names can contain arbitrary characters, some of which