# HG changeset patch
# User Stefano Stabellini <sstabellini@xxxxxxxxxxxxx>
# Date 1279538441 -3600
# Node ID 3e5baecab949193a297ac51e337db21d8449817d
# Parent 91ce0b0953ca684cc11beceda6adcf5cdef7b1b3
Implement "xl tmem-freeable" to match "xm tmem-freeable".
Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
---
tools/libxl/libxl.c | 14 ++++++++++++++
tools/libxl/libxl.h | 1 +
tools/libxl/xl.h | 1 +
tools/libxl/xl_cmdimpl.c | 23 +++++++++++++++++++++++
tools/libxl/xl_cmdtable.c | 5 +++++
5 files changed, 44 insertions(+)
diff -r 91ce0b0953ca -r 3e5baecab949 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Fri Jul 16 12:10:56 2010 +0100
+++ b/tools/libxl/libxl.c Mon Jul 19 12:20:41 2010 +0100
@@ -3232,6 +3232,20 @@ int libxl_tmem_shared_auth(struct libxl_
return rc;
}
+int libxl_tmem_freeable(struct libxl_ctx *ctx)
+{
+ int rc;
+
+ rc = xc_tmem_control(ctx->xch, -1, TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0,
0);
+ if (rc < 0) {
+ XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
+ "Can not get tmem freeable memory");
+ return -1;
+ }
+
+ return rc;
+}
+
int libxl_file_reference_map(struct libxl_ctx *ctx, libxl_file_reference *f)
{
struct stat st_buf;
diff -r 91ce0b0953ca -r 3e5baecab949 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Fri Jul 16 12:10:56 2010 +0100
+++ b/tools/libxl/libxl.h Mon Jul 19 12:20:41 2010 +0100
@@ -602,6 +602,7 @@ int libxl_tmem_set(struct libxl_ctx *ctx
uint32_t set);
int libxl_tmem_shared_auth(struct libxl_ctx *ctx, uint32_t domid, char* uuid,
int auth);
+int libxl_tmem_freeable(struct libxl_ctx *ctx);
typedef struct {
char *backend;
diff -r 91ce0b0953ca -r 3e5baecab949 tools/libxl/xl.h
--- a/tools/libxl/xl.h Fri Jul 16 12:10:56 2010 +0100
+++ b/tools/libxl/xl.h Mon Jul 19 12:20:41 2010 +0100
@@ -72,6 +72,7 @@ int main_tmem_thaw(int argc, char **argv
int main_tmem_thaw(int argc, char **argv);
int main_tmem_set(int argc, char **argv);
int main_tmem_shared_auth(int argc, char **argv);
+int main_tmem_freeable(int argc, char **argv);
int main_network2attach(int argc, char **argv);
int main_network2list(int argc, char **argv);
int main_network2detach(int argc, char **argv);
diff -r 91ce0b0953ca -r 3e5baecab949 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Fri Jul 16 12:10:56 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c Mon Jul 19 12:20:41 2010 +0100
@@ -4586,3 +4586,26 @@ int main_tmem_shared_auth(int argc, char
exit(0);
}
+int main_tmem_freeable(int argc, char **argv)
+{
+ int opt;
+ int mb;
+
+ while ((opt = getopt(argc, argv, "h")) != -1) {
+ switch (opt) {
+ case 'h':
+ help("tmem-freeable");
+ exit(0);
+ default:
+ fprintf(stderr, "option `%c' not supported.\n", opt);
+ break;
+ }
+ }
+
+ mb = libxl_tmem_freeable(&ctx);
+ if (mb == -1)
+ exit(-1);
+
+ printf("%d\n", mb);
+ exit(0);
+}
diff -r 91ce0b0953ca -r 3e5baecab949 tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Fri Jul 16 12:10:56 2010 +0100
+++ b/tools/libxl/xl_cmdtable.c Mon Jul 19 12:20:41 2010 +0100
@@ -295,6 +295,11 @@ struct cmd_spec cmd_table[] = {
"
(abcdef01-2345-6789-1234-567890abcdef)\n"
" -A AUTH 0=auth,1=deauth",
},
+ { "tmem-freeable",
+ &main_tmem_freeable,
+ "Get information about how much freeable memory (MB) is in-use by tmem",
+ "",
+ },
{ "network2-attach",
&main_network2attach,
"Create a new version 2 virtual network device",
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|