debuggers.hg

changeset 20830:55109e7326cc

libxenlight: do not try to set memory target with a number we haven't
verified in set-mem.

checking that memory string conversion what done properly instead of
sending a request to balloon a domain to 0 memory.

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jan 12 07:03:14 2010 +0000 (2010-01-12)
parents 3edbffaab206
children 6ae90d7f7f45
files tools/libxl/xl.c
line diff
     1.1 --- a/tools/libxl/xl.c	Tue Jan 12 07:02:29 2010 +0000
     1.2 +++ b/tools/libxl/xl.c	Tue Jan 12 07:03:14 2010 +0000
     1.3 @@ -993,6 +993,8 @@ void set_memory_target(char *p, char *me
     1.4  {
     1.5      struct libxl_ctx ctx;
     1.6      uint32_t domid;
     1.7 +    uint32_t memorykb;
     1.8 +    char *endptr;
     1.9  
    1.10      if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
    1.11          fprintf(stderr, "cannot init xl context\n");
    1.12 @@ -1004,7 +1006,13 @@ void set_memory_target(char *p, char *me
    1.13          fprintf(stderr, "%s is an invalid domain identifier\n", p);
    1.14          exit(2);
    1.15      }
    1.16 -    libxl_set_memory_target(&ctx, domid, atoi(mem));
    1.17 +    memorykb = strtoul(mem, &endptr, 10);
    1.18 +    if (*endptr != '\0') {
    1.19 +        fprintf(stderr, "invalid memory size: %s\n", mem);
    1.20 +        exit(3);
    1.21 +    }
    1.22 +    printf("setting domid %d memory to : %d\n", domid, memorykb);
    1.23 +    libxl_set_memory_target(&ctx, domid, memorykb);
    1.24  }
    1.25  
    1.26  int main_memset(int argc, char **argv)