Coverity: Check return value of sysroot_path.
[libguestfs.git] / inspector / virt-inspector.c
index 7724be6..607e5ae 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <inttypes.h>
 #include <unistd.h>
 #include <getopt.h>
 #include <locale.h>
 #include <assert.h>
+#include <libintl.h>
 
 #include <libxml/xmlIO.h>
 #include <libxml/xmlwriter.h>
@@ -426,6 +428,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);
+
   str = guestfs_inspect_get_format (g, root);
   if (!str) exit (EXIT_FAILURE);
   if (STRNEQ (str, "unknown"))