support topolgy info in xl info
authorJuergen Gross <juergen.gross@ts.fujitsu.com>
Thu, 9 Dec 2010 10:23:20 +0000 (11:23 +0100)
committerJuergen Gross <juergen.gross@ts.fujitsu.com>
Thu, 9 Dec 2010 10:23:20 +0000 (11:23 +0100)
Adds option -n/--numa to xl info command to print topology information.
No numa information up to now, as I've no machine which will give this info
via xm info (could be a bug in xm, however).

Signed-off-by: juergen.gross@ts.fujitsu.com
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_cmdtable.c

index 33a54033b1d93e35b741354f67599b54a699dec9..55970aeb2a70ac08bce4757152a8d456a796cfe1 100644 (file)
@@ -3935,12 +3935,41 @@ static void output_physinfo(void)
     return;
 }
 
-static void info(void)
+static void output_topologyinfo(void)
+{
+    libxl_topologyinfo info;
+    int i;
+
+    if (libxl_get_topologyinfo(&ctx, &info)) {
+        fprintf(stderr, "libxl_get_topologyinfo failed.\n");
+        return;
+    }
+
+    printf("cpu_topology           :\n");
+    printf("cpu:    core    socket     node\n");
+
+    for (i = 0; i < info.coremap.entries; i++) {
+        if (info.coremap.array[i] != LIBXL_CPUARRAY_INVALID_ENTRY)
+            printf("%3d:    %4d     %4d     %4d\n", i, info.coremap.array[i],
+                info.socketmap.array[i], info.nodemap.array[i]);
+    }
+
+    printf("numa_info              : none\n");
+
+    libxl_topologyinfo_destroy(&info);
+
+    return;
+}
+
+static void info(int numa)
 {
     output_nodeinfo();
 
     output_physinfo();
 
+    if (numa)
+        output_topologyinfo();
+
     output_xeninfo();
 
     printf("xend_config_format     : 4\n");
@@ -3951,19 +3980,29 @@ static void info(void)
 int main_info(int argc, char **argv)
 {
     int opt;
+    int option_index = 0;
+    static struct option long_options[] = {
+        {"help", 0, 0, 'h'},
+        {"numa", 0, 0, 'n'},
+        {0, 0, 0, 0}
+    };
+    int numa = 0;
 
-    while ((opt = getopt(argc, argv, "h")) != -1) {
+    while ((opt = getopt_long(argc, argv, "hn", long_options, &option_index)) != -1) {
         switch (opt) {
         case 'h':
             help("info");
             return 0;
+        case 'n':
+            numa = 1;
+            break;
         default:
             fprintf(stderr, "option `%c' not supported.\n", opt);
             break;
         }
     }
 
-    info();
+    info(numa);
     return 0;
 }
 
index 285c84a41d6f081da0d1a22a7e29a21c999ca722..149bce978f7bf3be9728f411021ebeb2c532e20b 100644 (file)
@@ -185,7 +185,7 @@ struct cmd_spec cmd_table[] = {
     { "info",
       &main_info,
       "Get information about Xen host",
-      "",
+      "-n, --numa         List host NUMA topology information",
     },
     { "sched-credit",
       &main_sched_credit,