diff options
Diffstat (limited to 'inspector/virt-inspector')
-rwxr-xr-x | inspector/virt-inspector | 20 |
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 |