debuggers.hg

changeset 20822:9a49e6a66bf0

libxenlight: simplify the logic of domain_list to just return 1024 domains maximum

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jan 08 11:47:28 2010 +0000 (2010-01-08)
parents dd9250567d18
children b35974051d7e
files tools/libxl/libxl.c
line diff
     1.1 --- a/tools/libxl/libxl.c	Fri Jan 08 11:46:52 2010 +0000
     1.2 +++ b/tools/libxl/libxl.c	Fri Jan 08 11:47:28 2010 +0000
     1.3 @@ -273,32 +273,20 @@ struct libxl_dominfo * libxl_domain_list
     1.4  {
     1.5      struct libxl_dominfo *ptr;
     1.6      int index, i, ret, first_domain;
     1.7 -    xc_domaininfo_t info[16];
     1.8 -    int size = 16;
     1.9 +    xc_domaininfo_t info[1024];
    1.10 +    int size = 1024;
    1.11  
    1.12      first_domain = 1;
    1.13      index = 0;
    1.14      ptr = calloc(size, sizeof(struct libxl_dominfo));
    1.15      if (!ptr)
    1.16          return NULL;
    1.17 -redo:
    1.18 -    ret = xc_domain_getinfolist(ctx->xch, first_domain, 16, info);
    1.19 +
    1.20 +    ret = xc_domain_getinfolist(ctx->xch, first_domain, 1024, info);
    1.21      for (i = 0; i < ret; i++) {
    1.22 -        if (index == size) {
    1.23 -            struct libxl_dominfo *ptr2;
    1.24 -
    1.25 -            ptr2 = calloc(size * 2, sizeof(struct libxl_dominfo));
    1.26 -            if (!ptr2) {
    1.27 -                free(ptr);
    1.28 -                return NULL;
    1.29 -            }
    1.30 -            memcpy(ptr2, ptr, sizeof(struct libxl_dominfo) * size);
    1.31 -            free(ptr);
    1.32 -            ptr = ptr2;
    1.33 -            size *= 2;
    1.34 -        }
    1.35          memcpy(&(ptr[index].uuid), info[i].handle, sizeof(xen_domain_handle_t));
    1.36          ptr[index].domid = info[i].domain;
    1.37 +	    printf("domain %d [ret %d]\n", ptr[index].domid, ret);
    1.38  
    1.39          if (info[i].flags & XEN_DOMINF_dying)
    1.40              ptr[index].dying = 1;
    1.41 @@ -310,8 +298,6 @@ redo:
    1.42          first_domain = info[i].domain + 1;
    1.43          index++;
    1.44      }
    1.45 -    if (ret == 16)
    1.46 -        goto redo;
    1.47      *nb_domain = index;
    1.48      return ptr;
    1.49  }