|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 3/4] xl: Expose CPU status map with 'xl info -m'
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
tools/xl/xl_cmdtable.c | 4 +++-
tools/xl/xl_info.c | 46 ++++++++++++++++++++++++++++++++++++++----
2 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 502244f683..68caafd5bd 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -261,7 +261,9 @@ const struct cmd_spec cmd_table[] = {
{ "info",
&main_info, 0, 0,
"Get information about Xen host",
- "-n, --numa List host NUMA topology information",
+ "[options]",
+ "-n, --numa List host NUMA topology information\n"
+ "-m, --map Show CPU status map"
},
{ "sharing",
&main_sharing, 0, 0,
diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c
index 98fc879e63..bed8996c9b 100644
--- a/tools/xl/xl_info.c
+++ b/tools/xl/xl_info.c
@@ -420,7 +420,39 @@ static void output_xenstore_info(void)
xs_close(xsh);
}
-static void print_info(int numa, bool xs)
+static void output_cpumap(void)
+{
+ int nr, i;
+
+ libxl_cpu_status_map *cpu_status_map = libxl_get_cpu_status_map(ctx, &nr);
+ if (!cpu_status_map) {
+ fprintf(stderr, "libxl_get_cpu_status_map failed.\n");
+ return;
+ }
+
+ printf("CPU statuses\n");
+
+ for (i = 0; i < nr; i++) {
+ const char *status = "None";
+ bool online = libxl_bitmap_test(&cpu_status_map->cpu_online_map, i);
+ bool present = libxl_bitmap_test(&cpu_status_map->cpu_present_map, i);
+ bool possible = libxl_bitmap_test(&cpu_status_map->cpu_possible_map,
i);
+
+ if (online)
+ status = "Online";
+ else if (present)
+ status = "Offline (Present)";
+ else if (possible)
+ status = "Offline (Possible)";
+
+ printf(" %d: %s\n", i, status);
+ }
+
+ libxl_cpu_status_map_dispose(cpu_status_map);
+ free(cpu_status_map);
+}
+
+static void print_info(int numa, bool xs, bool cpu_map)
{
output_nodeinfo();
@@ -430,6 +462,8 @@ static void print_info(int numa, bool xs)
output_topologyinfo();
output_numainfo();
}
+ if (cpu_map)
+ output_cpumap();
output_xeninfo();
if (xs)
@@ -732,18 +766,22 @@ int main_info(int argc, char **argv)
static struct option opts[] = {
{"numa", 0, 0, 'n'},
{"xenstore", 0, 0, 'x'},
+ {"map", 0, 0, 'm'},
COMMON_LONG_OPTS
};
int numa = 0;
- bool xs = false;
+ bool xs = false, cpu_map = false;
- SWITCH_FOREACH_OPT(opt, "nx", opts, "info", 0) {
+ SWITCH_FOREACH_OPT(opt, "nxm", opts, "info", 0) {
case 'n':
numa = 1;
break;
case 'x':
xs = true;
break;
+ case 'm':
+ cpu_map = true;
+ break;
}
/*
@@ -753,7 +791,7 @@ int main_info(int argc, char **argv)
if (numa == 0 && argc > optind)
info_name = argv[optind];
- print_info(numa, xs);
+ print_info(numa, xs, cpu_map);
return 0;
}
--
2.55.0
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |