[Libvirt-cim] [PATCH 3 of 5] Make xml_parse_test capable of printing the generated XML for a domain

Dan Smith danms at us.ibm.com
Fri Jan 4 19:55:35 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1199480010 28800
# Node ID 6cd4300ae6a3509caec3a5076a6ccc498f06abcc
# Parent  c16905cea2137a9fb6275883550e08e1f83f2cc1
Make xml_parse_test capable of printing the generated XML for a domain

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r c16905cea213 -r 6cd4300ae6a3 libxkutil/xml_parse_test.c
--- a/libxkutil/xml_parse_test.c	Fri Jan 04 12:53:30 2008 -0800
+++ b/libxkutil/xml_parse_test.c	Fri Jan 04 12:53:30 2008 -0800
@@ -3,6 +3,7 @@
 #include <libvirt/libvirt.h>
 
 #include "device_parsing.h"
+#include "xmlgen.h"
 
 static void print_value(FILE *d, const char *name, const char *val)
 {
@@ -130,6 +131,18 @@ static void print_devices(struct domain 
         }
 }
 
+static void print_domxml(struct domain *dominfo,
+                         FILE *d)
+{
+        char *xml;
+
+        xml = system_to_xml(dominfo);
+        if (xml == NULL)
+                printf("Failed to create system XML\n");
+        else
+                printf("%s\n", xml);
+}
+
 int main(int argc, char **argv)
 {
         virConnectPtr conn;
@@ -137,7 +150,7 @@ int main(int argc, char **argv)
         struct domain *dominfo;
 
         if (argc < 2) {
-                printf("Usage: %s domain\n", argv[0]);
+                printf("Usage: %s domain [URI] [xml]\n", argv[0]);
                 return 1;
         }
 
@@ -163,8 +176,12 @@ int main(int argc, char **argv)
 
         printf("Parsed domain info\n");
 
-        print_dominfo(dominfo, stdout);
-        print_devices(dominfo, stdout);
+        if ((argc > 3) && (argv[3][0] == 'x'))
+                print_domxml(dominfo, stdout);
+        else {
+                print_dominfo(dominfo, stdout);
+                print_devices(dominfo, stdout);
+        }
 
         return 0;
 }




More information about the Libvirt-cim mailing list