debuggers.hg

changeset 21863:3e5baecab949

Implement "xl tmem-freeable" to match "xm tmem-freeable".

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
author Stefano Stabellini <sstabellini@xensource.com>
date Mon Jul 19 12:20:41 2010 +0100 (2010-07-19)
parents 91ce0b0953ca
children 9ccd024065c5
files tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/xl.h tools/libxl/xl_cmdimpl.c tools/libxl/xl_cmdtable.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Fri Jul 16 12:10:56 2010 +0100
     1.2 +++ b/tools/libxl/libxl.c	Mon Jul 19 12:20:41 2010 +0100
     1.3 @@ -3232,6 +3232,20 @@ int libxl_tmem_shared_auth(struct libxl_
     1.4      return rc;
     1.5  }
     1.6  
     1.7 +int libxl_tmem_freeable(struct libxl_ctx *ctx)
     1.8 +{
     1.9 +    int rc;
    1.10 +
    1.11 +    rc = xc_tmem_control(ctx->xch, -1, TMEMC_QUERY_FREEABLE_MB, -1, 0, 0, 0, 0);
    1.12 +    if (rc < 0) {
    1.13 +        XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, rc,
    1.14 +            "Can not get tmem freeable memory");
    1.15 +        return -1;
    1.16 +    }
    1.17 +
    1.18 +    return rc;
    1.19 +}
    1.20 +
    1.21  int libxl_file_reference_map(struct libxl_ctx *ctx, libxl_file_reference *f)
    1.22  {
    1.23  	struct stat st_buf;
     2.1 --- a/tools/libxl/libxl.h	Fri Jul 16 12:10:56 2010 +0100
     2.2 +++ b/tools/libxl/libxl.h	Mon Jul 19 12:20:41 2010 +0100
     2.3 @@ -602,6 +602,7 @@ int libxl_tmem_set(struct libxl_ctx *ctx
     2.4                     uint32_t set);
     2.5  int libxl_tmem_shared_auth(struct libxl_ctx *ctx, uint32_t domid, char* uuid,
     2.6                             int auth);
     2.7 +int libxl_tmem_freeable(struct libxl_ctx *ctx);
     2.8  
     2.9  typedef struct {
    2.10      char *backend;
     3.1 --- a/tools/libxl/xl.h	Fri Jul 16 12:10:56 2010 +0100
     3.2 +++ b/tools/libxl/xl.h	Mon Jul 19 12:20:41 2010 +0100
     3.3 @@ -72,6 +72,7 @@ int main_tmem_destroy(int argc, char **a
     3.4  int main_tmem_thaw(int argc, char **argv);
     3.5  int main_tmem_set(int argc, char **argv);
     3.6  int main_tmem_shared_auth(int argc, char **argv);
     3.7 +int main_tmem_freeable(int argc, char **argv);
     3.8  int main_network2attach(int argc, char **argv);
     3.9  int main_network2list(int argc, char **argv);
    3.10  int main_network2detach(int argc, char **argv);
     4.1 --- a/tools/libxl/xl_cmdimpl.c	Fri Jul 16 12:10:56 2010 +0100
     4.2 +++ b/tools/libxl/xl_cmdimpl.c	Mon Jul 19 12:20:41 2010 +0100
     4.3 @@ -4586,3 +4586,26 @@ int main_tmem_shared_auth(int argc, char
     4.4      exit(0);
     4.5  }
     4.6  
     4.7 +int main_tmem_freeable(int argc, char **argv)
     4.8 +{
     4.9 +    int opt;
    4.10 +    int mb;
    4.11 +
    4.12 +    while ((opt = getopt(argc, argv, "h")) != -1) {
    4.13 +        switch (opt) {
    4.14 +        case 'h':
    4.15 +            help("tmem-freeable");
    4.16 +            exit(0);
    4.17 +        default:
    4.18 +            fprintf(stderr, "option `%c' not supported.\n", opt);
    4.19 +            break;
    4.20 +        }
    4.21 +    }
    4.22 +
    4.23 +    mb = libxl_tmem_freeable(&ctx);
    4.24 +    if (mb == -1)
    4.25 +        exit(-1);
    4.26 +
    4.27 +    printf("%d\n", mb);
    4.28 +    exit(0);
    4.29 +}
     5.1 --- a/tools/libxl/xl_cmdtable.c	Fri Jul 16 12:10:56 2010 +0100
     5.2 +++ b/tools/libxl/xl_cmdtable.c	Mon Jul 19 12:20:41 2010 +0100
     5.3 @@ -295,6 +295,11 @@ struct cmd_spec cmd_table[] = {
     5.4        "                                 (abcdef01-2345-6789-1234-567890abcdef)\n"
     5.5        "  -A AUTH                        0=auth,1=deauth",
     5.6      },
     5.7 +    { "tmem-freeable",
     5.8 +      &main_tmem_freeable,
     5.9 +      "Get information about how much freeable memory (MB) is in-use by tmem",
    5.10 +      "",
    5.11 +    },
    5.12      { "network2-attach",
    5.13        &main_network2attach,
    5.14        "Create a new version 2 virtual network device",