From: Zhigang Wang <zhigang.x.wang@oracle.com>
To: Wei Yongjun <yjwei@cn.fujitsu.com>
Cc: Juergen Gross <juergen.gross@ts.fujitsu.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCHv2] xl: use help table to describe command help information
Date: Tue, 11 May 2010 10:59:00 +0800 [thread overview]
Message-ID: <4BE8C7F4.30305@oracle.com> (raw)
In-Reply-To: <4BE8BE70.8080602@cn.fujitsu.com>
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
next prev parent reply other threads:[~2010-05-11 2:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 7:08 [PATCH] xl: add missing migrate commands to command table Wei Yongjun
2010-05-10 7:10 ` [PATCH] xl: use help table to describe command help information Wei Yongjun
2010-05-10 7:31 ` Juergen Gross
2010-05-11 2:18 ` [PATCHv2] " Wei Yongjun
2010-05-11 2:59 ` Zhigang Wang [this message]
2010-05-11 11:06 ` Stefano Stabellini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BE8C7F4.30305@oracle.com \
--to=zhigang.x.wang@oracle.com \
--cc=juergen.gross@ts.fujitsu.com \
--cc=xen-devel@lists.xensource.com \
--cc=yjwei@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.