[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] libxl: fix "xl list" output
Hi all, 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@xxxxxxxxxxxxx> --- diff -r 618b3597603c tools/libxl/libxl.c --- a/tools/libxl/libxl.c Mon Jan 18 10:37:28 2010 +0000 +++ b/tools/libxl/libxl.c Mon Jan 18 11:13:03 2010 +0000 @@ -287,7 +287,7 @@ struct libxl_dominfo * libxl_list_domain(struct libxl_ctx *ctx, int *nb_domain) { struct libxl_dominfo *ptr; - int index, i, ret; + int i, ret; xc_domaininfo_t info[1024]; int size = 1024; @@ -296,24 +296,22 @@ return NULL; ret = xc_domain_getinfolist(ctx->xch, 0, 1024, info); - for (index = i = 0; i < ret; i++) { - memcpy(&(ptr[index].uuid), info[i].handle, sizeof(xen_domain_handle_t)); - ptr[index].domid = info[i].domain; + for (i = 0; i < ret; i++) { + memcpy(&(ptr[i].uuid), info[i].handle, sizeof(xen_domain_handle_t)); + ptr[i].domid = info[i].domain; if (info[i].flags & XEN_DOMINF_dying) - ptr[index].dying = 1; + ptr[i].dying = 1; else if (info[i].flags & XEN_DOMINF_paused) - ptr[index].paused = 1; + ptr[i].paused = 1; else if (info[i].flags & XEN_DOMINF_blocked || info[i].flags & XEN_DOMINF_running) - ptr[index].running = 1; - ptr[index].max_memkb = PAGE_TO_MEMKB(info[i].max_pages); - ptr[index].cpu_time = info[i].cpu_time; - ptr[index].vcpu_max_id = info[i].max_vcpu_id; - ptr[index].vcpu_online = info[i].nr_online_vcpus; - - index++; + ptr[i].running = 1; + ptr[i].max_memkb = PAGE_TO_MEMKB(info[i].tot_pages); + ptr[i].cpu_time = info[i].cpu_time; + ptr[i].vcpu_max_id = info[i].max_vcpu_id; + ptr[i].vcpu_online = info[i].nr_online_vcpus; } - *nb_domain = index; + *nb_domain = ret; return ptr; } diff -r 618b3597603c tools/libxl/xl.c --- a/tools/libxl/xl.c Mon Jan 18 10:37:28 2010 +0000 +++ b/tools/libxl/xl.c Mon Jan 18 11:13:03 2010 +0000 @@ -1421,14 +1421,17 @@ fprintf(stderr, "libxl_domain_infolist failed.\n"); exit(1); } - printf("Name ID \tState\n"); + printf("Name ID Mem VCPUs\tState\tTime(s)\n"); for (i = 0; i < nb_domain; i++) { - printf("%-40s %5d %c%c%c\n", + printf("%-40s %5d %5lu %5d %c%c%c %8.1f\n", libxl_domid_to_name(&ctx, info[i].domid), info[i].domid, + (unsigned long) (info[i].max_memkb / 1024), + info[i].vcpu_online, info[i].running ? 'r' : '-', info[i].paused ? 'p' : '-', - info[i].dying ? 'd' : '-'); + info[i].dying ? 'd' : '-', + ((float)info[i].cpu_time / 1e9)); } free(info); } _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |