debuggers.hg

changeset 20861:ff2d29e6ab9c

libxenlight: add a list-vm options to xl that only list vms uuid, domid, name

Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sun Jan 17 18:05:32 2010 +0000 (2010-01-17)
parents abc717dc6c2a
children 757359a36785
files tools/libxl/xl.c
line diff
     1.1 --- a/tools/libxl/xl.c	Sun Jan 17 18:05:03 2010 +0000
     1.2 +++ b/tools/libxl/xl.c	Sun Jan 17 18:05:32 2010 +0000
     1.3 @@ -1433,6 +1433,36 @@ void list_domains(void)
     1.4      free(info);
     1.5  }
     1.6  
     1.7 +void list_vm(void)
     1.8 +{
     1.9 +    struct libxl_ctx ctx;
    1.10 +    struct libxl_vminfo *info;
    1.11 +    int nb_vm, i;
    1.12 +
    1.13 +    if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
    1.14 +        fprintf(stderr, "cannot init xl context\n");
    1.15 +        return;
    1.16 +    }
    1.17 +    libxl_ctx_set_log(&ctx, log_callback, NULL);
    1.18 +
    1.19 +    info = libxl_list_vm(&ctx, &nb_vm);
    1.20 +
    1.21 +    if (info < 0) {
    1.22 +        fprintf(stderr, "libxl_domain_infolist failed.\n");
    1.23 +        exit(1);
    1.24 +    }
    1.25 +    printf("UUID                                  ID    name\n");
    1.26 +    for (i = 0; i < nb_vm; i++) {
    1.27 +        printf(UUID_FMT "  %d    %-30s\n",
    1.28 +            info[i].uuid[0], info[i].uuid[1], info[i].uuid[2], info[i].uuid[3],
    1.29 +            info[i].uuid[4], info[i].uuid[5], info[i].uuid[6], info[i].uuid[7],
    1.30 +            info[i].uuid[8], info[i].uuid[9], info[i].uuid[10], info[i].uuid[11],
    1.31 +            info[i].uuid[12], info[i].uuid[13], info[i].uuid[14], info[i].uuid[15],
    1.32 +            info[i].domid, libxl_domid_to_name(&ctx, info[i].domid));
    1.33 +    }
    1.34 +    free(info);
    1.35 +}
    1.36 +
    1.37  int save_domain(char *p, char *filename, int checkpoint)
    1.38  {
    1.39      struct libxl_ctx ctx;
    1.40 @@ -1633,6 +1663,25 @@ int main_list(int argc, char **argv)
    1.41      exit(0);
    1.42  }
    1.43  
    1.44 +int main_list_vm(int argc, char **argv)
    1.45 +{
    1.46 +    int opt;
    1.47 +
    1.48 +    while ((opt = getopt(argc, argv, "h")) != -1) {
    1.49 +        switch (opt) {
    1.50 +        case 'h':
    1.51 +            help("list-vm");
    1.52 +            exit(0);
    1.53 +        default:
    1.54 +            fprintf(stderr, "option not supported\n");
    1.55 +            break;
    1.56 +        }
    1.57 +    }
    1.58 +
    1.59 +    list_vm();
    1.60 +    exit(0);
    1.61 +}
    1.62 +
    1.63  int main_create(int argc, char **argv)
    1.64  {
    1.65      char *filename = NULL;
    1.66 @@ -1679,6 +1728,8 @@ int main(int argc, char **argv)
    1.67          main_create(argc - 1, argv + 1);
    1.68      } else if (!strcmp(argv[1], "list")) {
    1.69          main_list(argc - 1, argv + 1);
    1.70 +    } else if (!strcmp(argv[1], "list-vm")) {
    1.71 +        main_list_vm(argc - 1, argv + 1);
    1.72      } else if (!strcmp(argv[1], "destroy")) {
    1.73          main_destroy(argc - 1, argv + 1);
    1.74      } else if (!strcmp(argv[1], "pci-attach")) {