Wei Yongjun
2010-May-10 07:08 UTC
[Xen-devel] [PATCH] xl: add missing migrate commands to command table
The command migrate and migrate_receive are missing in command table. This patch added them. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> diff -r bbf009817ffb -r ac61c50eb031 tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Fri May 07 19:22:28 2010 +0100 +++ b/tools/libxl/xl_cmdtable.c Mon May 10 14:50:48 2010 +0800 @@ -25,7 +25,9 @@ { "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" }, + { "migrate", &main_migrate, "save a domain state to restore later" }, { "restore", &main_restore, "restore a domain from a saved state" }, + { "migrate-receive", &main_migrate_receive, "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" }, _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Wei Yongjun
2010-May-10 07:10 UTC
[Xen-devel] [PATCH] xl: use help table to describe command help information
This patch generate a help table to describe command help information. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> diff -r ac61c50eb031 -r 9530370da103 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon May 10 14:50:48 2010 +0800 +++ b/tools/libxl/xl_cmdimpl.c Mon May 10 15:03:03 2010 +0800 @@ -1164,111 +1164,15 @@ for (i = 0; i < cmdtable_len; i++) printf(" %-20s%s\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"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-p Leave the domain paused after it is created.\n"); - printf("-c Connect to the console after the domain is created.\n"); - printf("-d Enable debug messages.\n"); - printf("-e Do not wait in the background for the death of the domain.\n"); - } else if(!strcmp(command, "list")) { - printf("Usage: xl list [-v] [Domain]\n\n"); - printf("List information about all/some domains.\n\n"); - } else if(!strcmp(command, "pci-attach")) { - printf("Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n\n"); - printf("Insert a new pass-through pci device.\n\n"); - } else if(!strcmp(command, "pci-detach")) { - printf("Usage: xl pci-detach <Domain> <BDF>\n\n"); - printf("Remove a domain''s pass-through pci device.\n\n"); - } else if(!strcmp(command, "pci-list")) { - printf("Usage: xl pci-list <Domain>\n\n"); - printf("List pass-through pci devices for a domain.\n\n"); - } else if(!strcmp(command, "pause")) { - printf("Usage: xl pause <Domain>\n\n"); - printf("Pause execution of a domain.\n\n"); - } else if(!strcmp(command, "unpause")) { - printf("Usage: xl unpause <Domain>\n\n"); - printf("Unpause a paused domain.\n\n"); - } else if(!strcmp(command, "save")) { - printf("Usage: xl save [options] <Domain> <CheckpointFile> [<ConfigFile>]\n\n"); - printf("Save a domain state to restore later.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-c Leave domain running after creating the snapshot.\n"); - } else if(!strcmp(command, "restore")) { - printf("Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n"); - printf("Restore a domain from a saved state.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-p Do not unpause domain after restoring it.\n"); - printf("-e Do not wait in the background for the death of the domain.\n"); - printf("-d Enable debug messages.\n"); - } else if(!strcmp(command, "migrate")) { - printf("Usage: xl migrate [options] <Domain> <host>\n\n"); - printf("Save a domain state to restore later.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-C <config> Send <config> instead of config file from creation.\n"); - printf("-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed to sh. If empty, run <host> instead of ssh <host> xl migrate-receive [-d -e]\n"); - printf("-e Do not wait in the background (on <host>) for the death of the domain.\n"); - } else if(!strcmp(command, "migrate-receive")) { - printf("Usage: xl migrate-receive - for internal use only"); - } else if(!strcmp(command, "restore")) { - printf("Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n"); - printf("Restore a domain from a saved state.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-O Old (configless) xl save format.\n"); - printf("-p Do not unpause domain after restoring it.\n"); - printf("-e Do not wait in the background for the death of the domain.\n"); - } else if(!strcmp(command, "destroy")) { - printf("Usage: xl destroy <Domain>\n\n"); - printf("Terminate a domain immediately.\n\n"); - } else if (!strcmp(command, "console")) { - printf("Usage: xl console <Domain>\n\n"); - printf("Attach to domain''s console.\n\n"); - } else if (!strcmp(command, "cd-insert")) { - printf("Usage: xl cd-insert <Domain> <VirtualDevice> <type:path>\n\n"); - printf("Insert a cdrom into a guest''s cd drive.\n\n"); - } else if (!strcmp(command, "cd-eject")) { - printf("Usage: xl cd-eject <Domain> <VirtualDevice>\n\n"); - printf("Eject a cdrom from a guest''s cd drive.\n\n"); - } else if (!strcmp(command, "mem-set")) { - printf("Usage: xl mem-set <Domain> <MemKB>\n\n"); - printf("Set the current memory usage for a domain.\n\n"); - } else if (!strcmp(command, "button-press")) { - printf("Usage: xl button-press <Domain> <Button>\n\n"); - printf("Indicate <Button> press to a domain.\n"); - printf("<Button> may be ''power'' or ''sleep''.\n\n"); - } else if (!strcmp(command, "vcpu-list")) { - printf("Usage: xl vcpu-list [Domain, ...]\n\n"); - printf("List the VCPUs for all/some domains.\n\n"); - } else if (!strcmp(command, "vcpu-pin")) { - printf("Usage: xl vcpu-pin <Domain> <VCPU|all> <CPUs|all>\n\n"); - printf("Set which CPUs a VCPU can use.\n\n"); - } else if (!strcmp(command, "vcpu-set")) { - printf("Usage: xl vcpu-set <Domain> <vCPUs>\n\n"); - printf("Set the number of active VCPUs for allowed for the domain.\n\n"); - } else if(!strcmp(command, "info")) { - printf("Usage: xl info\n\n"); - printf("Get information about Xen host.\n\n"); - } else if (!strcmp(command, "sched-credit")) { - printf("Usage: xl sched-credit [-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]\n\n"); - printf("Get/set credit scheduler parameters.\n"); - printf(" -d DOMAIN, --domain=DOMAIN Domain to modify\n"); - printf(" -w WEIGHT, --weight=WEIGHT Weight (int)\n"); - printf(" -c CAP, --cap=CAP Cap (int)\n"); - } 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"); - } else if (!strcmp(command, "rename")) { - printf("Usage: xl rename <Domain> <NewDomainName>\n\n"); - printf("Rename a domain.\n"); + } else { + for (i = 0; cmd_htable[i].cmd_name != NULL; i++) + if (!strcmp(command, cmd_htable[i].cmd_name)) { + printf("%s", cmd_htable[i].cmd_help); + break; + } + + if (!cmd_htable[i].cmd_name) + printf("no help information for command %s\n", command); } } diff -r ac61c50eb031 -r 9530370da103 tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Mon May 10 14:50:48 2010 +0800 +++ b/tools/libxl/xl_cmdtable.c Mon May 10 15:03:03 2010 +0800 @@ -14,6 +14,142 @@ #include "xl_cmdtable.h" +struct cmd_help cmd_htable[] = { + { "create", + "Usage: xl create <ConfigFile> [options] [vars]\n\n" + "Create a domain based on <ConfigFile>.\n\n" + "Options:\n\n" + "-h Print this help.\n" + "-p Leave the domain paused after it is created.\n" + "-c Connect to the console after the domain is created.\n" + "-d Enable debug messages.\n" + "-e Do not wait in the background for the death of the domain.\n" + }, + { "list", + "Usage: xl list [-v] [Domain]\n\n" + "List information about all/some domains.\n\n" + }, + { "pci-attach", + "Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n\n" + "Insert a new pass-through pci device.\n\n" + }, + { "pci-detach", + "Usage: xl pci-detach <Domain> <BDF>\n\n" + "Remove a domain''s pass-through pci device.\n\n" + }, + { "pci-list", + "Usage: xl pci-list <Domain>\n\n" + "List pass-through pci devices for a domain.\n\n" + }, + { "pause", + "Usage: xl pause <Domain>\n\n" + "Pause execution of a domain.\n\n" + }, + { "unpause", + "Usage: xl unpause <Domain>\n\n" + "Unpause a paused domain.\n\n" + }, + { "save", + "Usage: xl save [options] <Domain> <CheckpointFile> [<ConfigFile>]\n\n" + "Save a domain state to restore later.\n\n" + "Options:\n\n" + "-h Print this help.\n" + "-c Leave domain running after creating the snapshot.\n" + }, + { "restore", + "Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n" + "Restore a domain from a saved state.\n\n" + "Options:\n\n" + "-h Print this help.\n" + "-p Do not unpause domain after restoring it.\n" + "-e Do not wait in the background for the death of the domain.\n" + "-d Enable debug messages.\n" + }, + { "migrate", + "Usage: xl migrate [options] <Domain> <host>\n\n" + "Save a domain state to restore later.\n\n" + "Options:\n\n" + "-h Print this help.\n" + "-C <config> Send <config> instead of config file from creation.\n" + "-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed to sh." + " If empty, run <host> instead of ssh <host> xl migrate-receive [-d -e]\n" + "-e Do not wait in the background (on <host>) for the death of the domain.\n" + }, + { "migrate-receive", + "Usage: xl migrate-receive - for internal use only" + }, + { "restore", + "Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n" + "Restore a domain from a saved state.\n\n" + "Options:\n\n" + "-h Print this help.\n" + "-O Old (configless) xl save format.\n" + "-p Do not unpause domain after restoring it.\n" + "-e Do not wait in the background for the death of the domain.\n" + }, + { "destroy", + "Usage: xl destroy <Domain>\n\n" + "Terminate a domain immediately.\n\n" + }, + { "console", + "Usage: xl console <Domain>\n\n" + "Attach to domain''s console.\n\n" + }, + { "cd-insert", + "Usage: xl cd-insert <Domain> <VirtualDevice> <type:path>\n\n" + "Insert a cdrom into a guest''s cd drive.\n\n" + }, + { "cd-eject", + "Usage: xl cd-eject <Domain> <VirtualDevice>\n\n" + "Eject a cdrom from a guest''s cd drive.\n\n" + }, + { "mem-set", + "Usage: xl mem-set <Domain> <MemKB>\n\n" + "Set the current memory usage for a domain.\n\n" + }, + { "button-press", + "Usage: xl button-press <Domain> <Button>\n\n" + "Indicate <Button> press to a domain.\n" + "<Button> may be ''power'' or ''sleep''.\n\n" + }, + { "vcpu-list", + "Usage: xl vcpu-list [Domain, ...]\n\n" + "List the VCPUs for all/some domains.\n\n" + }, + { "vcpu-pin", + "Usage: xl vcpu-pin <Domain> <VCPU|all> <CPUs|all>\n\n" + "Set which CPUs a VCPU can use.\n\n" + }, + { "vcpu-set", + "Usage: xl vcpu-set <Domain> <vCPUs>\n\n" + "Set the number of active VCPUs for allowed for the domain.\n\n" + }, + { "info", + "Usage: xl info\n\n" + "Get information about Xen host.\n\n" + }, + { "sched-credit", + "Usage: xl sched-credit [-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]\n\n" + "Get/set credit scheduler parameters.\n" + " -d DOMAIN, --domain=DOMAIN Domain to modify\n" + " -w WEIGHT, --weight=WEIGHT Weight (int)\n" + " -c CAP, --cap=CAP Cap (int)\n" + }, + { "domid", + "Usage: xl domid <DomainName>\n\n" + "Convert a domain name to domain id.\n" + }, + { "domname", + "Usage: xl domname <DomainId>\n\n" + "Convert a domain id to domain name.\n" + }, + { "rename", + "Usage: xl rename <Domain> <NewDomainName>\n\n" + "Rename a domain.\n" + }, + { /* NULL */ }, +}; + struct cmd_spec cmd_table[] = { { "create", &main_create, "create a domain from config file <filename>" }, { "list", &main_list, "list information about all domains" }, diff -r ac61c50eb031 -r 9530370da103 tools/libxl/xl_cmdtable.h --- a/tools/libxl/xl_cmdtable.h Mon May 10 14:50:48 2010 +0800 +++ b/tools/libxl/xl_cmdtable.h Mon May 10 15:03:03 2010 +0800 @@ -14,11 +14,17 @@ #include "xl_cmdimpl.h" +struct cmd_help { + char *cmd_name; + char *cmd_help; +}; + struct cmd_spec { char *cmd_name; int (*cmd_impl)(int argc, char **argv); char *cmd_desc; }; +extern struct cmd_help cmd_htable[]; extern struct cmd_spec cmd_table[]; extern int cmdtable_len; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Juergen Gross
2010-May-10 07:31 UTC
Re: [Xen-devel] [PATCH] xl: use help table to describe command help information
On 05/10/2010 09:10 AM, Wei Yongjun wrote:> This patch generate a help table to describe command help > information.Wouldn''t it be better to include the help information in the command table? There you already have the command description which is part of the help text as well. Usage information should be another item in the table then. Juergen -- Juergen Gross Principal Developer Operating Systems TSP ES&S SWE OS6 Telephone: +49 (0) 89 3222 2967 Fujitsu Technology Solutions e-mail: juergen.gross@ts.fujitsu.com Domagkstr. 28 Internet: ts.fujitsu.com D-80807 Muenchen Company details: ts.fujitsu.com/imprint.html _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Wei Yongjun
2010-May-11 02:18 UTC
[Xen-devel] [PATCHv2] xl: use help table to describe command help information
# HG changeset patch # User Wei Yongjun <yjwei@cn.fujitsu.com> # Date 1273544009 -28800 # Node ID 3b082b6199edbe1af1c61c778d44028c499e5320 # Parent f8f668ad3841f7596c5085546961d9c7acf53ace xl: use help table to describe command help information This patch generate a help table to describe command help information. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> diff -r f8f668ad3841 -r 3b082b6199ed tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Mon May 10 14:50:48 2010 +0800 +++ b/tools/libxl/xl_cmdimpl.c Tue May 11 10:13:29 2010 +0800 @@ -1164,111 +1164,16 @@ for (i = 0; i < cmdtable_len; i++) printf(" %-20s%s\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"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-p Leave the domain paused after it is created.\n"); - printf("-c Connect to the console after the domain is created.\n"); - printf("-d Enable debug messages.\n"); - printf("-e Do not wait in the background for the death of the domain.\n"); - } else if(!strcmp(command, "list")) { - printf("Usage: xl list [-v] [Domain]\n\n"); - printf("List information about all/some domains.\n\n"); - } else if(!strcmp(command, "pci-attach")) { - printf("Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n\n"); - printf("Insert a new pass-through pci device.\n\n"); - } else if(!strcmp(command, "pci-detach")) { - printf("Usage: xl pci-detach <Domain> <BDF>\n\n"); - printf("Remove a domain''s pass-through pci device.\n\n"); - } else if(!strcmp(command, "pci-list")) { - printf("Usage: xl pci-list <Domain>\n\n"); - printf("List pass-through pci devices for a domain.\n\n"); - } else if(!strcmp(command, "pause")) { - printf("Usage: xl pause <Domain>\n\n"); - printf("Pause execution of a domain.\n\n"); - } else if(!strcmp(command, "unpause")) { - printf("Usage: xl unpause <Domain>\n\n"); - printf("Unpause a paused domain.\n\n"); - } else if(!strcmp(command, "save")) { - printf("Usage: xl save [options] <Domain> <CheckpointFile> [<ConfigFile>]\n\n"); - printf("Save a domain state to restore later.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-c Leave domain running after creating the snapshot.\n"); - } else if(!strcmp(command, "restore")) { - printf("Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n"); - printf("Restore a domain from a saved state.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-p Do not unpause domain after restoring it.\n"); - printf("-e Do not wait in the background for the death of the domain.\n"); - printf("-d Enable debug messages.\n"); - } else if(!strcmp(command, "migrate")) { - printf("Usage: xl migrate [options] <Domain> <host>\n\n"); - printf("Save a domain state to restore later.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-C <config> Send <config> instead of config file from creation.\n"); - printf("-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed to sh. If empty, run <host> instead of ssh <host> xl migrate-receive [-d -e]\n"); - printf("-e Do not wait in the background (on <host>) for the death of the domain.\n"); - } else if(!strcmp(command, "migrate-receive")) { - printf("Usage: xl migrate-receive - for internal use only"); - } else if(!strcmp(command, "restore")) { - printf("Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n"); - printf("Restore a domain from a saved state.\n\n"); - printf("Options:\n\n"); - printf("-h Print this help.\n"); - printf("-O Old (configless) xl save format.\n"); - printf("-p Do not unpause domain after restoring it.\n"); - printf("-e Do not wait in the background for the death of the domain.\n"); - } else if(!strcmp(command, "destroy")) { - printf("Usage: xl destroy <Domain>\n\n"); - printf("Terminate a domain immediately.\n\n"); - } else if (!strcmp(command, "console")) { - printf("Usage: xl console <Domain>\n\n"); - printf("Attach to domain''s console.\n\n"); - } else if (!strcmp(command, "cd-insert")) { - printf("Usage: xl cd-insert <Domain> <VirtualDevice> <type:path>\n\n"); - printf("Insert a cdrom into a guest''s cd drive.\n\n"); - } else if (!strcmp(command, "cd-eject")) { - printf("Usage: xl cd-eject <Domain> <VirtualDevice>\n\n"); - printf("Eject a cdrom from a guest''s cd drive.\n\n"); - } else if (!strcmp(command, "mem-set")) { - printf("Usage: xl mem-set <Domain> <MemKB>\n\n"); - printf("Set the current memory usage for a domain.\n\n"); - } else if (!strcmp(command, "button-press")) { - printf("Usage: xl button-press <Domain> <Button>\n\n"); - printf("Indicate <Button> press to a domain.\n"); - printf("<Button> may be ''power'' or ''sleep''.\n\n"); - } else if (!strcmp(command, "vcpu-list")) { - printf("Usage: xl vcpu-list [Domain, ...]\n\n"); - printf("List the VCPUs for all/some domains.\n\n"); - } else if (!strcmp(command, "vcpu-pin")) { - printf("Usage: xl vcpu-pin <Domain> <VCPU|all> <CPUs|all>\n\n"); - printf("Set which CPUs a VCPU can use.\n\n"); - } else if (!strcmp(command, "vcpu-set")) { - printf("Usage: xl vcpu-set <Domain> <vCPUs>\n\n"); - printf("Set the number of active VCPUs for allowed for the domain.\n\n"); - } else if(!strcmp(command, "info")) { - printf("Usage: xl info\n\n"); - printf("Get information about Xen host.\n\n"); - } else if (!strcmp(command, "sched-credit")) { - printf("Usage: xl sched-credit [-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]\n\n"); - printf("Get/set credit scheduler parameters.\n"); - printf(" -d DOMAIN, --domain=DOMAIN Domain to modify\n"); - printf(" -w WEIGHT, --weight=WEIGHT Weight (int)\n"); - printf(" -c CAP, --cap=CAP Cap (int)\n"); - } 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"); - } else if (!strcmp(command, "rename")) { - printf("Usage: xl rename <Domain> <NewDomainName>\n\n"); - printf("Rename a domain.\n"); + } else { + for (i = 0; i < cmdtable_len; i++) + if (!strcmp(command, cmd_table[i].cmd_name)) { + printf("%s\n%s.\n\n", cmd_table[i].cmd_usage, cmd_table[i].cmd_desc); + if (cmd_table[i].cmd_option) + printf("%s", cmd_table[i].cmd_option); + return; + } + + printf("command not implemented\n"); } } diff -r f8f668ad3841 -r 3b082b6199ed tools/libxl/xl_cmdtable.c --- a/tools/libxl/xl_cmdtable.c Mon May 10 14:50:48 2010 +0800 +++ b/tools/libxl/xl_cmdtable.c Tue May 11 10:13:29 2010 +0800 @@ -15,32 +15,162 @@ #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" }, - { "migrate", &main_migrate, "save a domain state to restore later" }, - { "restore", &main_restore, "restore a domain from a saved state" }, - { "migrate-receive", &main_migrate_receive, "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" }, - { "domid", &main_domid, "convert a domain name to domain id"}, - { "domname", &main_domname, "convert a domain id to domain name"}, - { "rename", &main_rename, "rename a domain"}, + { "create", + &main_create, + "Create a domain from config file <filename>", + "Usage: xl create <ConfigFile> [options] [vars]\n", + "Options:\n\n" + "-h Print this help.\n" + "-p Leave the domain paused after it is created.\n" + "-c Connect to the console after the domain is created.\n" + "-d Enable debug messages.\n" + "-e Do not wait in the background for the death of the domain.\n" + }, + { "list", + &main_list, + "List information about all/some domains", + "Usage: xl list [-v] [Domain]\n", + }, + { "destroy", + &main_destroy, + "Terminate a domain immediately", + "Usage: xl destroy <Domain>\n", + }, + { "pci-attach", + &main_pciattach, + "Insert a new pass-through pci device", + "Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n", + }, + { "pci-detach", + &main_pcidetach, + "Remove a domain''s pass-through pci device", + "Usage: xl pci-detach <Domain> <BDF>\n", + }, + { "pci-list", + &main_pcilist, + "List pass-through pci devices for a domain", + "Usage: xl pci-list <Domain>\n", + }, + { "pause", + &main_pause, + "Pause execution of a domain", + "Usage: xl pause <Domain>\n", + }, + { "unpause", + &main_unpause, + "Unpause a paused domain", + "Usage: xl unpause <Domain>\n", + }, + { "console", + &main_console, + "Attach to domain''s console", + "Usage: xl console <Domain>\n", + }, + { "save", + &main_save, + "Save a domain state to restore later", + "Usage: xl save [options] <Domain> <CheckpointFile> [<ConfigFile>]\n", + "Options:\n\n" + "-h Print this help.\n" + "-c Leave domain running after creating the snapshot.\n" + }, + { "migrate", + &main_migrate, + "Save a domain state to restore later", + "Usage: xl migrate [options] <Domain> <host>\n", + "Options:\n\n" + "-h Print this help.\n" + "-C <config> Send <config> instead of config file from creation.\n" + "-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed\n" + " to sh. If empty, run <host> instead of ssh <host> xl\n" + " migrate-receive [-d -e]\n" + "-e Do not wait in the background (on <host>) for the death\n" + " of the domain.\n" + }, + { "restore", + &main_restore, + "Restore a domain from a saved state", + "Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n", + "Options:\n\n" + "-h Print this help.\n" + "-p Do not unpause domain after restoring it.\n" + "-e Do not wait in the background for the death of the domain.\n" + "-d Enable debug messages.\n" + }, + { "migrate-receive", + &main_migrate_receive, + "Restore a domain from a saved state", + "Usage: xl migrate-receive - for internal use only\n", + }, + { "cd-insert", + &main_cd_insert, + "Insert a cdrom into a guest''s cd drive", + "Usage: xl cd-insert <Domain> <VirtualDevice> <type:path>\n", + }, + { "cd-eject", + &main_cd_eject, + "Eject a cdrom from a guest''s cd drive", + "Usage: xl cd-eject <Domain> <VirtualDevice>\n", + }, + { "mem-set", + &main_memset, + "Set the current memory usage for a domain", + "Usage: xl mem-set <Domain> <MemKB>\n", + }, + { "button-press", + &main_button_press, + "Indicate an ACPI button press to the domain", + "Usage: xl button-press <Domain> <Button>\n\n", + "<Button> may be ''power'' or ''sleep''.\n" + }, + { "vcpu-list", + &main_vcpulist, + "List the VCPUs for all/some domains", + "Usage: xl vcpu-list [Domain, ...]\n", + }, + { "vcpu-pin", + &main_vcpupin, + "Set which CPUs a VCPU can use", + "Usage: xl vcpu-pin <Domain> <VCPU|all> <CPUs|all>\n", + }, + { "vcpu-set", + &main_vcpuset, + "Set the number of active VCPUs allowed for the domain", + "Usage: xl vcpu-set <Domain> <vCPUs>\n", + }, + { "list-vm", + &main_list_vm, + "List the VMs,without DOM0", + "Usage: xl list-vm\n", + }, + { "info", + &main_info, + "Get information about Xen host", + "Usage: xl info\n", + }, + { "sched-credit", + &main_sched_credit, + "Get/set credit scheduler parameters", + "Usage: xl sched-credit [-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]\n", + " -d DOMAIN, --domain=DOMAIN Domain to modify\n" + " -w WEIGHT, --weight=WEIGHT Weight (int)\n" + " -c CAP, --cap=CAP Cap (int)\n" + }, + { "domid", + &main_domid, + "Convert a domain name to domain id", + "Usage: xl domid <DomainName>\n", + }, + { "domname", + &main_domname, + "Convert a domain id to domain name", + "Usage: xl domname <DomainId>\n", + }, + { "rename", + &main_rename, + "Rename a domain", + "Usage: xl rename <Domain> <NewDomainName>\n", + }, }; int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec); diff -r f8f668ad3841 -r 3b082b6199ed tools/libxl/xl_cmdtable.h --- a/tools/libxl/xl_cmdtable.h Mon May 10 14:50:48 2010 +0800 +++ b/tools/libxl/xl_cmdtable.h Tue May 11 10:13:29 2010 +0800 @@ -18,6 +18,8 @@ char *cmd_name; int (*cmd_impl)(int argc, char **argv); char *cmd_desc; + char *cmd_usage; + char *cmd_option; }; extern struct cmd_spec cmd_table[]; _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Zhigang Wang
2010-May-11 02:59 UTC
Re: [Xen-devel] [PATCHv2] xl: use help table to describe command help information
Excellent! It''s the right design. Thanks, zhigang On 05/11/2010 10:18 AM, Wei Yongjun wrote:> # HG changeset patch > # User Wei Yongjun <yjwei@cn.fujitsu.com> > # Date 1273544009 -28800 > # Node ID 3b082b6199edbe1af1c61c778d44028c499e5320 > # Parent f8f668ad3841f7596c5085546961d9c7acf53ace > xl: use help table to describe command help information > > This patch generate a help table to describe command help > information. > > Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> > > diff -r f8f668ad3841 -r 3b082b6199ed tools/libxl/xl_cmdimpl.c > --- a/tools/libxl/xl_cmdimpl.c Mon May 10 14:50:48 2010 +0800 > +++ b/tools/libxl/xl_cmdimpl.c Tue May 11 10:13:29 2010 +0800 > @@ -1164,111 +1164,16 @@ > for (i = 0; i < cmdtable_len; i++) > printf(" %-20s%s\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"); > - printf("Options:\n\n"); > - printf("-h Print this help.\n"); > - printf("-p Leave the domain paused after it is created.\n"); > - printf("-c Connect to the console after the domain is created.\n"); > - printf("-d Enable debug messages.\n"); > - printf("-e Do not wait in the background for the death of the domain.\n"); > - } else if(!strcmp(command, "list")) { > - printf("Usage: xl list [-v] [Domain]\n\n"); > - printf("List information about all/some domains.\n\n"); > - } else if(!strcmp(command, "pci-attach")) { > - printf("Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n\n"); > - printf("Insert a new pass-through pci device.\n\n"); > - } else if(!strcmp(command, "pci-detach")) { > - printf("Usage: xl pci-detach <Domain> <BDF>\n\n"); > - printf("Remove a domain''s pass-through pci device.\n\n"); > - } else if(!strcmp(command, "pci-list")) { > - printf("Usage: xl pci-list <Domain>\n\n"); > - printf("List pass-through pci devices for a domain.\n\n"); > - } else if(!strcmp(command, "pause")) { > - printf("Usage: xl pause <Domain>\n\n"); > - printf("Pause execution of a domain.\n\n"); > - } else if(!strcmp(command, "unpause")) { > - printf("Usage: xl unpause <Domain>\n\n"); > - printf("Unpause a paused domain.\n\n"); > - } else if(!strcmp(command, "save")) { > - printf("Usage: xl save [options] <Domain> <CheckpointFile> [<ConfigFile>]\n\n"); > - printf("Save a domain state to restore later.\n\n"); > - printf("Options:\n\n"); > - printf("-h Print this help.\n"); > - printf("-c Leave domain running after creating the snapshot.\n"); > - } else if(!strcmp(command, "restore")) { > - printf("Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n"); > - printf("Restore a domain from a saved state.\n\n"); > - printf("Options:\n\n"); > - printf("-h Print this help.\n"); > - printf("-p Do not unpause domain after restoring it.\n"); > - printf("-e Do not wait in the background for the death of the domain.\n"); > - printf("-d Enable debug messages.\n"); > - } else if(!strcmp(command, "migrate")) { > - printf("Usage: xl migrate [options] <Domain> <host>\n\n"); > - printf("Save a domain state to restore later.\n\n"); > - printf("Options:\n\n"); > - printf("-h Print this help.\n"); > - printf("-C <config> Send <config> instead of config file from creation.\n"); > - printf("-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed to sh. If empty, run <host> instead of ssh <host> xl migrate-receive [-d -e]\n"); > - printf("-e Do not wait in the background (on <host>) for the death of the domain.\n"); > - } else if(!strcmp(command, "migrate-receive")) { > - printf("Usage: xl migrate-receive - for internal use only"); > - } else if(!strcmp(command, "restore")) { > - printf("Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n\n"); > - printf("Restore a domain from a saved state.\n\n"); > - printf("Options:\n\n"); > - printf("-h Print this help.\n"); > - printf("-O Old (configless) xl save format.\n"); > - printf("-p Do not unpause domain after restoring it.\n"); > - printf("-e Do not wait in the background for the death of the domain.\n"); > - } else if(!strcmp(command, "destroy")) { > - printf("Usage: xl destroy <Domain>\n\n"); > - printf("Terminate a domain immediately.\n\n"); > - } else if (!strcmp(command, "console")) { > - printf("Usage: xl console <Domain>\n\n"); > - printf("Attach to domain''s console.\n\n"); > - } else if (!strcmp(command, "cd-insert")) { > - printf("Usage: xl cd-insert <Domain> <VirtualDevice> <type:path>\n\n"); > - printf("Insert a cdrom into a guest''s cd drive.\n\n"); > - } else if (!strcmp(command, "cd-eject")) { > - printf("Usage: xl cd-eject <Domain> <VirtualDevice>\n\n"); > - printf("Eject a cdrom from a guest''s cd drive.\n\n"); > - } else if (!strcmp(command, "mem-set")) { > - printf("Usage: xl mem-set <Domain> <MemKB>\n\n"); > - printf("Set the current memory usage for a domain.\n\n"); > - } else if (!strcmp(command, "button-press")) { > - printf("Usage: xl button-press <Domain> <Button>\n\n"); > - printf("Indicate <Button> press to a domain.\n"); > - printf("<Button> may be ''power'' or ''sleep''.\n\n"); > - } else if (!strcmp(command, "vcpu-list")) { > - printf("Usage: xl vcpu-list [Domain, ...]\n\n"); > - printf("List the VCPUs for all/some domains.\n\n"); > - } else if (!strcmp(command, "vcpu-pin")) { > - printf("Usage: xl vcpu-pin <Domain> <VCPU|all> <CPUs|all>\n\n"); > - printf("Set which CPUs a VCPU can use.\n\n"); > - } else if (!strcmp(command, "vcpu-set")) { > - printf("Usage: xl vcpu-set <Domain> <vCPUs>\n\n"); > - printf("Set the number of active VCPUs for allowed for the domain.\n\n"); > - } else if(!strcmp(command, "info")) { > - printf("Usage: xl info\n\n"); > - printf("Get information about Xen host.\n\n"); > - } else if (!strcmp(command, "sched-credit")) { > - printf("Usage: xl sched-credit [-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]\n\n"); > - printf("Get/set credit scheduler parameters.\n"); > - printf(" -d DOMAIN, --domain=DOMAIN Domain to modify\n"); > - printf(" -w WEIGHT, --weight=WEIGHT Weight (int)\n"); > - printf(" -c CAP, --cap=CAP Cap (int)\n"); > - } 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"); > - } else if (!strcmp(command, "rename")) { > - printf("Usage: xl rename <Domain> <NewDomainName>\n\n"); > - printf("Rename a domain.\n"); > + } else { > + for (i = 0; i < cmdtable_len; i++) > + if (!strcmp(command, cmd_table[i].cmd_name)) { > + printf("%s\n%s.\n\n", cmd_table[i].cmd_usage, cmd_table[i].cmd_desc); > + if (cmd_table[i].cmd_option) > + printf("%s", cmd_table[i].cmd_option); > + return; > + } > + > + printf("command not implemented\n"); > } > } > > diff -r f8f668ad3841 -r 3b082b6199ed tools/libxl/xl_cmdtable.c > --- a/tools/libxl/xl_cmdtable.c Mon May 10 14:50:48 2010 +0800 > +++ b/tools/libxl/xl_cmdtable.c Tue May 11 10:13:29 2010 +0800 > @@ -15,32 +15,162 @@ > #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" }, > - { "migrate", &main_migrate, "save a domain state to restore later" }, > - { "restore", &main_restore, "restore a domain from a saved state" }, > - { "migrate-receive", &main_migrate_receive, "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" }, > - { "domid", &main_domid, "convert a domain name to domain id"}, > - { "domname", &main_domname, "convert a domain id to domain name"}, > - { "rename", &main_rename, "rename a domain"}, > + { "create", > + &main_create, > + "Create a domain from config file <filename>", > + "Usage: xl create <ConfigFile> [options] [vars]\n", > + "Options:\n\n" > + "-h Print this help.\n" > + "-p Leave the domain paused after it is created.\n" > + "-c Connect to the console after the domain is created.\n" > + "-d Enable debug messages.\n" > + "-e Do not wait in the background for the death of the domain.\n" > + }, > + { "list", > + &main_list, > + "List information about all/some domains", > + "Usage: xl list [-v] [Domain]\n", > + }, > + { "destroy", > + &main_destroy, > + "Terminate a domain immediately", > + "Usage: xl destroy <Domain>\n", > + }, > + { "pci-attach", > + &main_pciattach, > + "Insert a new pass-through pci device", > + "Usage: xl pci-attach <Domain> <BDF> [Virtual Slot]\n", > + }, > + { "pci-detach", > + &main_pcidetach, > + "Remove a domain''s pass-through pci device", > + "Usage: xl pci-detach <Domain> <BDF>\n", > + }, > + { "pci-list", > + &main_pcilist, > + "List pass-through pci devices for a domain", > + "Usage: xl pci-list <Domain>\n", > + }, > + { "pause", > + &main_pause, > + "Pause execution of a domain", > + "Usage: xl pause <Domain>\n", > + }, > + { "unpause", > + &main_unpause, > + "Unpause a paused domain", > + "Usage: xl unpause <Domain>\n", > + }, > + { "console", > + &main_console, > + "Attach to domain''s console", > + "Usage: xl console <Domain>\n", > + }, > + { "save", > + &main_save, > + "Save a domain state to restore later", > + "Usage: xl save [options] <Domain> <CheckpointFile> [<ConfigFile>]\n", > + "Options:\n\n" > + "-h Print this help.\n" > + "-c Leave domain running after creating the snapshot.\n" > + }, > + { "migrate", > + &main_migrate, > + "Save a domain state to restore later", > + "Usage: xl migrate [options] <Domain> <host>\n", > + "Options:\n\n" > + "-h Print this help.\n" > + "-C <config> Send <config> instead of config file from creation.\n" > + "-s <sshcommand> Use <sshcommand> instead of ssh. String will be passed\n" > + " to sh. If empty, run <host> instead of ssh <host> xl\n" > + " migrate-receive [-d -e]\n" > + "-e Do not wait in the background (on <host>) for the death\n" > + " of the domain.\n" > + }, > + { "restore", > + &main_restore, > + "Restore a domain from a saved state", > + "Usage: xl restore [options] [<ConfigFile>] <CheckpointFile>\n", > + "Options:\n\n" > + "-h Print this help.\n" > + "-p Do not unpause domain after restoring it.\n" > + "-e Do not wait in the background for the death of the domain.\n" > + "-d Enable debug messages.\n" > + }, > + { "migrate-receive", > + &main_migrate_receive, > + "Restore a domain from a saved state", > + "Usage: xl migrate-receive - for internal use only\n", > + }, > + { "cd-insert", > + &main_cd_insert, > + "Insert a cdrom into a guest''s cd drive", > + "Usage: xl cd-insert <Domain> <VirtualDevice> <type:path>\n", > + }, > + { "cd-eject", > + &main_cd_eject, > + "Eject a cdrom from a guest''s cd drive", > + "Usage: xl cd-eject <Domain> <VirtualDevice>\n", > + }, > + { "mem-set", > + &main_memset, > + "Set the current memory usage for a domain", > + "Usage: xl mem-set <Domain> <MemKB>\n", > + }, > + { "button-press", > + &main_button_press, > + "Indicate an ACPI button press to the domain", > + "Usage: xl button-press <Domain> <Button>\n\n", > + "<Button> may be ''power'' or ''sleep''.\n" > + }, > + { "vcpu-list", > + &main_vcpulist, > + "List the VCPUs for all/some domains", > + "Usage: xl vcpu-list [Domain, ...]\n", > + }, > + { "vcpu-pin", > + &main_vcpupin, > + "Set which CPUs a VCPU can use", > + "Usage: xl vcpu-pin <Domain> <VCPU|all> <CPUs|all>\n", > + }, > + { "vcpu-set", > + &main_vcpuset, > + "Set the number of active VCPUs allowed for the domain", > + "Usage: xl vcpu-set <Domain> <vCPUs>\n", > + }, > + { "list-vm", > + &main_list_vm, > + "List the VMs,without DOM0", > + "Usage: xl list-vm\n", > + }, > + { "info", > + &main_info, > + "Get information about Xen host", > + "Usage: xl info\n", > + }, > + { "sched-credit", > + &main_sched_credit, > + "Get/set credit scheduler parameters", > + "Usage: xl sched-credit [-d <Domain> [-w[=WEIGHT]|-c[=CAP]]]\n", > + " -d DOMAIN, --domain=DOMAIN Domain to modify\n" > + " -w WEIGHT, --weight=WEIGHT Weight (int)\n" > + " -c CAP, --cap=CAP Cap (int)\n" > + }, > + { "domid", > + &main_domid, > + "Convert a domain name to domain id", > + "Usage: xl domid <DomainName>\n", > + }, > + { "domname", > + &main_domname, > + "Convert a domain id to domain name", > + "Usage: xl domname <DomainId>\n", > + }, > + { "rename", > + &main_rename, > + "Rename a domain", > + "Usage: xl rename <Domain> <NewDomainName>\n", > + }, > }; > > int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec); > diff -r f8f668ad3841 -r 3b082b6199ed tools/libxl/xl_cmdtable.h > --- a/tools/libxl/xl_cmdtable.h Mon May 10 14:50:48 2010 +0800 > +++ b/tools/libxl/xl_cmdtable.h Tue May 11 10:13:29 2010 +0800 > @@ -18,6 +18,8 @@ > char *cmd_name; > int (*cmd_impl)(int argc, char **argv); > char *cmd_desc; > + char *cmd_usage; > + char *cmd_option; > }; > > extern struct cmd_spec cmd_table[]; > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Stefano Stabellini
2010-May-11 11:06 UTC
Re: [Xen-devel] [PATCHv2] xl: use help table to describe command help information
On Tue, 11 May 2010, Wei Yongjun wrote:> # HG changeset patch > # User Wei Yongjun <yjwei@cn.fujitsu.com> > # Date 1273544009 -28800 > # Node ID 3b082b6199edbe1af1c61c778d44028c499e5320 > # Parent f8f668ad3841f7596c5085546961d9c7acf53ace > xl: use help table to describe command help information > > This patch generate a help table to describe command help > information. > > Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel