xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3]xl: Add command description to command table
@ 2010-04-29  9:24 Yang Hongyang
  2010-05-04 16:10 ` Ian Jackson
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Hongyang @ 2010-04-29  9:24 UTC (permalink / raw)
  To: xen-devel

Add command description to command table

Signed-off-by: Yang Hongyang <yanghy@cn.fujitsu.com>

diff -r b695c51b8345 -r 25e930534a5d tools/libxl/Makefile
--- a/tools/libxl/Makefile	Thu Apr 29 23:07:31 2010 +0800
+++ b/tools/libxl/Makefile	Fri Apr 30 00:16:19 2010 +0800
@@ -73,7 +73,10 @@
 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
diff -r b695c51b8345 -r 25e930534a5d tools/libxl/xl.c
--- a/tools/libxl/xl.c	Thu Apr 29 23:07:31 2010 +0800
+++ b/tools/libxl/xl.c	Fri Apr 30 00:16:19 2010 +0800
@@ -31,6 +31,9 @@
 #include "xl_cmdimpl.h"
 #include "xl_cmdtable.h"
 
+extern struct cmd_spec cmd_table[];
+extern int cmdtable_len;
+
 extern struct libxl_ctx ctx;
 extern int logfile;
 
diff -r b695c51b8345 -r 25e930534a5d tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c	Thu Apr 29 23:07:31 2010 +0800
+++ b/tools/libxl/xl_cmdimpl.c	Fri Apr 30 00:16:19 2010 +0800
@@ -38,6 +38,10 @@
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxlutil.h"
+#include "xl_cmdtable.h"
+
+extern struct cmd_spec cmd_table[];
+extern int cmdtable_len;
 
 #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
 
@@ -1081,24 +1085,8 @@
     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");
+        for (int 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");
diff -r b695c51b8345 -r 25e930534a5d tools/libxl/xl_cmdtable.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxl/xl_cmdtable.c	Fri Apr 30 00:16:19 2010 +0800
@@ -0,0 +1,40 @@
+/*
+ * 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" },
+};
+
+int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);
diff -r b695c51b8345 -r 25e930534a5d tools/libxl/xl_cmdtable.h
--- a/tools/libxl/xl_cmdtable.h	Thu Apr 29 23:07:31 2010 +0800
+++ b/tools/libxl/xl_cmdtable.h	Fri Apr 30 00:16:19 2010 +0800
@@ -17,29 +17,5 @@
 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 },
-};
-
-int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec);

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3]xl: Add command description to command table
  2010-04-29  9:24 [PATCH 3/3]xl: Add command description to command table Yang Hongyang
@ 2010-05-04 16:10 ` Ian Jackson
  2010-05-04 16:20   ` Keir Fraser
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Jackson @ 2010-05-04 16:10 UTC (permalink / raw)
  To: xen-devel

Yang Hongyang writes ("[Xen-devel] [PATCH 3/3]xl: Add command description to command table"):
> Add command description to command table

Thanks.  I see this has already been applied.   However:

> diff -r b695c51b8345 -r 25e930534a5d tools/libxl/xl.c
> --- a/tools/libxl/xl.c	Thu Apr 29 23:07:31 2010 +0800
> +++ b/tools/libxl/xl.c	Fri Apr 30 00:16:19 2010 +0800
> @@ -31,6 +31,9 @@
>  #include "xl_cmdimpl.h"
>  #include "xl_cmdtable.h"
>  
> +extern struct cmd_spec cmd_table[];
> +extern int cmdtable_len;
> +
>  extern struct libxl_ctx ctx;
>  extern int logfile;

This is wrong.  Use of "extern" in this way in a .c file is incorrect;
pure predeclarations should appear only in .h files, and they should
appear exactly once each.  That way they can't get out of step.

I'll send a patch to fix this at some point.

Ian.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3]xl: Add command description to command table
  2010-05-04 16:10 ` Ian Jackson
@ 2010-05-04 16:20   ` Keir Fraser
  2010-05-04 16:41     ` Ian Jackson
  2010-05-05  0:47     ` Yang Hongyang
  0 siblings, 2 replies; 5+ messages in thread
From: Keir Fraser @ 2010-05-04 16:20 UTC (permalink / raw)
  To: Ian Jackson, xen-devel@lists.xensource.com

On 04/05/2010 17:10, "Ian Jackson" <Ian.Jackson@eu.citrix.com> wrote:

>> +extern struct cmd_spec cmd_table[];
>> +extern int cmdtable_len;
>> +
>>  extern struct libxl_ctx ctx;
>>  extern int logfile;
> 
> This is wrong.  Use of "extern" in this way in a .c file is incorrect;
> pure predeclarations should appear only in .h files, and they should
> appear exactly once each.  That way they can't get out of step.
> 
> I'll send a patch to fix this at some point.

I fixed it before I applied it.

 -- Keir

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3]xl: Add command description to command table
  2010-05-04 16:20   ` Keir Fraser
@ 2010-05-04 16:41     ` Ian Jackson
  2010-05-05  0:47     ` Yang Hongyang
  1 sibling, 0 replies; 5+ messages in thread
From: Ian Jackson @ 2010-05-04 16:41 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel@lists.xensource.com

Keir Fraser writes ("Re: [Xen-devel] [PATCH 3/3]xl: Add command description to command table"):
> On 04/05/2010 17:10, "Ian Jackson" <Ian.Jackson@eu.citrix.com> wrote:
> > I'll send a patch to fix this at some point.
> 
> I fixed it before I applied it.

So you did :-).

Ian.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3]xl: Add command description to command table
  2010-05-04 16:20   ` Keir Fraser
  2010-05-04 16:41     ` Ian Jackson
@ 2010-05-05  0:47     ` Yang Hongyang
  1 sibling, 0 replies; 5+ messages in thread
From: Yang Hongyang @ 2010-05-05  0:47 UTC (permalink / raw)
  To: Keir Fraser; +Cc: xen-devel@lists.xensource.com, Ian Jackson

Hi Keir,

On 05/05/2010 12:20 AM, Keir Fraser wrote:
> On 04/05/2010 17:10, "Ian Jackson" <Ian.Jackson@eu.citrix.com> wrote:
> 
>>> +extern struct cmd_spec cmd_table[];
>>> +extern int cmdtable_len;
>>> +
>>>  extern struct libxl_ctx ctx;
>>>  extern int logfile;
>>
>> This is wrong.  Use of "extern" in this way in a .c file is incorrect;
>> pure predeclarations should appear only in .h files, and they should
>> appear exactly once each.  That way they can't get out of step.
>>
>> I'll send a patch to fix this at some point.
> 
> I fixed it before I applied it.

Thank you for that!

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


-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-05  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-29  9:24 [PATCH 3/3]xl: Add command description to command table Yang Hongyang
2010-05-04 16:10 ` Ian Jackson
2010-05-04 16:20   ` Keir Fraser
2010-05-04 16:41     ` Ian Jackson
2010-05-05  0:47     ` Yang Hongyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).