aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-01-17 18:05:32 +0000
committerKeir Fraser <keir.fraser@citrix.com>2010-01-17 18:05:32 +0000
commit9ae90516621d9bb92e05c57a1de74a0297898569 (patch)
treebc5f87d3a65a6c6aa33f3f0bb4d28a6522e5a738
parent24cdde59ca1ca02ae0fe209a447d6810e2b47849 (diff)
downloadxen-9ae90516621d9bb92e05c57a1de74a0297898569.tar.gz
xen-9ae90516621d9bb92e05c57a1de74a0297898569.tar.bz2
xen-9ae90516621d9bb92e05c57a1de74a0297898569.zip
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>
-rw-r--r--tools/libxl/xl.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/libxl/xl.c b/tools/libxl/xl.c
index 451ab8cf50..49ae65c70e 100644
--- a/tools/libxl/xl.c
+++ b/tools/libxl/xl.c
@@ -1433,6 +1433,36 @@ void list_domains(void)
free(info);
}
+void list_vm(void)
+{
+ struct libxl_ctx ctx;
+ struct libxl_vminfo *info;
+ int nb_vm, i;
+
+ if (libxl_ctx_init(&ctx, LIBXL_VERSION)) {
+ fprintf(stderr, "cannot init xl context\n");
+ return;
+ }
+ libxl_ctx_set_log(&ctx, log_callback, NULL);
+
+ info = libxl_list_vm(&ctx, &nb_vm);
+
+ if (info < 0) {
+ fprintf(stderr, "libxl_domain_infolist failed.\n");
+ exit(1);
+ }
+ printf("UUID ID name\n");
+ for (i = 0; i < nb_vm; i++) {
+ printf(UUID_FMT " %d %-30s\n",
+ info[i].uuid[0], info[i].uuid[1], info[i].uuid[2], info[i].uuid[3],
+ info[i].uuid[4], info[i].uuid[5], info[i].uuid[6], info[i].uuid[7],
+ info[i].uuid[8], info[i].uuid[9], info[i].uuid[10], info[i].uuid[11],
+ info[i].uuid[12], info[i].uuid[13], info[i].uuid[14], info[i].uuid[15],
+ info[i].domid, libxl_domid_to_name(&ctx, info[i].domid));
+ }
+ free(info);
+}
+
int save_domain(char *p, char *filename, int checkpoint)
{
struct libxl_ctx ctx;
@@ -1633,6 +1663,25 @@ int main_list(int argc, char **argv)
exit(0);
}
+int main_list_vm(int argc, char **argv)
+{
+ int opt;
+
+ while ((opt = getopt(argc, argv, "h")) != -1) {
+ switch (opt) {
+ case 'h':
+ help("list-vm");
+ exit(0);
+ default:
+ fprintf(stderr, "option not supported\n");
+ break;
+ }
+ }
+
+ list_vm();
+ exit(0);
+}
+
int main_create(int argc, char **argv)
{
char *filename = NULL;
@@ -1679,6 +1728,8 @@ int main(int argc, char **argv)
main_create(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "list")) {
main_list(argc - 1, argv + 1);
+ } else if (!strcmp(argv[1], "list-vm")) {
+ main_list_vm(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "destroy")) {
main_destroy(argc - 1, argv + 1);
} else if (!strcmp(argv[1], "pci-attach")) {