aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>2012-01-26 12:46:26 +0000
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>2012-01-26 12:46:26 +0000
commit8a93efd7f06b7ce89b295d6ab4565bd964b71c51 (patch)
tree8d0adaa22da68871e2225fccd3b54e8e143efb90 /tools
parentb3690b8c5809d093b20b04e5f016471509dd9191 (diff)
downloadxen-8a93efd7f06b7ce89b295d6ab4565bd964b71c51.tar.gz
xen-8a93efd7f06b7ce89b295d6ab4565bd964b71c51.tar.bz2
xen-8a93efd7f06b7ce89b295d6ab4565bd964b71c51.zip
Tools: Add a sharing command to xl for information about shared pages
Also add the global sharing statistics to the libxl physinfo. This is a slight departure from libxc, but there's no reason libxl physinfo can't include extra bits of useful and relevant information. Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Signed-off-by: Adin Scannell <adin@scannell.ca> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Tim Deegan <tim@xen.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/libxl/libxl.c2
-rw-r--r--tools/libxl/libxl_types.idl2
-rw-r--r--tools/libxl/xl.h1
-rw-r--r--tools/libxl/xl_cmdimpl.c66
-rw-r--r--tools/libxl/xl_cmdtable.c5
5 files changed, 76 insertions, 0 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 169fc97781..5dd7412ca7 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -2507,6 +2507,8 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
physinfo->total_pages = xcphysinfo.total_pages;
physinfo->free_pages = xcphysinfo.free_pages;
physinfo->scrub_pages = xcphysinfo.scrub_pages;
+ physinfo->sharing_freed_pages = xc_sharing_freed_pages(ctx->xch);
+ physinfo->sharing_used_frames = xc_sharing_used_frames(ctx->xch);
physinfo->nr_nodes = xcphysinfo.nr_nodes;
memcpy(physinfo->hw_cap,xcphysinfo.hw_cap, sizeof(physinfo->hw_cap));
physinfo->phys_cap = xcphysinfo.capabilities;
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 574dec752a..d69b043820 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -367,6 +367,8 @@ libxl_physinfo = Struct("physinfo", [
("total_pages", uint64),
("free_pages", uint64),
("scrub_pages", uint64),
+ ("sharing_freed_pages", uint64),
+ ("sharing_used_frames", uint64),
("nr_nodes", uint32),
("hw_cap", libxl_hwcap),
diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h
index cc7dd1c95f..6c30765c7a 100644
--- 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 --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 7dbd8125a6..16fc5bf9b7 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3701,6 +3701,8 @@ static void output_physinfo(void)
i = (1 << 20) / vinfo->pagesize;
printf("total_memory : %"PRIu64"\n", info.total_pages / i);
printf("free_memory : %"PRIu64"\n", info.free_pages / i);
+ printf("sharing_freed_memory : %"PRIu64"\n", info.sharing_freed_pages / i);
+ printf("sharing_used_memory : %"PRIu64"\n", info.sharing_used_frames / i);
}
if (!libxl_get_freecpus(ctx, &cpumap)) {
libxl_for_each_cpu(i, cpumap)
@@ -3784,6 +3786,70 @@ int main_info(int argc, char **argv)
return 0;
}
+static void sharing(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);
+ }
+}
+
+int main_sharing(int argc, char **argv)
+{
+ int opt = 0;
+ libxl_dominfo info_buf;
+ libxl_dominfo *info, *info_free = NULL;
+ int nb_domain, rc;
+
+ if ((opt = def_getopt(argc, argv, "", "sharing", 0)) != -1)
+ return opt;
+
+ 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(info, nb_domain);
+
+ if (info_free)
+ free(info_free);
+
+ return 0;
+}
+
static int sched_credit_domain_get(
int domid, libxl_sched_credit *scinfo)
{
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
index 3f7008b02b..018d1dde42 100644
--- a/tools/libxl/xl_cmdtable.c
+++ b/tools/libxl/xl_cmdtable.c
@@ -189,6 +189,11 @@ 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",
+ "[Domain]",
+ },
{ "sched-credit",
&main_sched_credit, 0,
"Get/set credit scheduler parameters",