]> xenbits.xensource.com Git - xen.git/commitdiff
xl: Add command description to command table
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 4 May 2010 10:37:06 +0000 (11:37 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 4 May 2010 10:37:06 +0000 (11:37 +0100)
Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
tools/libxl/Makefile
tools/libxl/xl_cmdimpl.c
tools/libxl/xl_cmdtable.c [new file with mode: 0644]
tools/libxl/xl_cmdtable.h

index 1b42180ae8b940e8b620f2a403e5767338c54255..57b2d9064d2732b0b9bf75b2a07fe9573b3f8483 100644 (file)
@@ -82,7 +82,10 @@ xl.o: xl.c
 xl_cmdimpl.o: xl_cmdimpl.c
        $(CC) $(CFLAGS) -c xl_cmdimpl.c
 
-$(CLIENTS): xl.o xl_cmdimpl.o libxlutil.so libxenlight.so
+xl_cmdtable.o: xl_cmdtable.c
+       $(CC) $(CFLAGS) -c xl_cmdtable.c
+
+$(CLIENTS): xl.o xl_cmdimpl.o xl_cmdtable.o libxlutil.so libxenlight.so
        $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 .PHONY: install
index 2fd0c604df8e4ef3d466a3740f72e8406ec455f6..4315c5a5ee3933e0ed7d0447a2d4edc26aa13990 100644 (file)
@@ -38,6 +38,7 @@
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxlutil.h"
+#include "xl_cmdtable.h"
 
 #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
 
@@ -1078,28 +1079,14 @@ start:
 
 void help(char *command)
 {
+    int i;
+
     if (!command || !strcmp(command, "help")) {
         printf("Usage xl <subcommand> [args]\n\n");
         printf("xl full list of subcommands:\n\n");
-        printf(" create                        create a domain from config file <filename>\n\n");
-        printf(" list                          list information about all domains\n\n");
-        printf(" destroy                       terminate a domain immediately\n\n");
-        printf(" pci-attach                    insert a new pass-through pci device\n\n");
-        printf(" pci-detach                    remove a domain's pass-through pci device\n\n");
-        printf(" pci-list                      list pass-through pci devices for a domain\n\n");
-        printf(" pause                         pause execution of a domain\n\n");
-        printf(" unpause                       unpause a paused domain\n\n");
-        printf(" console                       attach to domain's console\n\n");
-        printf(" save                          save a domain state to restore later\n\n");
-        printf(" restore                       restore a domain from a saved state\n\n");
-        printf(" cd-insert                     insert a cdrom into a guest's cd drive\n\n");
-        printf(" cd-eject                      eject a cdrom from a guest's cd drive\n\n");
-        printf(" mem-set                       set the current memory usage for a domain\n\n");
-        printf(" button-press                  indicate an ACPI button press to the domain\n\n");
-        printf(" vcpu-list                     list the VCPUs for all/some domains.\n\n");
-        printf(" vcpu-pin                      Set which CPUs a VCPU can use.\n\n");
-        printf(" vcpu-set                      Set the number of active VCPUs allowed for the domain.\n\n");
-        printf(" sched-credit                  Get/set credit scheduler parameters.\n\n");
+        for (i = 0; i < cmdtable_len; i++)
+            printf(" %-25s%s\n\n",
+                   cmd_table[i].cmd_name, cmd_table[i].cmd_desc);
     } else if(!strcmp(command, "create")) {
         printf("Usage: xl create <ConfigFile> [options] [vars]\n\n");
         printf("Create a domain based on <ConfigFile>.\n\n");
@@ -2481,7 +2468,7 @@ void vcpulist(int argc, char **argv)
     ;
 }
 
-void main_vcpulist(int argc, char **argv)
+int main_vcpulist(int argc, char **argv)
 {
     int opt;
 
@@ -2736,7 +2723,7 @@ static void info(int verbose)
     return;
 }
 
-void main_info(int argc, char **argv)
+int main_info(int argc, char **argv)
 {
     int opt, verbose;
 
diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c
new file mode 100644 (file)
index 0000000..eb420aa
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Author Yang Hongyang <yanghy@cn.fujitsu.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "xl_cmdtable.h"
+
+struct cmd_spec cmd_table[] = {
+    { "create", &main_create, "create a domain from config file <filename>" },
+    { "list", &main_list, "list information about all domains" },
+    { "destroy", &main_destroy, "terminate a domain immediately" },
+    { "pci-attach", &main_pciattach, "insert a new pass-through pci device" },
+    { "pci-detach", &main_pcidetach, "remove a domain's pass-through pci device" },
+    { "pci-list", &main_pcilist, "list pass-through pci devices for a domain" },
+    { "pause", &main_pause, "pause execution of a domain" },
+    { "unpause", &main_unpause, "unpause a paused domain" },
+    { "console", &main_console, "attach to domain's console" },
+    { "save", &main_save, "save a domain state to restore later" },
+    { "restore", &main_restore, "restore a domain from a saved state" },
+    { "cd-insert", &main_cd_insert, "insert a cdrom into a guest's cd drive" },
+    { "cd-eject", &main_cd_eject, "eject a cdrom from a guest's cd drive" },
+    { "mem-set", &main_memset, "set the current memory usage for a domain" },
+    { "button-press", &main_button_press, "indicate an ACPI button press to the domain" },
+    { "vcpu-list", &main_vcpulist, "list the VCPUs for all/some domains" },
+    { "vcpu-pin", &main_vcpupin, "set which CPUs a VCPU can use" },
+    { "vcpu-set", &main_vcpuset, "set the number of active VCPUs allowed for the domain" },
+    { "list-vm", &main_list_vm, "list the VMs,without DOM0" },
+    { "info", &main_info, "get information about Xen host" },
+    { "sched-credit", &main_sched_credit, "get/set credit scheduler parameters" }
+};
+
+int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
index 76a5437697a360144acba73d9739d929e17633bc..e1a44d85bd4b4cea532f61e77148b2919d8d6321 100644 (file)
 struct cmd_spec {
     char *cmd_name;
     int (*cmd_impl)(int argc, char **argv);
+    char *cmd_desc;
 };
 
-struct cmd_spec cmd_table[] = {
-    { "create", &main_create },
-    { "list", &main_list },
-    { "destroy", &main_destroy },
-    { "pci-attach", &main_pciattach },
-    { "pci-detach", &main_pcidetach },
-    { "pci-list", &main_pcilist },
-    { "pause", &main_pause },
-    { "unpause", &main_unpause },
-    { "console", &main_console },
-    { "save", &main_save },
-    { "restore", &main_restore },
-    { "cd-insert", &main_cd_insert },
-    { "cd-eject", &main_cd_eject },
-    { "mem-set", &main_memset },
-    { "button-press", &main_button_press },
-    { "vcpu-list", &main_vcpulist },
-    { "vcpu-pin", &main_vcpupin },
-    { "vcpu-set", &main_vcpuset },
-    { "list-vm", &main_list_vm },
-    { "info", &main_info },
-    { "sched-credit", &main_sched_credit },
-};
-
-int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
+extern struct cmd_spec cmd_table[];
+extern int cmdtable_len;