[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/4] xl: report how much memory a domain has on each NUMA node
by introducing a new subcommant: `xl numainfo <domain>'. Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx> --- tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 5 ++++ 3 files changed, 64 insertions(+) diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h index f188708..f519242 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -33,6 +33,7 @@ struct cmd_spec { int main_vcpulist(int argc, char **argv); int main_info(int argc, char **argv); int main_sharing(int argc, char **argv); +int main_numainfo(int argc, char **argv); int main_cd_eject(int argc, char **argv); int main_cd_insert(int argc, char **argv); int main_console(int argc, char **argv); diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 4fc46eb..07a3504 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -4721,6 +4721,64 @@ int main_vcpupin(int argc, char **argv) return vcpupin(find_domain(argv[optind]), argv[optind+1] , argv[optind+2]); } +static void print_domain_numainfo(uint32_t domid) +{ + libxl_domain_numainfo *info; + libxl_bitmap nodemap; + libxl_physinfo physinfo; + int i; + + libxl_bitmap_init(&nodemap); + libxl_physinfo_init(&physinfo); + + if (libxl_node_bitmap_alloc(ctx, &nodemap, 0)) { + fprintf(stderr, "libxl_node_bitmap_alloc_failed.\n"); + goto out; + } + if (libxl_get_physinfo(ctx, &physinfo) != 0) { + fprintf(stderr, "libxl_physinfo failed.\n"); + goto out; + } + + if (libxl_domain_get_nodeaffinity(ctx, domid, &nodemap)) { + fprintf(stderr, "libxl_domain_get_nodeaffinity failed.\n"); + goto out; + } + printf("NODE Affinity: "); + print_bitmap(nodemap.map, physinfo.nr_nodes, stdout); + printf("\n"); + + info = libxl_domain_get_numainfo(ctx, domid); + if (!info) { + fprintf(stderr, "libxl_domain_get_numainfo failed.\n"); + goto out; + } + printf("Memory:\n"); + for (i = 0; i < info->num_memkbs; i++) { + if (info->memkbs[i]) + printf(" Node %d: %"PRIu64" Kb\n", i, info->memkbs[i]); + } + + out: + libxl_bitmap_dispose(&nodemap); + libxl_physinfo_dispose(&physinfo); +} + +int main_numainfo(int argc, char **argv) +{ + uint32_t domid; + int opt = 0; + + SWITCH_FOREACH_OPT(opt, "", NULL, "numainfo", 1) { + /* No options */ + } + + domid = find_domain(argv[optind]); + print_domain_numainfo(domid); + + return 0; +} + static void vcpuset(uint32_t domid, const char* nr_vcpus, int check_host) { char *endptr; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index e8ab93a..4b040dd 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -201,6 +201,11 @@ struct cmd_spec cmd_table[] = { "Set the current memory usage for a domain", "<Domain> <MemMB['b'[bytes]|'k'[KB]|'m'[MB]|'g'[GB]|'t'[TB]]>", }, + { "numainfo", + &main_numainfo, 0, 0, + "Print NUMA related information for a domain", + "<Domain>", + }, { "button-press", &main_button_press, 0, 1, "Indicate an ACPI button press to the domain", _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |