debuggers.hg
changeset 20867:d7e8b6a66a3d
libxl: fix "xl list" output
This simple patch fixes the "xl list" output and cleans
libxl_list_domain after the recent API changes to list domains and
VMs.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
This simple patch fixes the "xl list" output and cleans
libxl_list_domain after the recent API changes to list domains and
VMs.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Mon Jan 18 14:49:00 2010 +0000 (2010-01-18) |
parents | a56216b3f62d |
children | b684d9e57b8f |
files | tools/libxl/libxl.c tools/libxl/xl.c |
line diff
1.1 --- a/tools/libxl/libxl.c Mon Jan 18 14:48:18 2010 +0000 1.2 +++ b/tools/libxl/libxl.c Mon Jan 18 14:49:00 2010 +0000 1.3 @@ -287,7 +287,7 @@ int libxl_domain_resume(struct libxl_ctx 1.4 struct libxl_dominfo * libxl_list_domain(struct libxl_ctx *ctx, int *nb_domain) 1.5 { 1.6 struct libxl_dominfo *ptr; 1.7 - int index, i, ret; 1.8 + int i, ret; 1.9 xc_domaininfo_t info[1024]; 1.10 int size = 1024; 1.11 1.12 @@ -296,24 +296,22 @@ struct libxl_dominfo * libxl_list_domain 1.13 return NULL; 1.14 1.15 ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info); 1.16 - for (index = i = 0; i < ret; i++) { 1.17 - memcpy(&(ptr[index].uuid), info[i].handle, sizeof(xen_domain_handle_t)); 1.18 - ptr[index].domid = info[i].domain; 1.19 + for (i = 0; i < ret; i++) { 1.20 + memcpy(&(ptr[i].uuid), info[i].handle, sizeof(xen_domain_handle_t)); 1.21 + ptr[i].domid = info[i].domain; 1.22 1.23 if (info[i].flags & XEN_DOMINF_dying) 1.24 - ptr[index].dying = 1; 1.25 + ptr[i].dying = 1; 1.26 else if (info[i].flags & XEN_DOMINF_paused) 1.27 - ptr[index].paused = 1; 1.28 + ptr[i].paused = 1; 1.29 else if (info[i].flags & XEN_DOMINF_blocked || info[i].flags & XEN_DOMINF_running) 1.30 - ptr[index].running = 1; 1.31 - ptr[index].max_memkb = PAGE_TO_MEMKB(info[i].max_pages); 1.32 - ptr[index].cpu_time = info[i].cpu_time; 1.33 - ptr[index].vcpu_max_id = info[i].max_vcpu_id; 1.34 - ptr[index].vcpu_online = info[i].nr_online_vcpus; 1.35 - 1.36 - index++; 1.37 + ptr[i].running = 1; 1.38 + ptr[i].max_memkb = PAGE_TO_MEMKB(info[i].tot_pages); 1.39 + ptr[i].cpu_time = info[i].cpu_time; 1.40 + ptr[i].vcpu_max_id = info[i].max_vcpu_id; 1.41 + ptr[i].vcpu_online = info[i].nr_online_vcpus; 1.42 } 1.43 - *nb_domain = index; 1.44 + *nb_domain = ret; 1.45 return ptr; 1.46 } 1.47
2.1 --- a/tools/libxl/xl.c Mon Jan 18 14:48:18 2010 +0000 2.2 +++ b/tools/libxl/xl.c Mon Jan 18 14:49:00 2010 +0000 2.3 @@ -1421,14 +1421,17 @@ void list_domains(void) 2.4 fprintf(stderr, "libxl_domain_infolist failed.\n"); 2.5 exit(1); 2.6 } 2.7 - printf("Name ID \tState\n"); 2.8 + printf("Name ID Mem VCPUs\tState\tTime(s)\n"); 2.9 for (i = 0; i < nb_domain; i++) { 2.10 - printf("%-40s %5d %c%c%c\n", 2.11 + printf("%-40s %5d %5lu %5d %c%c%c %8.1f\n", 2.12 libxl_domid_to_name(&ctx, info[i].domid), 2.13 info[i].domid, 2.14 + (unsigned long) (info[i].max_memkb / 1024), 2.15 + info[i].vcpu_online, 2.16 info[i].running ? 'r' : '-', 2.17 info[i].paused ? 'p' : '-', 2.18 - info[i].dying ? 'd' : '-'); 2.19 + info[i].dying ? 'd' : '-', 2.20 + ((float)info[i].cpu_time / 1e9)); 2.21 } 2.22 free(info); 2.23 }