[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4 of 8] Tools: Add a sharing command to xl for information about shared pages
docs/man/xl.pod.1 | 18 +++++++++ tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 6 +++ 4 files changed, 110 insertions(+), 0 deletions(-) Signed-off-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx> Signed-off-by: Adin Scannell <adin@xxxxxxxxxxx> diff -r e16f5d2643c9 -r a22140d92931 docs/man/xl.pod.1 --- a/docs/man/xl.pod.1 +++ b/docs/man/xl.pod.1 @@ -280,6 +280,24 @@ B<Warning:> There is no good way to know mem-set will make a domain unstable and cause it to crash. Be very careful when using this command on running domains. +=item B<sharing> [I<-t> I<--totals>] [I<domain-id>] + +List count of shared pages. + +B<OPTIONS> + +=over 4 + +=item I<domain_id> + +List specifically for that domain. Otherwise, list for all domains. + +=item I<-t>, I<--totals> + +Also print global count of shared pages for this host. + +=back + =item B<migrate> [I<OPTIONS>] I<domain-id> I<host> Migrate a domain to another host machine. By default B<xl> relies on ssh as a diff -r e16f5d2643c9 -r a22140d92931 tools/libxl/xl.h --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -28,6 +28,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_cd_eject(int argc, char **argv); int main_cd_insert(int argc, char **argv); int main_console(int argc, char **argv); diff -r e16f5d2643c9 -r a22140d92931 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3755,6 +3755,91 @@ int main_info(int argc, char **argv) return 0; } +static void sharing(int totals, const libxl_dominfo *info, int nb_domain) +{ + int i; + + printf("Name ID Mem Shared\n"); + + for (i = 0; i < nb_domain; i++) { + char *domname; + unsigned shutdown_reason; + domname = libxl_domid_to_name(ctx, info[i].domid); + shutdown_reason = info[i].shutdown ? info[i].shutdown_reason : 0; + printf("%-40s %5d %5lu %5lu\n", + domname, + info[i].domid, + (unsigned long) (info[i].current_memkb / 1024), + (unsigned long) (info[i].shared_memkb / 1024)); + free(domname); + } + + if (totals) + { + /* To be added with a future patch. */ + } +} + +int main_sharing(int argc, char **argv) +{ + int opt; + int option_index = 0; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"totals", 0, 0, 't'}, + {0, 0, 0, 0} + }; + int totals = 0; + + libxl_dominfo info_buf; + libxl_dominfo *info, *info_free=0; + int nb_domain, rc; + + while ((opt = getopt_long(argc, argv, "ht", long_options, &option_index)) != -1) { + switch (opt) { + case 'h': + help("sharing"); + return 0; + case 't': + totals = 1; + break; + default: + fprintf(stderr, "option `%c' not supported.\n", optopt); + break; + } + } + + if (optind >= argc) { + info = libxl_list_domain(ctx, &nb_domain); + if (!info) { + fprintf(stderr, "libxl_domain_infolist failed.\n"); + return 1; + } + info_free = info; + } else if (optind == argc-1) { + find_domain(argv[optind]); + rc = libxl_domain_info(ctx, &info_buf, domid); + if (rc == ERROR_INVAL) { + fprintf(stderr, "Error: Domain \'%s\' does not exist.\n", + argv[optind]); + return -rc; + } + if (rc) { + fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc); + return -rc; + } + info = &info_buf; + nb_domain = 1; + } else { + help("sharing"); + return 2; + } + + sharing(totals, info, nb_domain); + + return 0; +} + static int sched_credit_domain_get( int domid, libxl_sched_credit *scinfo) { diff -r e16f5d2643c9 -r a22140d92931 tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -189,6 +189,12 @@ struct cmd_spec cmd_table[] = { "Get information about Xen host", "-n, --numa List host NUMA topology information", }, + { "sharing", + &main_sharing, 0, + "Get information about page sharing", + "[options] [Domain]", + "-t, --totals Include host totals in the output", + }, { "sched-credit", &main_sched_credit, 0, "Get/set credit scheduler parameters", _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |