mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
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 commit is contained in:
1 parent
6127bd73bd
commit
61802642f7
2 files changed
+18
-17
No files matched your search
+12
-14
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -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);
|
||||
}
|
||||
|
||||