xs_transaction_t t;
xen_domain_handle_t handle;
- uuid_string = string_of_uuid(ctx, info->uuid);
- if (!uuid_string) {
- XL_LOG(ctx, XL_LOG_ERROR, "cannot allocate uuid string");
- return ERROR_FAIL;
- }
+ uuid_string = libxl_uuid2string(ctx, info->uuid);
+ if (!uuid_string) return ERROR_NOMEM;
flags = info->hvm ? XEN_DOMCTL_CDF_hvm_guest : 0;
flags |= info->hap ? XEN_DOMCTL_CDF_hap : 0;
int libxl_domain_shutdown(struct libxl_ctx *ctx, uint32_t domid, int req);
int libxl_domain_destroy(struct libxl_ctx *ctx, uint32_t domid, int force);
+char *libxl_uuid2string(struct libxl_ctx *ctx, uint8_t uuid[16]);
+ /* 0 means ERROR_ENOMEM, which we have logged */
+
/* events handling */
typedef enum {
printf("-d Enable debug messages.\n");
printf("-e Do not wait in the background for the death of the domain.\n");
} else if(!strcmp(command, "list")) {
- printf("Usage: xl list [Domain]\n\n");
+ printf("Usage: xl list [-v] [Domain]\n\n");
printf("List information about all/some domains.\n\n");
} else if(!strcmp(command, "pci-attach")) {
printf("Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n\n");
libxl_domain_destroy(&ctx, domid, 0);
}
-void list_domains(void)
+void list_domains(int verbose)
{
struct libxl_ctx ctx;
struct libxl_dominfo *info;
}
printf("Name ID Mem VCPUs\tState\tTime(s)\n");
for (i = 0; i < nb_domain; i++) {
- printf("%-40s %5d %5lu %5d %c%c%c %8.1f\n",
+ printf("%-40s %5d %5lu %5d %c%c%c %8.1f",
libxl_domid_to_name(&ctx, info[i].domid),
info[i].domid,
(unsigned long) (info[i].max_memkb / 1024),
info[i].paused ? 'p' : '-',
info[i].dying ? 'd' : '-',
((float)info[i].cpu_time / 1e9));
+ if (verbose) {
+ char *uuid = libxl_uuid2string(&ctx, info[i].uuid);
+ printf(" %s", uuid);
+ }
+ putchar('\n');
}
free(info);
}
int main_list(int argc, char **argv)
{
- int opt;
+ int opt, verbose = 0;
- while ((opt = getopt(argc, argv, "h")) != -1) {
+ while ((opt = getopt(argc, argv, "hv")) != -1) {
switch (opt) {
case 'h':
help("list");
exit(0);
+ case 'v':
+ verbose = 1;
+ break;
default:
fprintf(stderr, "option not supported\n");
break;
}
}
- list_domains();
+ list_domains(verbose);
exit(0);
}