Add 'xl tmem-list' command
Signed-off-by: Yang Hongyang<yanghy@xxxxxxxxxxxxxx>
diff -r baccadfd9418 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/libxl.c Wed May 19 23:25:29 2010 +0800
@@ -2825,3 +2825,18 @@
return strtoul(start_time, NULL, 10);
}
+char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long)
+{
+ int rc;
+ char _buf[32768];
+
+ rc = xc_tmem_control(ctx->xch, -1, TMEMC_LIST, domid, 32768, use_long,
+ 0, _buf);
+ if (rc < 0) {
+ XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ "Can not get tmem list");
+ return NULL;
+ }
+
+ return strdup(_buf);
+}
diff -r baccadfd9418 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/libxl.h Wed May 19 23:25:29 2010 +0800
@@ -513,5 +513,7 @@
int libxl_send_sysrq(struct libxl_ctx *ctx, uint32_t domid, char sysrq);
uint32_t libxl_vm_get_start_time(struct libxl_ctx *ctx, uint32_t domid);
+char *libxl_tmem_list(struct libxl_ctx *ctx, uint32_t domid, int use_long);
+
#endif /* LIBXL_H */
diff -r baccadfd9418 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed May 19 23:25:29 2010 +0800
@@ -3667,3 +3667,49 @@
exit(0);
}
+
+int main_tmem_list(int argc, char **argv)
+{
+ char *dom = NULL;
+ char *buf = NULL;
+ int use_long = 0;
+ int all = 0;
+ int opt;
+
+ while ((opt = getopt(argc, argv, "alh")) != -1) {
+ switch (opt) {
+ case 'l':
+ use_long = 1;
+ break;
+ case 'a':
+ all = 1;
+ break;
+ case 'h':
+ help("tmem-list");
+ exit(0);
+ default:
+ fprintf(stderr, "option `%c' not supported.\n", opt);
+ break;
+ }
+ }
+
+ dom = argv[optind];
+ if (!dom && all == 0) {
+ fprintf(stderr, "You must specify -a or a domain id.\n\n");
+ help("tmem-list");
+ exit(1);
+ }
+
+ if (all)
+ domid = -1;
+ else
+ find_domain(dom);
+
+ buf = libxl_tmem_list(&ctx, domid, use_long);
+ if (buf == NULL)
+ exit(-1);
+
+ printf("%s\n", buf);
+ free(buf);
+ exit(0);
+}
diff -r baccadfd9418 tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.h Wed May 19 23:25:29 2010 +0800
@@ -52,6 +52,7 @@
int main_blocklist(int argc, char **argv);
int main_blockdetach(int argc, char **argv);
int main_uptime(int argc, char **argv);
+int main_tmem_list(int argc, char **argv);
void help(char *command);
diff -r baccadfd9418 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Wed May 19 23:25:29 2010 +0800
@@ -224,6 +224,12 @@
"Print uptime for all/some domains",
"[-s] [Domain]",
},
+ { "tmem-list",
+ &main_tmem_list,
+ "List tmem pools",
+ "[-l] [<Domain>|-a]",
+ " -l List tmem stats",
+ },
};
int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
--
Regards
Yang Hongyang
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|