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-devel

[Xen-devel] [PATCH 2/2]xl: Add "xl domname" command

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/2]xl: Add "xl domname" command
From: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>
Date: Fri, 07 May 2010 13:00:52 +0800
Delivery-date: Thu, 06 May 2010 22:01:54 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100415 Thunderbird/3.0.4
Add "xl domname" command, a clone of "xm domname".

Signed-off-by: Yang Hongyang <yanghy@xxxxxxxxxxxxxx>

diff -r 1d00cee69621 -r 357eab43f7ee tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri May 07 19:35:40 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c  Fri May 07 20:06:28 2010 +0800
@@ -1224,6 +1224,9 @@
     } else if (!strcmp(command, "domid")) {
         printf("Usage: xl domid <DomainName>\n\n");
         printf("Convert a domain name to domain id.\n");
+    } else if (!strcmp(command, "domname")) {
+        printf("Usage: xl domname <DomainId>\n\n");
+        printf("Convert a domain id to domain name.\n");
     }
 }
 
@@ -2981,3 +2984,43 @@
 
     exit(0);
 }
+
+int main_domname(int argc, char **argv)
+{
+    int opt;
+    char *domname = NULL;
+    char *endptr = NULL;
+
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("domname");
+            exit(0);
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (!argv[optind]) {
+        fprintf(stderr, "Must specify a domain id.\n\n");
+        help("domname");
+        exit(1);
+    }
+    domid = strtol(argv[optind], &endptr, 10);
+    if (domid == 0 && !strcmp(endptr, argv[optind])) {
+        /*no digits at all*/
+        fprintf(stderr, "Invalid domain id.\n\n");
+        exit(1);
+    }
+
+    domname = libxl_domid_to_name(&ctx, domid);
+    if (!domname) {
+        fprintf(stderr, "Can't get domain name of domain id '%d', maybe this 
domain does not exist.\n", domid);
+        exit(1);
+    }
+
+    printf("%s\n", domname);
+
+    exit(0);
+}
diff -r 1d00cee69621 -r 357eab43f7ee tools/libxl/xl_cmdimpl.h
--- a/tools/libxl/xl_cmdimpl.h  Fri May 07 19:35:40 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.h  Fri May 07 20:06:28 2010 +0800
@@ -36,5 +36,6 @@
 int main_memset(int argc, char **argv);
 int main_sched_credit(int argc, char **argv);
 int main_domid(int argc, char **argv);
+int main_domname(int argc, char **argv);
 
 void help(char *command);
diff -r 1d00cee69621 -r 357eab43f7ee tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Fri May 07 19:35:40 2010 +0800
+++ b/tools/libxl/xl_cmdtable.c Fri May 07 20:06:28 2010 +0800
@@ -37,6 +37,7 @@
     { "info", &main_info, "get information about Xen host" },
     { "sched-credit", &main_sched_credit, "get/set credit scheduler 
parameters" },
     { "domid", &main_domid, "convert a domain name to domain id"},
+    { "domname", &main_domname, "convert a domain id to domain name"},
 };
 
 int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

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

<Prev in Thread] Current Thread [Next in Thread>