summaryrefslogtreecommitdiffstats
path: root/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
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')
-rw-r--r--inspector/example1.xml4
-rw-r--r--inspector/example2.xml12
-rw-r--r--inspector/example3.xml4
-rw-r--r--inspector/example4.xml6
-rw-r--r--inspector/example5.xml4
-rw-r--r--inspector/example6.xml8
-rwxr-xr-xinspector/virt-inspector20
7 files changed, 36 insertions, 22 deletions
diff --git a/inspector/example1.xml b/inspector/example1.xml
index 790e8873..05eecd78 100644
--- a/inspector/example1.xml
+++ b/inspector/example1.xml
@@ -9,7 +9,7 @@
<minor_version>0</minor_version>
<mountpoints>
<mountpoint dev="/dev/vg_f13x64/lv_root">/</mountpoint>
- <mountpoint dev="/dev/vda1">/boot</mountpoint>
+ <mountpoint dev="/dev/sda1">/boot</mountpoint>
</mountpoints>
<filesystems>
<filesystem dev="/dev/vg_f13x64/lv_root">
@@ -17,7 +17,7 @@
<label>Fedora-13-x86_64</label>
<uuid>e6a4db1e-15c2-477b-ac2a-699181c396aa</uuid>
</filesystem>
- <filesystem dev="/dev/vda1">
+ <filesystem dev="/dev/sda1">
<type>ext4</type>
<uuid>59336587-da50-4b87-ad47-577a0fd95498</uuid>
</filesystem>
diff --git a/inspector/example2.xml b/inspector/example2.xml
index 67bcc015..88afa769 100644
--- a/inspector/example2.xml
+++ b/inspector/example2.xml
@@ -1,6 +1,6 @@
<operatingsystems>
<operatingsystem>
- <root>/dev/vda2</root>
+ <root>/dev/sda2</root>
<name>linux</name>
<arch>x86_64</arch>
<distro>rhel</distro>
@@ -8,21 +8,21 @@
<major_version>3</major_version>
<minor_version>9</minor_version>
<mountpoints>
- <mountpoint dev="/dev/vda2">/</mountpoint>
- <mountpoint dev="/dev/vda1">/boot</mountpoint>
+ <mountpoint dev="/dev/sda2">/</mountpoint>
+ <mountpoint dev="/dev/sda1">/boot</mountpoint>
</mountpoints>
<filesystems>
- <filesystem dev="/dev/vda2">
+ <filesystem dev="/dev/sda2">
<type>ext3</type>
<label>/</label>
<uuid>a3dde7db-0e74-4545-9f4b-a0fe7d853702</uuid>
</filesystem>
- <filesystem dev="/dev/vda1">
+ <filesystem dev="/dev/sda1">
<type>ext3</type>
<label>/boot</label>
<uuid>690b600c-201f-4e16-9c11-06e73e248746</uuid>
</filesystem>
- <filesystem dev="/dev/vda3">
+ <filesystem dev="/dev/sda3">
<type>swap</type>
<uuid>c53d3294-9465-456c-a9ee-1b08d270b1b6</uuid>
</filesystem>
diff --git a/inspector/example3.xml b/inspector/example3.xml
index ff012562..82813265 100644
--- a/inspector/example3.xml
+++ b/inspector/example3.xml
@@ -9,14 +9,14 @@
<minor_version>0</minor_version>
<mountpoints>
<mountpoint dev="/dev/vg_rhel6brewx64/lv_root">/</mountpoint>
- <mountpoint dev="/dev/vda1">/boot</mountpoint>
+ <mountpoint dev="/dev/sda1">/boot</mountpoint>
</mountpoints>
<filesystems>
<filesystem dev="/dev/vg_rhel6brewx64/lv_root">
<type>ext4</type>
<uuid>acffb3a7-ace7-4398-8233-d554d4b01174</uuid>
</filesystem>
- <filesystem dev="/dev/vda1">
+ <filesystem dev="/dev/sda1">
<type>ext4</type>
<uuid>1267df04-7310-4f0e-bd53-f4c30ff2fff7</uuid>
</filesystem>
diff --git a/inspector/example4.xml b/inspector/example4.xml
index cc34481a..f517ddd9 100644
--- a/inspector/example4.xml
+++ b/inspector/example4.xml
@@ -1,6 +1,6 @@
<operatingsystems>
<operatingsystem>
- <root>/dev/vda2</root>
+ <root>/dev/sda2</root>
<name>windows</name>
<arch>i386</arch>
<distro>windows</distro>
@@ -9,10 +9,10 @@
<minor_version>1</minor_version>
<windows_systemroot>/Windows</windows_systemroot>
<mountpoints>
- <mountpoint dev="/dev/vda2">/</mountpoint>
+ <mountpoint dev="/dev/sda2">/</mountpoint>
</mountpoints>
<filesystems>
- <filesystem dev="/dev/vda2">
+ <filesystem dev="/dev/sda2">
<type>ntfs</type>
<uuid>F2E8996AE8992E3B</uuid>
</filesystem>
diff --git a/inspector/example5.xml b/inspector/example5.xml
index 3bb982c4..666248e5 100644
--- a/inspector/example5.xml
+++ b/inspector/example5.xml
@@ -13,14 +13,14 @@
<mountpoint dev="/dev/debian5x64.home.annexia.org/var">/var</mountpoint>
<mountpoint dev="/dev/debian5x64.home.annexia.org/tmp">/tmp</mountpoint>
<mountpoint dev="/dev/debian5x64.home.annexia.org/home">/home</mountpoint>
- <mountpoint dev="/dev/vda1">/boot</mountpoint>
+ <mountpoint dev="/dev/sda1">/boot</mountpoint>
</mountpoints>
<filesystems>
<filesystem dev="/dev/debian5x64.home.annexia.org/root">
<type>ext3</type>
<uuid>e15bda18-deca-40d1-beb4-ff31e4068741</uuid>
</filesystem>
- <filesystem dev="/dev/vda1">
+ <filesystem dev="/dev/sda1">
<type>ext2</type>
<uuid>b6590940-dc13-4fc5-b306-7c7bdf075f17</uuid>
</filesystem>
diff --git a/inspector/example6.xml b/inspector/example6.xml
index d213d6ee..52edbcc2 100644
--- a/inspector/example6.xml
+++ b/inspector/example6.xml
@@ -1,6 +1,6 @@
<operatingsystems>
<operatingsystem>
- <root>/dev/vda1</root>
+ <root>/dev/sda1</root>
<name>linux</name>
<arch>x86_64</arch>
<distro>debian</distro>
@@ -8,14 +8,14 @@
<major_version>0</major_version>
<minor_version>0</minor_version>
<mountpoints>
- <mountpoint dev="/dev/vda1">/</mountpoint>
+ <mountpoint dev="/dev/sda1">/</mountpoint>
</mountpoints>
<filesystems>
- <filesystem dev="/dev/vda1">
+ <filesystem dev="/dev/sda1">
<type>ext4</type>
<uuid>09384d4f-df19-479b-85fc-6451e56d41aa</uuid>
</filesystem>
- <filesystem dev="/dev/vda5">
+ <filesystem dev="/dev/sda5">
<type>swap</type>
<uuid>c0d1b68f-c0f9-4497-a366-938b37532613</uuid>
</filesystem>
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