inspector: Include <hostname> in output.
authorRichard W.M. Jones <rjones@redhat.com>
Thu, 14 Apr 2011 16:58:51 +0000 (17:58 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 18 Apr 2011 21:21:16 +0000 (22:21 +0100)
Cherry picked from commit 36d3a4ce53317b104d48b60c9fe1ed679065d1d4
and rebased for stable-1.8 branch.

inspector/example-debian.xml
inspector/example-fedora.xml
inspector/example-ubuntu.xml
inspector/example-windows.xml
inspector/virt-inspector.c
inspector/virt-inspector.rng

index cead573..089df4e 100644 (file)
@@ -10,6 +10,7 @@
     <minor_version>0</minor_version>
     <package_format>deb</package_format>
     <package_management>apt</package_management>
+    <hostname>debian.invalid</hostname>
     <mountpoints>
       <mountpoint dev="/dev/debian/root">/</mountpoint>
       <mountpoint dev="/dev/debian/usr">/usr</mountpoint>
index 6e03a12..73769f8 100644 (file)
@@ -10,6 +10,7 @@
     <minor_version>0</minor_version>
     <package_format>rpm</package_format>
     <package_management>yum</package_management>
+    <hostname>fedora.invalid</hostname>
     <mountpoints>
       <mountpoint dev="/dev/VG/Root">/</mountpoint>
       <mountpoint dev="/dev/sda1">/boot</mountpoint>
index 61338e1..572ffb5 100644 (file)
@@ -10,6 +10,7 @@
     <minor_version>10</minor_version>
     <package_format>deb</package_format>
     <package_management>apt</package_management>
+    <hostname>ubuntu.invalid</hostname>
     <mountpoints>
       <mountpoint dev="/dev/sda2">/</mountpoint>
       <mountpoint dev="/dev/sda1">/boot</mountpoint>
index 346b2ed..67d099a 100644 (file)
@@ -9,6 +9,7 @@
     <major_version>6</major_version>
     <minor_version>1</minor_version>
     <windows_systemroot>/Windows</windows_systemroot>
+    <hostname>windows.invalid</hostname>
     <mountpoints>
       <mountpoint dev="/dev/sda2">/</mountpoint>
     </mountpoints>
index 4d2824c..2e3449e 100644 (file)
@@ -408,6 +408,14 @@ output_root (xmlTextWriterPtr xo, char *root)
     free (str);
   );
 
+  str = guestfs_inspect_get_hostname (g, root);
+  if (!str) exit (EXIT_FAILURE);
+  if (STRNEQ (str, "unknown"))
+    XMLERROR (-1,
+      xmlTextWriterWriteElement (xo, BAD_CAST "hostname",
+                                 BAD_CAST str));
+  free (str);
+
   output_mountpoints (xo, root);
 
   output_filesystems (xo, root);
index 10aa6db..d35e752 100644 (file)
@@ -39,6 +39,7 @@
 
             <optional><element name="package_format"><text/></element></optional>
             <optional><element name="package_management"><text/></element></optional>
+            <optional><element name="hostname"><text/></element></optional>
 
             <ref name="mountpoints"/>
             <ref name="filesystems"/>