debuggers.hg

changeset 21295:ef961ddf8b33

xl: Add command description to command table

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 04 11:37:06 2010 +0100 (2010-05-04)
parents 35da124fc66a
children 843a42e726cc
files tools/libxl/Makefile tools/libxl/xl_cmdimpl.c tools/libxl/xl_cmdtable.c tools/libxl/xl_cmdtable.h
line diff
     1.1 --- a/tools/libxl/Makefile	Tue May 04 11:28:06 2010 +0100
     1.2 +++ b/tools/libxl/Makefile	Tue May 04 11:37:06 2010 +0100
     1.3 @@ -82,7 +82,10 @@ xl.o: xl.c
     1.4  xl_cmdimpl.o: xl_cmdimpl.c
     1.5  	$(CC) $(CFLAGS) -c xl_cmdimpl.c
     1.6  
     1.7 -$(CLIENTS): xl.o xl_cmdimpl.o libxlutil.so libxenlight.so
     1.8 +xl_cmdtable.o: xl_cmdtable.c
     1.9 +	$(CC) $(CFLAGS) -c xl_cmdtable.c
    1.10 +
    1.11 +$(CLIENTS): xl.o xl_cmdimpl.o xl_cmdtable.o libxlutil.so libxenlight.so
    1.12  	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
    1.13  
    1.14  .PHONY: install
     2.1 --- a/tools/libxl/xl_cmdimpl.c	Tue May 04 11:28:06 2010 +0100
     2.2 +++ b/tools/libxl/xl_cmdimpl.c	Tue May 04 11:37:06 2010 +0100
     2.3 @@ -38,6 +38,7 @@
     2.4  #include "libxl.h"
     2.5  #include "libxl_utils.h"
     2.6  #include "libxlutil.h"
     2.7 +#include "xl_cmdtable.h"
     2.8  
     2.9  #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
    2.10  
    2.11 @@ -1078,28 +1079,14 @@ start:
    2.12  
    2.13  void help(char *command)
    2.14  {
    2.15 +    int i;
    2.16 +
    2.17      if (!command || !strcmp(command, "help")) {
    2.18          printf("Usage xl <subcommand> [args]\n\n");
    2.19          printf("xl full list of subcommands:\n\n");
    2.20 -        printf(" create                        create a domain from config file <filename>\n\n");
    2.21 -        printf(" list                          list information about all domains\n\n");
    2.22 -        printf(" destroy                       terminate a domain immediately\n\n");
    2.23 -        printf(" pci-attach                    insert a new pass-through pci device\n\n");
    2.24 -        printf(" pci-detach                    remove a domain's pass-through pci device\n\n");
    2.25 -        printf(" pci-list                      list pass-through pci devices for a domain\n\n");
    2.26 -        printf(" pause                         pause execution of a domain\n\n");
    2.27 -        printf(" unpause                       unpause a paused domain\n\n");
    2.28 -        printf(" console                       attach to domain's console\n\n");
    2.29 -        printf(" save                          save a domain state to restore later\n\n");
    2.30 -        printf(" restore                       restore a domain from a saved state\n\n");
    2.31 -        printf(" cd-insert                     insert a cdrom into a guest's cd drive\n\n");
    2.32 -        printf(" cd-eject                      eject a cdrom from a guest's cd drive\n\n");
    2.33 -        printf(" mem-set                       set the current memory usage for a domain\n\n");
    2.34 -        printf(" button-press                  indicate an ACPI button press to the domain\n\n");
    2.35 -        printf(" vcpu-list                     list the VCPUs for all/some domains.\n\n");
    2.36 -        printf(" vcpu-pin                      Set which CPUs a VCPU can use.\n\n");
    2.37 -        printf(" vcpu-set                      Set the number of active VCPUs allowed for the domain.\n\n");
    2.38 -        printf(" sched-credit                  Get/set credit scheduler parameters.\n\n");
    2.39 +        for (i = 0; i < cmdtable_len; i++)
    2.40 +            printf(" %-25s%s\n\n",
    2.41 +                   cmd_table[i].cmd_name, cmd_table[i].cmd_desc);
    2.42      } else if(!strcmp(command, "create")) {
    2.43          printf("Usage: xl create <ConfigFile> [options] [vars]\n\n");
    2.44          printf("Create a domain based on <ConfigFile>.\n\n");
    2.45 @@ -2481,7 +2468,7 @@ void vcpulist(int argc, char **argv)
    2.46      ;
    2.47  }
    2.48  
    2.49 -void main_vcpulist(int argc, char **argv)
    2.50 +int main_vcpulist(int argc, char **argv)
    2.51  {
    2.52      int opt;
    2.53  
    2.54 @@ -2736,7 +2723,7 @@ static void info(int verbose)
    2.55      return;
    2.56  }
    2.57  
    2.58 -void main_info(int argc, char **argv)
    2.59 +int main_info(int argc, char **argv)
    2.60  {
    2.61      int opt, verbose;
    2.62  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/libxl/xl_cmdtable.c	Tue May 04 11:37:06 2010 +0100
     3.3 @@ -0,0 +1,41 @@
     3.4 +/*
     3.5 + * Author Yang Hongyang <yanghy@cn.fujitsu.com>
     3.6 + *
     3.7 + * This program is free software; you can redistribute it and/or modify
     3.8 + * it under the terms of the GNU Lesser General Public License as published
     3.9 + * by the Free Software Foundation; version 2.1 only. with the special
    3.10 + * exception on linking described in file LICENSE.
    3.11 + *
    3.12 + * This program is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 + * GNU Lesser General Public License for more details.
    3.16 + */
    3.17 +
    3.18 +#include "xl_cmdtable.h"
    3.19 +
    3.20 +struct cmd_spec cmd_table[] = {
    3.21 +    { "create", &main_create, "create a domain from config file <filename>" },
    3.22 +    { "list", &main_list, "list information about all domains" },
    3.23 +    { "destroy", &main_destroy, "terminate a domain immediately" },
    3.24 +    { "pci-attach", &main_pciattach, "insert a new pass-through pci device" },
    3.25 +    { "pci-detach", &main_pcidetach, "remove a domain's pass-through pci device" },
    3.26 +    { "pci-list", &main_pcilist, "list pass-through pci devices for a domain" },
    3.27 +    { "pause", &main_pause, "pause execution of a domain" },
    3.28 +    { "unpause", &main_unpause, "unpause a paused domain" },
    3.29 +    { "console", &main_console, "attach to domain's console" },
    3.30 +    { "save", &main_save, "save a domain state to restore later" },
    3.31 +    { "restore", &main_restore, "restore a domain from a saved state" },
    3.32 +    { "cd-insert", &main_cd_insert, "insert a cdrom into a guest's cd drive" },
    3.33 +    { "cd-eject", &main_cd_eject, "eject a cdrom from a guest's cd drive" },
    3.34 +    { "mem-set", &main_memset, "set the current memory usage for a domain" },
    3.35 +    { "button-press", &main_button_press, "indicate an ACPI button press to the domain" },
    3.36 +    { "vcpu-list", &main_vcpulist, "list the VCPUs for all/some domains" },
    3.37 +    { "vcpu-pin", &main_vcpupin, "set which CPUs a VCPU can use" },
    3.38 +    { "vcpu-set", &main_vcpuset, "set the number of active VCPUs allowed for the domain" },
    3.39 +    { "list-vm", &main_list_vm, "list the VMs,without DOM0" },
    3.40 +    { "info", &main_info, "get information about Xen host" },
    3.41 +    { "sched-credit", &main_sched_credit, "get/set credit scheduler parameters" }
    3.42 +};
    3.43 +
    3.44 +int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
     4.1 --- a/tools/libxl/xl_cmdtable.h	Tue May 04 11:28:06 2010 +0100
     4.2 +++ b/tools/libxl/xl_cmdtable.h	Tue May 04 11:37:06 2010 +0100
     4.3 @@ -17,30 +17,8 @@
     4.4  struct cmd_spec {
     4.5      char *cmd_name;
     4.6      int (*cmd_impl)(int argc, char **argv);
     4.7 +    char *cmd_desc;
     4.8  };
     4.9  
    4.10 -struct cmd_spec cmd_table[] = {
    4.11 -    { "create", &main_create },
    4.12 -    { "list", &main_list },
    4.13 -    { "destroy", &main_destroy },
    4.14 -    { "pci-attach", &main_pciattach },
    4.15 -    { "pci-detach", &main_pcidetach },
    4.16 -    { "pci-list", &main_pcilist },
    4.17 -    { "pause", &main_pause },
    4.18 -    { "unpause", &main_unpause },
    4.19 -    { "console", &main_console },
    4.20 -    { "save", &main_save },
    4.21 -    { "restore", &main_restore },
    4.22 -    { "cd-insert", &main_cd_insert },
    4.23 -    { "cd-eject", &main_cd_eject },
    4.24 -    { "mem-set", &main_memset },
    4.25 -    { "button-press", &main_button_press },
    4.26 -    { "vcpu-list", &main_vcpulist },
    4.27 -    { "vcpu-pin", &main_vcpupin },
    4.28 -    { "vcpu-set", &main_vcpuset },
    4.29 -    { "list-vm", &main_list_vm },
    4.30 -    { "info", &main_info },
    4.31 -    { "sched-credit", &main_sched_credit },
    4.32 -};
    4.33 -
    4.34 -int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
    4.35 +extern struct cmd_spec cmd_table[];
    4.36 +extern int cmdtable_len;