diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-01-18 14:49:00 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-01-18 14:49:00 +0000 |
commit | 61802642f7ec83566f2c0ceb092ef9aa65ef9332 (patch) | |
tree | 10397ebc5cb3dc784008d0f85adc74f1b303befa | |
parent | 6127bd73bde6c4265a2ac403203e24a11c582cc5 (diff) | |
download | xen-61802642f7ec83566f2c0ceb092ef9aa65ef9332.tar.gz xen-61802642f7ec83566f2c0ceb092ef9aa65ef9332.tar.bz2 xen-61802642f7ec83566f2c0ceb092ef9aa65ef9332.zip |
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>
-rw-r--r-- | tools/libxl/libxl.c | 26 | ||||
-rw-r--r-- | tools/libxl/xl.c | 9 |
2 files changed, 18 insertions, 17 deletions
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index ca92400930..7b7289f863 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -287,7 +287,7 @@ int libxl_domain_resume(struct libxl_ctx *ctx, uint32_t domid) 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 @@ struct libxl_dominfo * libxl_list_domain(struct libxl_ctx *ctx, int *nb_domain) 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 --git a/tools/libxl/xl.c b/tools/libxl/xl.c index 49ae65c70e..34eefef5b2 100644 --- a/tools/libxl/xl.c +++ b/tools/libxl/xl.c @@ -1421,14 +1421,17 @@ void list_domains(void) 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); } |