WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xl: support "xl list <domain>"

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: support "xl list <domain>"
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 02 Aug 2010 01:40:24 -0700
Delivery-date: Mon, 02 Aug 2010 01:42:58 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
# Date 1280499176 -3600
# Node ID 84f8ad68bc58a4039e70da2d9949cc0d059f105b
# Parent  64fa1a9c723ca60a9246283b133c85a1a81806e2
xl: support "xl list <domain>"

xm list takes an optional domain argument; make xl list do likewise.
This also gets rid of a small amount of code which was duplicated
between list_domains and list_domains_details.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   66 +++++++++++++++++++++++++++--------------------
 1 files changed, 39 insertions(+), 27 deletions(-)

diff -r 64fa1a9c723c -r 84f8ad68bc58 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jul 30 15:12:10 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri Jul 30 15:12:56 2010 +0100
@@ -2126,22 +2126,15 @@ void reboot_domain(char *p)
     if (rc) { fprintf(stderr,"reboot failed (rc=%d)\n.",rc);exit(-1); }
 }
 
-void list_domains_details(void)
-{
-    libxl_dominfo *info;
+void list_domains_details(const libxl_dominfo *info, int nb_domain)
+{
     struct domain_config d_config;
 
     char *config_file;
     uint8_t *data;
-    int nb_domain, i, len, rc;
+    int i, len, rc;
     libxl_device_model_info dm_info;
 
-    info = libxl_list_domain(&ctx, &nb_domain);
-
-    if (!info) {
-        fprintf(stderr, "libxl_domain_infolist failed.\n");
-        exit(1);
-    }
     for (i = 0; i < nb_domain; i++) {
         rc = libxl_userdata_retrieve(&ctx, info[i].domid, "xl", &data, &len);
         if (rc)
@@ -2153,20 +2146,12 @@ void list_domains_details(void)
         free(data);
         free(config_file);
     }
-    free(info);
-}
-
-void list_domains(int verbose)
-{
-    libxl_dominfo *info;
-    int nb_domain, i;
-
-    info = libxl_list_domain(&ctx, &nb_domain);
-
-    if (!info) {
-        fprintf(stderr, "libxl_domain_infolist failed.\n");
-        exit(1);
-    }
+}
+
+void list_domains(int verbose, const libxl_dominfo *info, int nb_domain)
+{
+    int i;
+
     printf("Name                                        ID   Mem 
VCPUs\tState\tTime(s)\n");
     for (i = 0; i < nb_domain; i++) {
         printf("%-40s %5d %5lu %5d     %c%c%c%c%c%c  %8.1f",
@@ -2187,7 +2172,6 @@ void list_domains(int verbose)
         }
         putchar('\n');
     }
-    free(info);
 }
 
 void list_vm(void)
@@ -2992,6 +2976,10 @@ int main_list(int argc, char **argv)
         {0, 0, 0, 0}
     };
 
+    libxl_dominfo info_buf;
+    libxl_dominfo *info, *info_free=0;
+    int nb_domain, rc;
+
     while (1) {
         opt = getopt_long(argc, argv, "lvh", long_options, &option_index);
         if (opt == -1)
@@ -3013,10 +3001,34 @@ int main_list(int argc, char **argv)
         }
     }
 
+    if (optind >= argc) {
+        info = libxl_list_domain(&ctx, &nb_domain);
+        if (!info) {
+            fprintf(stderr, "libxl_domain_infolist failed.\n");
+            exit(1);
+        }
+        info_free = info;
+    } else if (optind == argc-1) {
+        find_domain(argv[optind]);
+        rc = libxl_domain_info(&ctx, &info_buf, domid);
+        if (rc) {
+            fprintf(stderr, "libxl_domain_info failed (code %d).\n", rc);
+            exit(-rc);
+        }
+        info = &info_buf;
+        nb_domain = 1;
+    } else {
+        help("list");
+        exit(2);
+    }
+
     if (details)
-        list_domains_details();
+        list_domains_details(info, nb_domain);
     else
-        list_domains(verbose);
+        list_domains(verbose, info, nb_domain);
+
+    free(info_free);
+
     exit(0);
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: support "xl list <domain>", Xen patchbot-unstable <=