edit: Move 'exit 0' to end of file.
[libguestfs.git] / inspector / virt-inspector.c
index d3e00a9..4d8e3ad 100644 (file)
@@ -1,5 +1,5 @@
 /* virt-inspector
- * Copyright (C) 2010 Red Hat Inc.
+ * Copyright (C) 2010-2011 Red Hat Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
 #include <inttypes.h>
 #include <unistd.h>
 #include <getopt.h>
+#include <locale.h>
 #include <assert.h>
 
 #include <libxml/xmlIO.h>
@@ -38,6 +39,7 @@
 guestfs_h *g;
 
 int read_only = 1;
+int live = 0;
 int verbose = 0;
 int keys_from_stdin = 0;
 int echo_keys = 0;
@@ -226,6 +228,7 @@ main (int argc, char *argv[])
    */
   assert (read_only == 1);
   assert (inspector == 1);
+  assert (live == 0);
 
   /* Must be no extra arguments on the command line. */
   if (optind != argc)
@@ -331,7 +334,7 @@ static void
 output_root (xmlTextWriterPtr xo, char *root)
 {
   char *str;
-  int i;
+  int i, r;
   char buf[32];
   char canonical_root[strlen (root) + 1];
 
@@ -370,6 +373,13 @@ output_root (xmlTextWriterPtr xo, char *root)
       xmlTextWriterWriteElement (xo, BAD_CAST "product_name", BAD_CAST str));
   free (str);
 
+  str = guestfs_inspect_get_product_variant (g, root);
+  if (!str) exit (EXIT_FAILURE);
+  if (STRNEQ (str, "unknown"))
+    XMLERROR (-1,
+      xmlTextWriterWriteElement (xo, BAD_CAST "product_variant", BAD_CAST str));
+  free (str);
+
   i = guestfs_inspect_get_major_version (g, root);
   snprintf (buf, sizeof buf, "%d", i);
   XMLERROR (-1,
@@ -407,6 +417,35 @@ output_root (xmlTextWriterPtr xo, char *root)
     free (str);
   );
 
+  str = guestfs_inspect_get_format (g, root);
+  if (!str) exit (EXIT_FAILURE);
+  if (STRNEQ (str, "unknown"))
+    XMLERROR (-1,
+      xmlTextWriterWriteElement (xo, BAD_CAST "format",
+                                 BAD_CAST str));
+  free (str);
+
+  r = guestfs_inspect_is_live (g, root);
+  if (r > 0) {
+    XMLERROR (-1,
+              xmlTextWriterStartElement (xo, BAD_CAST "live"));
+    XMLERROR (-1, xmlTextWriterEndElement (xo));
+  }
+
+  r = guestfs_inspect_is_netinst (g, root);
+  if (r > 0) {
+    XMLERROR (-1,
+              xmlTextWriterStartElement (xo, BAD_CAST "netinst"));
+    XMLERROR (-1, xmlTextWriterEndElement (xo));
+  }
+
+  r = guestfs_inspect_is_multipart (g, root);
+  if (r > 0) {
+    XMLERROR (-1,
+              xmlTextWriterStartElement (xo, BAD_CAST "multipart"));
+    XMLERROR (-1, xmlTextWriterEndElement (xo));
+  }
+
   output_mountpoints (xo, root);
 
   output_filesystems (xo, root);