* [Qemu-devel] [PATCH, RFC] Use help sub-sections to create sub-help options
@ 2015-08-27 15:20 Laurent Vivier
2015-08-27 15:44 ` Marc-André Lureau
0 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2015-08-27 15:20 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: armbru
As '-help' output is 400 lines long it is not easy
to find information, but generally we know from
which area we want the information.
As subsections already exist in the help description,
add some command options to only display the wanted
subsection.
As more is better, this patch adds 13 lines to the -help output:
-help-standard display standard options
-help-block display block options
-help-usb display usb options
-help-display display display options
-help-machine display machine options
-help-network display network options
-help-character display character options
-help-url display url options
-help-bt display bt options
-help-tpm display tpm options
-help-kernel display kernel options
-help-expert display expert options
-help-object display object options
Example:
$ qemu-system-x86_64 -help-kernel
Linux/Multiboot boot specific:
-kernel bzImage use 'bzImage' as kernel image
-append cmdline use 'cmdline' as kernel command line
-initrd file use 'file' as initial ram disk
-dtb file use 'file' as device tree image
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
qemu-options.hx | 137 +++++++++++++++++++++++++++++++++++++++++++--
vl.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 302 insertions(+), 4 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 77f5853..091cc21 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -6,17 +6,122 @@ HXCOMM construct option structures, enums and help message for specified
HXCOMM architectures.
HXCOMM HXCOMM can be used for comments, discarded from both texi and C
+#if !(defined(QEMU_HELP_DISABLE_STANDARD) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Standard options:)
STEXI
@table @option
ETEXI
DEF("help", 0, QEMU_OPTION_h,
- "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
+ "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
STEXI
@item -h
@findex -h
-Display help and exit
+Display all help options and exit
+ETEXI
+
+DEF("help-standard", 0, QEMU_OPTION_h_standard,
+ "-help-standard display standard options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-standard
+@findex -help-standard
+Display standard options
+ETEXI
+
+DEF("help-block", 0, QEMU_OPTION_h_block,
+ "-help-block display block options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-block
+@findex -help-block
+Display block options
+ETEXI
+
+DEF("help-usb", 0, QEMU_OPTION_h_usb,
+ "-help-usb display usb options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-usb
+@findex -help-usb
+Display usb options
+ETEXI
+
+DEF("help-display", 0, QEMU_OPTION_h_display,
+ "-help-display display display options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-display
+@findex -help-display
+Display display options
+ETEXI
+
+DEF("help-machine", 0, QEMU_OPTION_h_machine,
+ "-help-machine display machine options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-machine
+@findex -help-machine
+Display machine options
+ETEXI
+
+DEF("help-network", 0, QEMU_OPTION_h_network,
+ "-help-network display network options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-network
+@findex -help-network
+Display network options
+ETEXI
+
+DEF("help-character", 0, QEMU_OPTION_h_character,
+ "-help-character display character options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-character
+@findex -help-character
+Display character options
+ETEXI
+
+DEF("help-url", 0, QEMU_OPTION_h_url,
+ "-help-url display url options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-url
+@findex -help-url
+Display url options
+ETEXI
+
+DEF("help-bt", 0, QEMU_OPTION_h_bt,
+ "-help-bt display bt options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-bt
+@findex -help-bt
+Display bt options
+ETEXI
+
+DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
+ "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-tpm
+@findex -help-tpm
+Display tpm options
+ETEXI
+
+DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
+ "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-kernel
+@findex -help-kernel
+Display kernel options
+ETEXI
+
+DEF("help-expert", 0, QEMU_OPTION_h_expert,
+ "-help-expert display expert options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-expert
+@findex -help-expert
+Display expert options
+ETEXI
+
+DEF("help-object", 0, QEMU_OPTION_h_object,
+ "-help-object display object options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-object
+@findex -help-object
+Display object options
ETEXI
DEF("version", 0, QEMU_OPTION_version,
@@ -410,7 +515,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_BLOCK) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Block device options:)
STEXI
@table @option
@@ -798,7 +905,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_USB) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(USB options:)
STEXI
@table @option
@@ -862,7 +971,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_DISPLAY) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Display options:)
STEXI
@table @option
@@ -1329,7 +1440,9 @@ STEXI
@end table
ETEXI
ARCHHEADING(, QEMU_ARCH_I386)
+#endif
+#if !(defined(QEMU_HELP_DISABLE_MACHINE) && defined(QEMU_OPTIONS_GENERATE_HELP))
ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
STEXI
@table @option
@@ -1441,7 +1554,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_NETWORK) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Network options:)
STEXI
@table @option
@@ -1995,7 +2110,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_CHARACTER) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Character device options:)
STEXI
@@ -2273,7 +2390,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_URL) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Device URL Syntax:)
STEXI
@@ -2482,7 +2601,9 @@ ETEXI
STEXI
@end table
ETEXI
+#endif
+#if !(defined(QEMU_HELP_DISABLE_BT) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Bluetooth(R) options:)
STEXI
@table @option
@@ -2557,7 +2678,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_TPM) && defined(QEMU_OPTIONS_GENERATE_HELP))
#ifdef CONFIG_TPM
DEFHEADING(TPM device options:)
@@ -2632,7 +2755,9 @@ ETEXI
DEFHEADING()
#endif
+#endif
+#if !(defined(QEMU_HELP_DISABLE_KERNEL) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Linux/Multiboot boot specific:)
STEXI
@@ -2688,7 +2813,9 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if !(defined(QEMU_HELP_DISABLE_EXPERT) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Debug/Expert options:)
STEXI
@table @option
@@ -3510,7 +3637,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
" Output vmstate information in JSON format to file.\n"
" Use the scripts/vmstate-static-checker.py file to\n"
" check for possible regressions in migration code\n"
- " by comparing two such vmstate dumps.",
+ " by comparing two such vmstate dumps.\n",
QEMU_ARCH_ALL)
STEXI
@item -dump-vmstate @var{file}
@@ -3518,7 +3645,9 @@ STEXI
Dump json-encoded vmstate information for current machine type to file
in @var{file}
ETEXI
+#endif
+#if !(defined(QEMU_HELP_DISABLE_OBJECT) && defined(QEMU_OPTIONS_GENERATE_HELP))
DEFHEADING(Generic object creation)
DEF("object", HAS_ARG, QEMU_OPTION_object,
@@ -3571,7 +3700,7 @@ to the RNG daemon.
@end table
ETEXI
-
+#endif
HXCOMM This is the last statement. Insert new options before this line!
STEXI
diff --git a/vl.c b/vl.c
index 584ca88..65a815f 100644
--- a/vl.c
+++ b/vl.c
@@ -1931,6 +1931,136 @@ static void help(int exitcode)
exit(exitcode);
}
+#define QEMU_HELP_DISABLE_BLOCK
+#define QEMU_HELP_DISABLE_USB
+#define QEMU_HELP_DISABLE_DISPLAY
+#define QEMU_HELP_DISABLE_MACHINE
+#define QEMU_HELP_DISABLE_NETWORK
+#define QEMU_HELP_DISABLE_CHARACTER
+#define QEMU_HELP_DISABLE_URL
+#define QEMU_HELP_DISABLE_BT
+#define QEMU_HELP_DISABLE_TPM
+#define QEMU_HELP_DISABLE_KERNEL
+#define QEMU_HELP_DISABLE_EXPERT
+#define QEMU_HELP_DISABLE_OBJECT
+
+static void help_standard(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+
+#define QEMU_HELP_DISABLE_STANDARD
+#undef QEMU_HELP_DISABLE_BLOCK
+static void help_block(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_BLOCK
+#undef QEMU_HELP_DISABLE_USB
+static void help_usb(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_USB
+#undef QEMU_HELP_DISABLE_DISPLAY
+static void help_display(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_DISPLAY
+#undef QEMU_HELP_DISABLE_MACHINE
+static void help_machine(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_MACHINE
+#undef QEMU_HELP_DISABLE_NETWORK
+static void help_network(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_NETWORK
+#undef QEMU_HELP_DISABLE_CHARACTER
+static void help_character(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_CHARACTER
+#undef QEMU_HELP_DISABLE_URL
+static void help_url(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_URL
+#undef QEMU_HELP_DISABLE_BT
+static void help_bt(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_BT
+#undef QEMU_HELP_DISABLE_TPM
+static void help_tpm(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_TPM
+#undef QEMU_HELP_DISABLE_KERNEL
+static void help_kernel(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_KERNEL
+#undef QEMU_HELP_DISABLE_EXPERT
+static void help_expert(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#define QEMU_HELP_DISABLE_EXPERT
+#undef QEMU_HELP_DISABLE_OBJECT
+static void help_object(int exitcode)
+{
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#undef QEMU_HELP_DISABLE_STANDARD
+#undef QEMU_HELP_DISABLE_BLOCK
+#undef QEMU_HELP_DISABLE_USB
+#undef QEMU_HELP_DISABLE_DISPLAY
+#undef QEMU_HELP_DISABLE_NETWORK
+#undef QEMU_HELP_DISABLE_CHARACTER
+#undef QEMU_HELP_DISABLE_URL
+#undef QEMU_HELP_DISABLE_BT
+#undef QEMU_HELP_DISABLE_TPM
+#undef QEMU_HELP_DISABLE_KERNEL
+#undef QEMU_HELP_DISABLE_EXPERT
+#undef QEMU_HELP_DISABLE_OBJECT
+
+
#define HAS_ARG 0x0001
typedef struct QEMUOption {
@@ -3318,6 +3448,42 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_h:
help(0);
break;
+ case QEMU_OPTION_h_standard:
+ help_standard(0);
+ break;
+ case QEMU_OPTION_h_block:
+ help_block(0);
+ break;
+ case QEMU_OPTION_h_usb:
+ help_usb(0);
+ break;
+ case QEMU_OPTION_h_display:
+ help_display(0);
+ break;
+ case QEMU_OPTION_h_machine:
+ help_machine(0);
+ break;
+ case QEMU_OPTION_h_network:
+ help_network(0);
+ break;
+ case QEMU_OPTION_h_character:
+ help_character(0);
+ break;
+ case QEMU_OPTION_h_url:
+ help_url(0);
+ break;
+ case QEMU_OPTION_h_bt:
+ help_bt(0);
+ break;
+ case QEMU_OPTION_h_kernel:
+ help_kernel(0);
+ break;
+ case QEMU_OPTION_h_expert:
+ help_expert(0);
+ break;
+ case QEMU_OPTION_h_object:
+ help_object(0);
+ break;
case QEMU_OPTION_version:
version();
exit(0);
@@ -3330,6 +3496,9 @@ int main(int argc, char **argv, char **envp)
}
break;
#ifdef CONFIG_TPM
+ case QEMU_OPTION_h_tpm:
+ help_tpm(0);
+ break;
case QEMU_OPTION_tpmdev:
if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
exit(1);
--
2.1.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH, RFC] Use help sub-sections to create sub-help options
2015-08-27 15:20 [Qemu-devel] [PATCH, RFC] Use help sub-sections to create sub-help options Laurent Vivier
@ 2015-08-27 15:44 ` Marc-André Lureau
2015-08-27 15:50 ` Laurent Vivier
2015-08-27 17:07 ` [Qemu-devel] [PATCH, RFC v2] " Laurent Vivier
0 siblings, 2 replies; 11+ messages in thread
From: Marc-André Lureau @ 2015-08-27 15:44 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Paolo Bonzini, QEMU, Markus Armbruster
Hi
On Thu, Aug 27, 2015 at 5:20 PM, Laurent Vivier <lvivier@redhat.com> wrote:
> As '-help' output is 400 lines long it is not easy
> to find information, but generally we know from
> which area we want the information.
>
> As subsections already exist in the help description,
> add some command options to only display the wanted
> subsection.
>
> As more is better, this patch adds 13 lines to the -help output:
>
> -help-standard display standard options
> -help-block display block options
> -help-usb display usb options
> -help-display display display options
> -help-machine display machine options
> -help-network display network options
> -help-character display character options
> -help-url display url options
> -help-bt display bt options
> -help-tpm display tpm options
> -help-kernel display kernel options
> -help-expert display expert options
> -help-object display object options
>
> Example:
>
> $ qemu-system-x86_64 -help-kernel
> Linux/Multiboot boot specific:
> -kernel bzImage use 'bzImage' as kernel image
> -append cmdline use 'cmdline' as kernel command line
> -initrd file use 'file' as initial ram disk
> -dtb file use 'file' as device tree image
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> qemu-options.hx | 137 +++++++++++++++++++++++++++++++++++++++++++--
> vl.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The patch works as expected, although it's a bit cumbersome this
#define #undef dance, I don't have a good idea either, but maybe it
would be slightly easier with an ENABLE_ALL and ENABLE_FOO, I think
that could avoid the big list of #define #undef and make it a bit
simpler too.
> 2 files changed, 302 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 77f5853..091cc21 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -6,17 +6,122 @@ HXCOMM construct option structures, enums and help message for specified
> HXCOMM architectures.
> HXCOMM HXCOMM can be used for comments, discarded from both texi and C
>
> +#if !(defined(QEMU_HELP_DISABLE_STANDARD) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Standard options:)
> STEXI
> @table @option
> ETEXI
>
> DEF("help", 0, QEMU_OPTION_h,
> - "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
> + "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
> STEXI
> @item -h
> @findex -h
> -Display help and exit
> +Display all help options and exit
> +ETEXI
> +
> +DEF("help-standard", 0, QEMU_OPTION_h_standard,
> + "-help-standard display standard options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-standard
> +@findex -help-standard
> +Display standard options
> +ETEXI
> +
> +DEF("help-block", 0, QEMU_OPTION_h_block,
> + "-help-block display block options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-block
> +@findex -help-block
> +Display block options
> +ETEXI
> +
> +DEF("help-usb", 0, QEMU_OPTION_h_usb,
> + "-help-usb display usb options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-usb
> +@findex -help-usb
> +Display usb options
> +ETEXI
> +
> +DEF("help-display", 0, QEMU_OPTION_h_display,
> + "-help-display display display options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-display
> +@findex -help-display
> +Display display options
> +ETEXI
> +
> +DEF("help-machine", 0, QEMU_OPTION_h_machine,
> + "-help-machine display machine options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-machine
> +@findex -help-machine
> +Display machine options
> +ETEXI
> +
> +DEF("help-network", 0, QEMU_OPTION_h_network,
> + "-help-network display network options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-network
> +@findex -help-network
> +Display network options
> +ETEXI
> +
> +DEF("help-character", 0, QEMU_OPTION_h_character,
> + "-help-character display character options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-character
> +@findex -help-character
> +Display character options
> +ETEXI
> +
> +DEF("help-url", 0, QEMU_OPTION_h_url,
> + "-help-url display url options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-url
> +@findex -help-url
> +Display url options
> +ETEXI
> +
> +DEF("help-bt", 0, QEMU_OPTION_h_bt,
> + "-help-bt display bt options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-bt
> +@findex -help-bt
> +Display bt options
> +ETEXI
> +
> +DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
> + "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-tpm
> +@findex -help-tpm
> +Display tpm options
> +ETEXI
> +
> +DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
> + "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-kernel
> +@findex -help-kernel
> +Display kernel options
> +ETEXI
> +
> +DEF("help-expert", 0, QEMU_OPTION_h_expert,
> + "-help-expert display expert options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-expert
> +@findex -help-expert
> +Display expert options
> +ETEXI
> +
> +DEF("help-object", 0, QEMU_OPTION_h_object,
> + "-help-object display object options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-object
> +@findex -help-object
> +Display object options
> ETEXI
>
> DEF("version", 0, QEMU_OPTION_version,
> @@ -410,7 +515,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_BLOCK) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Block device options:)
> STEXI
> @table @option
> @@ -798,7 +905,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_USB) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(USB options:)
> STEXI
> @table @option
> @@ -862,7 +971,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_DISPLAY) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Display options:)
> STEXI
> @table @option
> @@ -1329,7 +1440,9 @@ STEXI
> @end table
> ETEXI
> ARCHHEADING(, QEMU_ARCH_I386)
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_MACHINE) && defined(QEMU_OPTIONS_GENERATE_HELP))
> ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
> STEXI
> @table @option
> @@ -1441,7 +1554,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_NETWORK) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Network options:)
> STEXI
> @table @option
> @@ -1995,7 +2110,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_CHARACTER) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Character device options:)
> STEXI
>
> @@ -2273,7 +2390,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_URL) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Device URL Syntax:)
> STEXI
>
> @@ -2482,7 +2601,9 @@ ETEXI
> STEXI
> @end table
> ETEXI
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_BT) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Bluetooth(R) options:)
> STEXI
> @table @option
> @@ -2557,7 +2678,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_TPM) && defined(QEMU_OPTIONS_GENERATE_HELP))
> #ifdef CONFIG_TPM
> DEFHEADING(TPM device options:)
>
> @@ -2632,7 +2755,9 @@ ETEXI
> DEFHEADING()
>
> #endif
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_KERNEL) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Linux/Multiboot boot specific:)
> STEXI
>
> @@ -2688,7 +2813,9 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_EXPERT) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Debug/Expert options:)
> STEXI
> @table @option
> @@ -3510,7 +3637,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
> " Output vmstate information in JSON format to file.\n"
> " Use the scripts/vmstate-static-checker.py file to\n"
> " check for possible regressions in migration code\n"
> - " by comparing two such vmstate dumps.",
> + " by comparing two such vmstate dumps.\n",
> QEMU_ARCH_ALL)
> STEXI
> @item -dump-vmstate @var{file}
> @@ -3518,7 +3645,9 @@ STEXI
> Dump json-encoded vmstate information for current machine type to file
> in @var{file}
> ETEXI
> +#endif
>
> +#if !(defined(QEMU_HELP_DISABLE_OBJECT) && defined(QEMU_OPTIONS_GENERATE_HELP))
> DEFHEADING(Generic object creation)
>
> DEF("object", HAS_ARG, QEMU_OPTION_object,
> @@ -3571,7 +3700,7 @@ to the RNG daemon.
> @end table
>
> ETEXI
> -
> +#endif
>
> HXCOMM This is the last statement. Insert new options before this line!
> STEXI
> diff --git a/vl.c b/vl.c
> index 584ca88..65a815f 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1931,6 +1931,136 @@ static void help(int exitcode)
> exit(exitcode);
> }
>
> +#define QEMU_HELP_DISABLE_BLOCK
> +#define QEMU_HELP_DISABLE_USB
> +#define QEMU_HELP_DISABLE_DISPLAY
> +#define QEMU_HELP_DISABLE_MACHINE
> +#define QEMU_HELP_DISABLE_NETWORK
> +#define QEMU_HELP_DISABLE_CHARACTER
> +#define QEMU_HELP_DISABLE_URL
> +#define QEMU_HELP_DISABLE_BT
> +#define QEMU_HELP_DISABLE_TPM
> +#define QEMU_HELP_DISABLE_KERNEL
> +#define QEMU_HELP_DISABLE_EXPERT
> +#define QEMU_HELP_DISABLE_OBJECT
> +
> +static void help_standard(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +
> +#define QEMU_HELP_DISABLE_STANDARD
> +#undef QEMU_HELP_DISABLE_BLOCK
> +static void help_block(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_BLOCK
> +#undef QEMU_HELP_DISABLE_USB
> +static void help_usb(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_USB
> +#undef QEMU_HELP_DISABLE_DISPLAY
> +static void help_display(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_DISPLAY
> +#undef QEMU_HELP_DISABLE_MACHINE
> +static void help_machine(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_MACHINE
> +#undef QEMU_HELP_DISABLE_NETWORK
> +static void help_network(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_NETWORK
> +#undef QEMU_HELP_DISABLE_CHARACTER
> +static void help_character(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_CHARACTER
> +#undef QEMU_HELP_DISABLE_URL
> +static void help_url(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_URL
> +#undef QEMU_HELP_DISABLE_BT
> +static void help_bt(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_BT
> +#undef QEMU_HELP_DISABLE_TPM
> +static void help_tpm(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_TPM
> +#undef QEMU_HELP_DISABLE_KERNEL
> +static void help_kernel(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_KERNEL
> +#undef QEMU_HELP_DISABLE_EXPERT
> +static void help_expert(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#define QEMU_HELP_DISABLE_EXPERT
> +#undef QEMU_HELP_DISABLE_OBJECT
> +static void help_object(int exitcode)
> +{
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#undef QEMU_HELP_DISABLE_STANDARD
> +#undef QEMU_HELP_DISABLE_BLOCK
> +#undef QEMU_HELP_DISABLE_USB
> +#undef QEMU_HELP_DISABLE_DISPLAY
> +#undef QEMU_HELP_DISABLE_NETWORK
> +#undef QEMU_HELP_DISABLE_CHARACTER
> +#undef QEMU_HELP_DISABLE_URL
> +#undef QEMU_HELP_DISABLE_BT
> +#undef QEMU_HELP_DISABLE_TPM
> +#undef QEMU_HELP_DISABLE_KERNEL
> +#undef QEMU_HELP_DISABLE_EXPERT
> +#undef QEMU_HELP_DISABLE_OBJECT
> +
> +
> #define HAS_ARG 0x0001
>
> typedef struct QEMUOption {
> @@ -3318,6 +3448,42 @@ int main(int argc, char **argv, char **envp)
> case QEMU_OPTION_h:
> help(0);
> break;
> + case QEMU_OPTION_h_standard:
> + help_standard(0);
> + break;
> + case QEMU_OPTION_h_block:
> + help_block(0);
> + break;
> + case QEMU_OPTION_h_usb:
> + help_usb(0);
> + break;
> + case QEMU_OPTION_h_display:
> + help_display(0);
> + break;
> + case QEMU_OPTION_h_machine:
> + help_machine(0);
> + break;
> + case QEMU_OPTION_h_network:
> + help_network(0);
> + break;
> + case QEMU_OPTION_h_character:
> + help_character(0);
> + break;
> + case QEMU_OPTION_h_url:
> + help_url(0);
> + break;
> + case QEMU_OPTION_h_bt:
> + help_bt(0);
> + break;
> + case QEMU_OPTION_h_kernel:
> + help_kernel(0);
> + break;
> + case QEMU_OPTION_h_expert:
> + help_expert(0);
> + break;
> + case QEMU_OPTION_h_object:
> + help_object(0);
> + break;
> case QEMU_OPTION_version:
> version();
> exit(0);
> @@ -3330,6 +3496,9 @@ int main(int argc, char **argv, char **envp)
> }
> break;
> #ifdef CONFIG_TPM
> + case QEMU_OPTION_h_tpm:
> + help_tpm(0);
> + break;
> case QEMU_OPTION_tpmdev:
> if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
> exit(1);
> --
> 2.1.0
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH, RFC] Use help sub-sections to create sub-help options
2015-08-27 15:44 ` Marc-André Lureau
@ 2015-08-27 15:50 ` Laurent Vivier
2015-08-27 17:07 ` [Qemu-devel] [PATCH, RFC v2] " Laurent Vivier
1 sibling, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2015-08-27 15:50 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Paolo Bonzini, QEMU, Markus Armbruster
On 27/08/2015 17:44, Marc-André Lureau wrote:
> Hi
>
> On Thu, Aug 27, 2015 at 5:20 PM, Laurent Vivier <lvivier@redhat.com> wrote:
>> As '-help' output is 400 lines long it is not easy
>> to find information, but generally we know from
>> which area we want the information.
>>
>> As subsections already exist in the help description,
>> add some command options to only display the wanted
>> subsection.
>>
>> As more is better, this patch adds 13 lines to the -help output:
>>
>> -help-standard display standard options
>> -help-block display block options
>> -help-usb display usb options
>> -help-display display display options
>> -help-machine display machine options
>> -help-network display network options
>> -help-character display character options
>> -help-url display url options
>> -help-bt display bt options
>> -help-tpm display tpm options
>> -help-kernel display kernel options
>> -help-expert display expert options
>> -help-object display object options
>>
>> Example:
>>
>> $ qemu-system-x86_64 -help-kernel
>> Linux/Multiboot boot specific:
>> -kernel bzImage use 'bzImage' as kernel image
>> -append cmdline use 'cmdline' as kernel command line
>> -initrd file use 'file' as initial ram disk
>> -dtb file use 'file' as device tree image
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
>> ---
>> qemu-options.hx | 137 +++++++++++++++++++++++++++++++++++++++++++--
>> vl.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> The patch works as expected, although it's a bit cumbersome this
> #define #undef dance, I don't have a good idea either, but maybe it
> would be slightly easier with an ENABLE_ALL and ENABLE_FOO, I think
> that could avoid the big list of #define #undef and make it a bit
> simpler too.
I agree with you, but my goal was to keep the default behavior if
nothing is defined. But if everyone agrees, I can change that.
>
>
>> 2 files changed, 302 insertions(+), 4 deletions(-)
>>
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index 77f5853..091cc21 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -6,17 +6,122 @@ HXCOMM construct option structures, enums and help message for specified
>> HXCOMM architectures.
>> HXCOMM HXCOMM can be used for comments, discarded from both texi and C
>>
>> +#if !(defined(QEMU_HELP_DISABLE_STANDARD) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Standard options:)
>> STEXI
>> @table @option
>> ETEXI
>>
>> DEF("help", 0, QEMU_OPTION_h,
>> - "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
>> + "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
>> STEXI
>> @item -h
>> @findex -h
>> -Display help and exit
>> +Display all help options and exit
>> +ETEXI
>> +
>> +DEF("help-standard", 0, QEMU_OPTION_h_standard,
>> + "-help-standard display standard options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-standard
>> +@findex -help-standard
>> +Display standard options
>> +ETEXI
>> +
>> +DEF("help-block", 0, QEMU_OPTION_h_block,
>> + "-help-block display block options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-block
>> +@findex -help-block
>> +Display block options
>> +ETEXI
>> +
>> +DEF("help-usb", 0, QEMU_OPTION_h_usb,
>> + "-help-usb display usb options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-usb
>> +@findex -help-usb
>> +Display usb options
>> +ETEXI
>> +
>> +DEF("help-display", 0, QEMU_OPTION_h_display,
>> + "-help-display display display options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-display
>> +@findex -help-display
>> +Display display options
>> +ETEXI
>> +
>> +DEF("help-machine", 0, QEMU_OPTION_h_machine,
>> + "-help-machine display machine options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-machine
>> +@findex -help-machine
>> +Display machine options
>> +ETEXI
>> +
>> +DEF("help-network", 0, QEMU_OPTION_h_network,
>> + "-help-network display network options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-network
>> +@findex -help-network
>> +Display network options
>> +ETEXI
>> +
>> +DEF("help-character", 0, QEMU_OPTION_h_character,
>> + "-help-character display character options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-character
>> +@findex -help-character
>> +Display character options
>> +ETEXI
>> +
>> +DEF("help-url", 0, QEMU_OPTION_h_url,
>> + "-help-url display url options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-url
>> +@findex -help-url
>> +Display url options
>> +ETEXI
>> +
>> +DEF("help-bt", 0, QEMU_OPTION_h_bt,
>> + "-help-bt display bt options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-bt
>> +@findex -help-bt
>> +Display bt options
>> +ETEXI
>> +
>> +DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
>> + "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-tpm
>> +@findex -help-tpm
>> +Display tpm options
>> +ETEXI
>> +
>> +DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
>> + "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-kernel
>> +@findex -help-kernel
>> +Display kernel options
>> +ETEXI
>> +
>> +DEF("help-expert", 0, QEMU_OPTION_h_expert,
>> + "-help-expert display expert options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-expert
>> +@findex -help-expert
>> +Display expert options
>> +ETEXI
>> +
>> +DEF("help-object", 0, QEMU_OPTION_h_object,
>> + "-help-object display object options\n", QEMU_ARCH_ALL)
>> +STEXI
>> +@item -help-object
>> +@findex -help-object
>> +Display object options
>> ETEXI
>>
>> DEF("version", 0, QEMU_OPTION_version,
>> @@ -410,7 +515,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_BLOCK) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Block device options:)
>> STEXI
>> @table @option
>> @@ -798,7 +905,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_USB) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(USB options:)
>> STEXI
>> @table @option
>> @@ -862,7 +971,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_DISPLAY) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Display options:)
>> STEXI
>> @table @option
>> @@ -1329,7 +1440,9 @@ STEXI
>> @end table
>> ETEXI
>> ARCHHEADING(, QEMU_ARCH_I386)
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_MACHINE) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
>> STEXI
>> @table @option
>> @@ -1441,7 +1554,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_NETWORK) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Network options:)
>> STEXI
>> @table @option
>> @@ -1995,7 +2110,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_CHARACTER) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Character device options:)
>> STEXI
>>
>> @@ -2273,7 +2390,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_URL) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Device URL Syntax:)
>> STEXI
>>
>> @@ -2482,7 +2601,9 @@ ETEXI
>> STEXI
>> @end table
>> ETEXI
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_BT) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Bluetooth(R) options:)
>> STEXI
>> @table @option
>> @@ -2557,7 +2678,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_TPM) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> #ifdef CONFIG_TPM
>> DEFHEADING(TPM device options:)
>>
>> @@ -2632,7 +2755,9 @@ ETEXI
>> DEFHEADING()
>>
>> #endif
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_KERNEL) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Linux/Multiboot boot specific:)
>> STEXI
>>
>> @@ -2688,7 +2813,9 @@ STEXI
>> @end table
>> ETEXI
>> DEFHEADING()
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_EXPERT) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Debug/Expert options:)
>> STEXI
>> @table @option
>> @@ -3510,7 +3637,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
>> " Output vmstate information in JSON format to file.\n"
>> " Use the scripts/vmstate-static-checker.py file to\n"
>> " check for possible regressions in migration code\n"
>> - " by comparing two such vmstate dumps.",
>> + " by comparing two such vmstate dumps.\n",
>> QEMU_ARCH_ALL)
>> STEXI
>> @item -dump-vmstate @var{file}
>> @@ -3518,7 +3645,9 @@ STEXI
>> Dump json-encoded vmstate information for current machine type to file
>> in @var{file}
>> ETEXI
>> +#endif
>>
>> +#if !(defined(QEMU_HELP_DISABLE_OBJECT) && defined(QEMU_OPTIONS_GENERATE_HELP))
>> DEFHEADING(Generic object creation)
>>
>> DEF("object", HAS_ARG, QEMU_OPTION_object,
>> @@ -3571,7 +3700,7 @@ to the RNG daemon.
>> @end table
>>
>> ETEXI
>> -
>> +#endif
>>
>> HXCOMM This is the last statement. Insert new options before this line!
>> STEXI
>> diff --git a/vl.c b/vl.c
>> index 584ca88..65a815f 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -1931,6 +1931,136 @@ static void help(int exitcode)
>> exit(exitcode);
>> }
>>
>> +#define QEMU_HELP_DISABLE_BLOCK
>> +#define QEMU_HELP_DISABLE_USB
>> +#define QEMU_HELP_DISABLE_DISPLAY
>> +#define QEMU_HELP_DISABLE_MACHINE
>> +#define QEMU_HELP_DISABLE_NETWORK
>> +#define QEMU_HELP_DISABLE_CHARACTER
>> +#define QEMU_HELP_DISABLE_URL
>> +#define QEMU_HELP_DISABLE_BT
>> +#define QEMU_HELP_DISABLE_TPM
>> +#define QEMU_HELP_DISABLE_KERNEL
>> +#define QEMU_HELP_DISABLE_EXPERT
>> +#define QEMU_HELP_DISABLE_OBJECT
>> +
>> +static void help_standard(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +
>> +#define QEMU_HELP_DISABLE_STANDARD
>> +#undef QEMU_HELP_DISABLE_BLOCK
>> +static void help_block(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_BLOCK
>> +#undef QEMU_HELP_DISABLE_USB
>> +static void help_usb(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_USB
>> +#undef QEMU_HELP_DISABLE_DISPLAY
>> +static void help_display(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_DISPLAY
>> +#undef QEMU_HELP_DISABLE_MACHINE
>> +static void help_machine(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_MACHINE
>> +#undef QEMU_HELP_DISABLE_NETWORK
>> +static void help_network(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_NETWORK
>> +#undef QEMU_HELP_DISABLE_CHARACTER
>> +static void help_character(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_CHARACTER
>> +#undef QEMU_HELP_DISABLE_URL
>> +static void help_url(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_URL
>> +#undef QEMU_HELP_DISABLE_BT
>> +static void help_bt(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_BT
>> +#undef QEMU_HELP_DISABLE_TPM
>> +static void help_tpm(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_TPM
>> +#undef QEMU_HELP_DISABLE_KERNEL
>> +static void help_kernel(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_KERNEL
>> +#undef QEMU_HELP_DISABLE_EXPERT
>> +static void help_expert(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#define QEMU_HELP_DISABLE_EXPERT
>> +#undef QEMU_HELP_DISABLE_OBJECT
>> +static void help_object(int exitcode)
>> +{
>> +#define QEMU_OPTIONS_GENERATE_HELP
>> +#include "qemu-options-wrapper.h"
>> + exit(exitcode);
>> +}
>> +#undef QEMU_HELP_DISABLE_STANDARD
>> +#undef QEMU_HELP_DISABLE_BLOCK
>> +#undef QEMU_HELP_DISABLE_USB
>> +#undef QEMU_HELP_DISABLE_DISPLAY
>> +#undef QEMU_HELP_DISABLE_NETWORK
>> +#undef QEMU_HELP_DISABLE_CHARACTER
>> +#undef QEMU_HELP_DISABLE_URL
>> +#undef QEMU_HELP_DISABLE_BT
>> +#undef QEMU_HELP_DISABLE_TPM
>> +#undef QEMU_HELP_DISABLE_KERNEL
>> +#undef QEMU_HELP_DISABLE_EXPERT
>> +#undef QEMU_HELP_DISABLE_OBJECT
>> +
>> +
>> #define HAS_ARG 0x0001
>>
>> typedef struct QEMUOption {
>> @@ -3318,6 +3448,42 @@ int main(int argc, char **argv, char **envp)
>> case QEMU_OPTION_h:
>> help(0);
>> break;
>> + case QEMU_OPTION_h_standard:
>> + help_standard(0);
>> + break;
>> + case QEMU_OPTION_h_block:
>> + help_block(0);
>> + break;
>> + case QEMU_OPTION_h_usb:
>> + help_usb(0);
>> + break;
>> + case QEMU_OPTION_h_display:
>> + help_display(0);
>> + break;
>> + case QEMU_OPTION_h_machine:
>> + help_machine(0);
>> + break;
>> + case QEMU_OPTION_h_network:
>> + help_network(0);
>> + break;
>> + case QEMU_OPTION_h_character:
>> + help_character(0);
>> + break;
>> + case QEMU_OPTION_h_url:
>> + help_url(0);
>> + break;
>> + case QEMU_OPTION_h_bt:
>> + help_bt(0);
>> + break;
>> + case QEMU_OPTION_h_kernel:
>> + help_kernel(0);
>> + break;
>> + case QEMU_OPTION_h_expert:
>> + help_expert(0);
>> + break;
>> + case QEMU_OPTION_h_object:
>> + help_object(0);
>> + break;
>> case QEMU_OPTION_version:
>> version();
>> exit(0);
>> @@ -3330,6 +3496,9 @@ int main(int argc, char **argv, char **envp)
>> }
>> break;
>> #ifdef CONFIG_TPM
>> + case QEMU_OPTION_h_tpm:
>> + help_tpm(0);
>> + break;
>> case QEMU_OPTION_tpmdev:
>> if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
>> exit(1);
>> --
>> 2.1.0
>>
>>
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH, RFC v2] Use help sub-sections to create sub-help options
2015-08-27 15:44 ` Marc-André Lureau
2015-08-27 15:50 ` Laurent Vivier
@ 2015-08-27 17:07 ` Laurent Vivier
2015-08-27 21:37 ` Marc-André Lureau
1 sibling, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2015-08-27 17:07 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
As '-help' output is 400 lines long it is not easy
to find information, but generally we know from
which area we want the information.
As subsections already exist in the help description,
add some command options to only display the wanted
subsection.
As more is better, this patch adds 13 lines to the -help output:
-help-standard display standard options
-help-block display block options
-help-usb display usb options
-help-display display display options
-help-machine display machine options
-help-network display network options
-help-character display character options
-help-url display url options
-help-bt display bt options
-help-tpm display tpm options
-help-kernel display kernel options
-help-expert display expert options
-help-object display object options
Example:
$ qemu-system-x86_64 -help-kernel
Linux/Multiboot boot specific:
-kernel bzImage use 'bzImage' as kernel image
-append cmdline use 'cmdline' as kernel command line
-initrd file use 'file' as initial ram disk
-dtb file use 'file' as device tree image
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
v2: simplify the dance of #define/#undef, thanks to Marc-André.
qemu-options.hx | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
vl.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 280 insertions(+), 4 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 77f5853..49b78df 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -6,17 +6,123 @@ HXCOMM construct option structures, enums and help message for specified
HXCOMM architectures.
HXCOMM HXCOMM can be used for comments, discarded from both texi and C
+#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_STANDARD
DEFHEADING(Standard options:)
STEXI
@table @option
ETEXI
DEF("help", 0, QEMU_OPTION_h,
- "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
+ "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
STEXI
@item -h
@findex -h
-Display help and exit
+Display all help options and exit
+ETEXI
+
+DEF("help-standard", 0, QEMU_OPTION_h_standard,
+ "-help-standard display standard options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-standard
+@findex -help-standard
+Display standard options
+ETEXI
+
+DEF("help-block", 0, QEMU_OPTION_h_block,
+ "-help-block display block options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-block
+@findex -help-block
+Display block options
+ETEXI
+
+DEF("help-usb", 0, QEMU_OPTION_h_usb,
+ "-help-usb display usb options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-usb
+@findex -help-usb
+Display usb options
+ETEXI
+
+DEF("help-display", 0, QEMU_OPTION_h_display,
+ "-help-display display display options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-display
+@findex -help-display
+Display display options
+ETEXI
+
+DEF("help-machine", 0, QEMU_OPTION_h_machine,
+ "-help-machine display machine options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-machine
+@findex -help-machine
+Display machine options
+ETEXI
+
+DEF("help-network", 0, QEMU_OPTION_h_network,
+ "-help-network display network options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-network
+@findex -help-network
+Display network options
+ETEXI
+
+DEF("help-character", 0, QEMU_OPTION_h_character,
+ "-help-character display character options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-character
+@findex -help-character
+Display character options
+ETEXI
+
+DEF("help-url", 0, QEMU_OPTION_h_url,
+ "-help-url display url options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-url
+@findex -help-url
+Display url options
+ETEXI
+
+DEF("help-bt", 0, QEMU_OPTION_h_bt,
+ "-help-bt display bt options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-bt
+@findex -help-bt
+Display bt options
+ETEXI
+
+DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
+ "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-tpm
+@findex -help-tpm
+Display tpm options
+ETEXI
+
+DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
+ "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-kernel
+@findex -help-kernel
+Display kernel options
+ETEXI
+
+DEF("help-expert", 0, QEMU_OPTION_h_expert,
+ "-help-expert display expert options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-expert
+@findex -help-expert
+Display expert options
+ETEXI
+
+DEF("help-object", 0, QEMU_OPTION_h_object,
+ "-help-object display object options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-object
+@findex -help-object
+Display object options
ETEXI
DEF("version", 0, QEMU_OPTION_version,
@@ -410,7 +516,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_BLOCK) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_BLOCK
DEFHEADING(Block device options:)
STEXI
@table @option
@@ -798,7 +907,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_USB) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_USB
DEFHEADING(USB options:)
STEXI
@table @option
@@ -862,7 +974,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_DISPLAY) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_DISPLAY
DEFHEADING(Display options:)
STEXI
@table @option
@@ -1329,7 +1444,10 @@ STEXI
@end table
ETEXI
ARCHHEADING(, QEMU_ARCH_I386)
+#endif
+#if defined(QEMU_HELP_SELECT_MACHINE) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_MACHINE
ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
STEXI
@table @option
@@ -1441,7 +1559,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_NETWORK) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_NETWORK
DEFHEADING(Network options:)
STEXI
@table @option
@@ -1995,7 +2116,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_CHARACTER) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_CHARACTER
DEFHEADING(Character device options:)
STEXI
@@ -2273,7 +2397,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_URL) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_URL
DEFHEADING(Device URL Syntax:)
STEXI
@@ -2482,7 +2609,10 @@ ETEXI
STEXI
@end table
ETEXI
+#endif
+#if defined(QEMU_HELP_SELECT_BT) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_BT
DEFHEADING(Bluetooth(R) options:)
STEXI
@table @option
@@ -2557,7 +2687,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_TPM) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_TPM
#ifdef CONFIG_TPM
DEFHEADING(TPM device options:)
@@ -2632,7 +2765,10 @@ ETEXI
DEFHEADING()
#endif
+#endif
+#if defined(QEMU_HELP_SELECT_KERNEL) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_KERNEL
DEFHEADING(Linux/Multiboot boot specific:)
STEXI
@@ -2688,7 +2824,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_EXPERT) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_EXPERT
DEFHEADING(Debug/Expert options:)
STEXI
@table @option
@@ -3510,7 +3649,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
" Output vmstate information in JSON format to file.\n"
" Use the scripts/vmstate-static-checker.py file to\n"
" check for possible regressions in migration code\n"
- " by comparing two such vmstate dumps.",
+ " by comparing two such vmstate dumps.\n",
QEMU_ARCH_ALL)
STEXI
@item -dump-vmstate @var{file}
@@ -3518,7 +3657,10 @@ STEXI
Dump json-encoded vmstate information for current machine type to file
in @var{file}
ETEXI
+#endif
+#if defined(QEMU_HELP_SELECT_OBJECT) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_OBJECT
DEFHEADING(Generic object creation)
DEF("object", HAS_ARG, QEMU_OPTION_object,
@@ -3571,7 +3713,7 @@ to the RNG daemon.
@end table
ETEXI
-
+#endif
HXCOMM This is the last statement. Insert new options before this line!
STEXI
diff --git a/vl.c b/vl.c
index 584ca88..e581dd2 100644
--- a/vl.c
+++ b/vl.c
@@ -1931,6 +1931,101 @@ static void help(int exitcode)
exit(exitcode);
}
+#define QEMU_HELP_SELECT
+static void help_standard(int exitcode)
+{
+#define QEMU_HELP_SELECT_STANDARD
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_block(int exitcode)
+{
+#define QEMU_HELP_SELECT_BLOCK
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_usb(int exitcode)
+{
+#define QEMU_HELP_SELECT_USB
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_display(int exitcode)
+{
+#define QEMU_HELP_SELECT_DISPLAY
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_machine(int exitcode)
+{
+#define QEMU_HELP_SELECT_MACHINE
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_network(int exitcode)
+{
+#define QEMU_HELP_SELECT_NETWORK
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_character(int exitcode)
+{
+#define QEMU_HELP_SELECT_CHARACTER
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_url(int exitcode)
+{
+#define QEMU_HELP_SELECT_URL
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_bt(int exitcode)
+{
+#define QEMU_HELP_SELECT_BT
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_tpm(int exitcode)
+{
+#define QEMU_HELP_SELECT_TPM
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_kernel(int exitcode)
+{
+#define QEMU_HELP_SELECT_KERNEL
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_expert(int exitcode)
+{
+#define QEMU_HELP_SELECT_EXPERT
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_object(int exitcode)
+{
+#define QEMU_HELP_SELECT_OBJECT
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#undef QEMU_HELP_SELECT
+
+
#define HAS_ARG 0x0001
typedef struct QEMUOption {
@@ -3318,6 +3413,42 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_h:
help(0);
break;
+ case QEMU_OPTION_h_standard:
+ help_standard(0);
+ break;
+ case QEMU_OPTION_h_block:
+ help_block(0);
+ break;
+ case QEMU_OPTION_h_usb:
+ help_usb(0);
+ break;
+ case QEMU_OPTION_h_display:
+ help_display(0);
+ break;
+ case QEMU_OPTION_h_machine:
+ help_machine(0);
+ break;
+ case QEMU_OPTION_h_network:
+ help_network(0);
+ break;
+ case QEMU_OPTION_h_character:
+ help_character(0);
+ break;
+ case QEMU_OPTION_h_url:
+ help_url(0);
+ break;
+ case QEMU_OPTION_h_bt:
+ help_bt(0);
+ break;
+ case QEMU_OPTION_h_kernel:
+ help_kernel(0);
+ break;
+ case QEMU_OPTION_h_expert:
+ help_expert(0);
+ break;
+ case QEMU_OPTION_h_object:
+ help_object(0);
+ break;
case QEMU_OPTION_version:
version();
exit(0);
@@ -3330,6 +3461,9 @@ int main(int argc, char **argv, char **envp)
}
break;
#ifdef CONFIG_TPM
+ case QEMU_OPTION_h_tpm:
+ help_tpm(0);
+ break;
case QEMU_OPTION_tpmdev:
if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
exit(1);
--
2.1.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH, RFC v2] Use help sub-sections to create sub-help options
2015-08-27 17:07 ` [Qemu-devel] [PATCH, RFC v2] " Laurent Vivier
@ 2015-08-27 21:37 ` Marc-André Lureau
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 1/2] " Laurent Vivier
0 siblings, 1 reply; 11+ messages in thread
From: Marc-André Lureau @ 2015-08-27 21:37 UTC (permalink / raw)
To: Laurent Vivier; +Cc: Paolo Bonzini, QEMU, Markus Armbruster
Hi
On Thu, Aug 27, 2015 at 7:07 PM, Laurent Vivier <lvivier@redhat.com> wrote:
> As '-help' output is 400 lines long it is not easy
> to find information, but generally we know from
> which area we want the information.
>
> As subsections already exist in the help description,
> add some command options to only display the wanted
> subsection.
>
> As more is better, this patch adds 13 lines to the -help output:
>
> -help-standard display standard options
> -help-block display block options
> -help-usb display usb options
> -help-display display display options
> -help-machine display machine options
> -help-network display network options
> -help-character display character options
> -help-url display url options
> -help-bt display bt options
> -help-tpm display tpm options
> -help-kernel display kernel options
> -help-expert display expert options
> -help-object display object options
>
> Example:
>
> $ qemu-system-x86_64 -help-kernel
> Linux/Multiboot boot specific:
> -kernel bzImage use 'bzImage' as kernel image
> -append cmdline use 'cmdline' as kernel command line
> -initrd file use 'file' as initial ram disk
> -dtb file use 'file' as device tree image
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v2: simplify the dance of #define/#undef, thanks to Marc-André.
>
> qemu-options.hx | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> vl.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 280 insertions(+), 4 deletions(-)
>
Looks good to me & works fine
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
I would prefer to not have all the --help-* in --help-standard, but
that's quite minor. But if you agree, it's perhaps worth the extra
effort though
thanks
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 77f5853..49b78df 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -6,17 +6,123 @@ HXCOMM construct option structures, enums and help message for specified
> HXCOMM architectures.
> HXCOMM HXCOMM can be used for comments, discarded from both texi and C
>
> +#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_STANDARD
> DEFHEADING(Standard options:)
> STEXI
> @table @option
> ETEXI
>
> DEF("help", 0, QEMU_OPTION_h,
> - "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
> + "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
> STEXI
> @item -h
> @findex -h
> -Display help and exit
> +Display all help options and exit
> +ETEXI
> +
> +DEF("help-standard", 0, QEMU_OPTION_h_standard,
> + "-help-standard display standard options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-standard
> +@findex -help-standard
> +Display standard options
> +ETEXI
> +
> +DEF("help-block", 0, QEMU_OPTION_h_block,
> + "-help-block display block options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-block
> +@findex -help-block
> +Display block options
> +ETEXI
> +
> +DEF("help-usb", 0, QEMU_OPTION_h_usb,
> + "-help-usb display usb options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-usb
> +@findex -help-usb
> +Display usb options
> +ETEXI
> +
> +DEF("help-display", 0, QEMU_OPTION_h_display,
> + "-help-display display display options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-display
> +@findex -help-display
> +Display display options
> +ETEXI
> +
> +DEF("help-machine", 0, QEMU_OPTION_h_machine,
> + "-help-machine display machine options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-machine
> +@findex -help-machine
> +Display machine options
> +ETEXI
> +
> +DEF("help-network", 0, QEMU_OPTION_h_network,
> + "-help-network display network options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-network
> +@findex -help-network
> +Display network options
> +ETEXI
> +
> +DEF("help-character", 0, QEMU_OPTION_h_character,
> + "-help-character display character options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-character
> +@findex -help-character
> +Display character options
> +ETEXI
> +
> +DEF("help-url", 0, QEMU_OPTION_h_url,
> + "-help-url display url options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-url
> +@findex -help-url
> +Display url options
> +ETEXI
> +
> +DEF("help-bt", 0, QEMU_OPTION_h_bt,
> + "-help-bt display bt options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-bt
> +@findex -help-bt
> +Display bt options
> +ETEXI
> +
> +DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
> + "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-tpm
> +@findex -help-tpm
> +Display tpm options
> +ETEXI
> +
> +DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
> + "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-kernel
> +@findex -help-kernel
> +Display kernel options
> +ETEXI
> +
> +DEF("help-expert", 0, QEMU_OPTION_h_expert,
> + "-help-expert display expert options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-expert
> +@findex -help-expert
> +Display expert options
> +ETEXI
> +
> +DEF("help-object", 0, QEMU_OPTION_h_object,
> + "-help-object display object options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-object
> +@findex -help-object
> +Display object options
> ETEXI
>
> DEF("version", 0, QEMU_OPTION_version,
> @@ -410,7 +516,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_BLOCK) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_BLOCK
> DEFHEADING(Block device options:)
> STEXI
> @table @option
> @@ -798,7 +907,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_USB) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_USB
> DEFHEADING(USB options:)
> STEXI
> @table @option
> @@ -862,7 +974,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_DISPLAY) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_DISPLAY
> DEFHEADING(Display options:)
> STEXI
> @table @option
> @@ -1329,7 +1444,10 @@ STEXI
> @end table
> ETEXI
> ARCHHEADING(, QEMU_ARCH_I386)
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_MACHINE) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_MACHINE
> ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
> STEXI
> @table @option
> @@ -1441,7 +1559,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_NETWORK) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_NETWORK
> DEFHEADING(Network options:)
> STEXI
> @table @option
> @@ -1995,7 +2116,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_CHARACTER) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_CHARACTER
> DEFHEADING(Character device options:)
> STEXI
>
> @@ -2273,7 +2397,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_URL) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_URL
> DEFHEADING(Device URL Syntax:)
> STEXI
>
> @@ -2482,7 +2609,10 @@ ETEXI
> STEXI
> @end table
> ETEXI
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_BT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_BT
> DEFHEADING(Bluetooth(R) options:)
> STEXI
> @table @option
> @@ -2557,7 +2687,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_TPM) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_TPM
> #ifdef CONFIG_TPM
> DEFHEADING(TPM device options:)
>
> @@ -2632,7 +2765,10 @@ ETEXI
> DEFHEADING()
>
> #endif
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_KERNEL) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_KERNEL
> DEFHEADING(Linux/Multiboot boot specific:)
> STEXI
>
> @@ -2688,7 +2824,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_EXPERT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_EXPERT
> DEFHEADING(Debug/Expert options:)
> STEXI
> @table @option
> @@ -3510,7 +3649,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
> " Output vmstate information in JSON format to file.\n"
> " Use the scripts/vmstate-static-checker.py file to\n"
> " check for possible regressions in migration code\n"
> - " by comparing two such vmstate dumps.",
> + " by comparing two such vmstate dumps.\n",
> QEMU_ARCH_ALL)
> STEXI
> @item -dump-vmstate @var{file}
> @@ -3518,7 +3657,10 @@ STEXI
> Dump json-encoded vmstate information for current machine type to file
> in @var{file}
> ETEXI
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_OBJECT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_OBJECT
> DEFHEADING(Generic object creation)
>
> DEF("object", HAS_ARG, QEMU_OPTION_object,
> @@ -3571,7 +3713,7 @@ to the RNG daemon.
> @end table
>
> ETEXI
> -
> +#endif
>
> HXCOMM This is the last statement. Insert new options before this line!
> STEXI
> diff --git a/vl.c b/vl.c
> index 584ca88..e581dd2 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1931,6 +1931,101 @@ static void help(int exitcode)
> exit(exitcode);
> }
>
> +#define QEMU_HELP_SELECT
> +static void help_standard(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_STANDARD
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_block(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_BLOCK
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_usb(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_USB
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_display(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_DISPLAY
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_machine(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_MACHINE
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_network(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_NETWORK
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_character(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_CHARACTER
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_url(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_URL
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_bt(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_BT
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_tpm(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_TPM
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_kernel(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_KERNEL
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_expert(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_EXPERT
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_object(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_OBJECT
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#undef QEMU_HELP_SELECT
> +
> +
> #define HAS_ARG 0x0001
>
> typedef struct QEMUOption {
> @@ -3318,6 +3413,42 @@ int main(int argc, char **argv, char **envp)
> case QEMU_OPTION_h:
> help(0);
> break;
> + case QEMU_OPTION_h_standard:
> + help_standard(0);
> + break;
> + case QEMU_OPTION_h_block:
> + help_block(0);
> + break;
> + case QEMU_OPTION_h_usb:
> + help_usb(0);
> + break;
> + case QEMU_OPTION_h_display:
> + help_display(0);
> + break;
> + case QEMU_OPTION_h_machine:
> + help_machine(0);
> + break;
> + case QEMU_OPTION_h_network:
> + help_network(0);
> + break;
> + case QEMU_OPTION_h_character:
> + help_character(0);
> + break;
> + case QEMU_OPTION_h_url:
> + help_url(0);
> + break;
> + case QEMU_OPTION_h_bt:
> + help_bt(0);
> + break;
> + case QEMU_OPTION_h_kernel:
> + help_kernel(0);
> + break;
> + case QEMU_OPTION_h_expert:
> + help_expert(0);
> + break;
> + case QEMU_OPTION_h_object:
> + help_object(0);
> + break;
> case QEMU_OPTION_version:
> version();
> exit(0);
> @@ -3330,6 +3461,9 @@ int main(int argc, char **argv, char **envp)
> }
> break;
> #ifdef CONFIG_TPM
> + case QEMU_OPTION_h_tpm:
> + help_tpm(0);
> + break;
> case QEMU_OPTION_tpmdev:
> if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
> exit(1);
> --
> 2.1.0
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options
2015-08-27 21:37 ` Marc-André Lureau
@ 2015-08-27 22:22 ` Laurent Vivier
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands Laurent Vivier
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Laurent Vivier @ 2015-08-27 22:22 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
As '-help' output is 400 lines long it is not easy
to find information, but generally we know from
which area we want the information.
As subsections already exist in the help description,
add some command options to only display the wanted
subsection.
As more is better, this patch adds 13 lines to the -help output:
-help-standard display standard options
-help-block display block options
-help-usb display usb options
-help-display display display options
-help-machine display machine options
-help-network display network options
-help-character display character options
-help-url display url options
-help-bt display bt options
-help-tpm display tpm options
-help-kernel display kernel options
-help-expert display expert options
-help-object display object options
Example:
$ qemu-system-x86_64 -help-kernel
Linux/Multiboot boot specific:
-kernel bzImage use 'bzImage' as kernel image
-append cmdline use 'cmdline' as kernel command line
-initrd file use 'file' as initial ram disk
-dtb file use 'file' as device tree image
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
v3: add a 2nd patch to add an help section, -help displays only this section
v2: simplify the dance of #define/#undef, thanks to Marc-André.
qemu-options.hx | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
vl.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 280 insertions(+), 4 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 77f5853..49b78df 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -6,17 +6,123 @@ HXCOMM construct option structures, enums and help message for specified
HXCOMM architectures.
HXCOMM HXCOMM can be used for comments, discarded from both texi and C
+#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_STANDARD
DEFHEADING(Standard options:)
STEXI
@table @option
ETEXI
DEF("help", 0, QEMU_OPTION_h,
- "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
+ "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
STEXI
@item -h
@findex -h
-Display help and exit
+Display all help options and exit
+ETEXI
+
+DEF("help-standard", 0, QEMU_OPTION_h_standard,
+ "-help-standard display standard options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-standard
+@findex -help-standard
+Display standard options
+ETEXI
+
+DEF("help-block", 0, QEMU_OPTION_h_block,
+ "-help-block display block options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-block
+@findex -help-block
+Display block options
+ETEXI
+
+DEF("help-usb", 0, QEMU_OPTION_h_usb,
+ "-help-usb display usb options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-usb
+@findex -help-usb
+Display usb options
+ETEXI
+
+DEF("help-display", 0, QEMU_OPTION_h_display,
+ "-help-display display display options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-display
+@findex -help-display
+Display display options
+ETEXI
+
+DEF("help-machine", 0, QEMU_OPTION_h_machine,
+ "-help-machine display machine options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-machine
+@findex -help-machine
+Display machine options
+ETEXI
+
+DEF("help-network", 0, QEMU_OPTION_h_network,
+ "-help-network display network options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-network
+@findex -help-network
+Display network options
+ETEXI
+
+DEF("help-character", 0, QEMU_OPTION_h_character,
+ "-help-character display character options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-character
+@findex -help-character
+Display character options
+ETEXI
+
+DEF("help-url", 0, QEMU_OPTION_h_url,
+ "-help-url display url options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-url
+@findex -help-url
+Display url options
+ETEXI
+
+DEF("help-bt", 0, QEMU_OPTION_h_bt,
+ "-help-bt display bt options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-bt
+@findex -help-bt
+Display bt options
+ETEXI
+
+DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
+ "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-tpm
+@findex -help-tpm
+Display tpm options
+ETEXI
+
+DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
+ "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-kernel
+@findex -help-kernel
+Display kernel options
+ETEXI
+
+DEF("help-expert", 0, QEMU_OPTION_h_expert,
+ "-help-expert display expert options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-expert
+@findex -help-expert
+Display expert options
+ETEXI
+
+DEF("help-object", 0, QEMU_OPTION_h_object,
+ "-help-object display object options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-object
+@findex -help-object
+Display object options
ETEXI
DEF("version", 0, QEMU_OPTION_version,
@@ -410,7 +516,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_BLOCK) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_BLOCK
DEFHEADING(Block device options:)
STEXI
@table @option
@@ -798,7 +907,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_USB) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_USB
DEFHEADING(USB options:)
STEXI
@table @option
@@ -862,7 +974,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_DISPLAY) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_DISPLAY
DEFHEADING(Display options:)
STEXI
@table @option
@@ -1329,7 +1444,10 @@ STEXI
@end table
ETEXI
ARCHHEADING(, QEMU_ARCH_I386)
+#endif
+#if defined(QEMU_HELP_SELECT_MACHINE) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_MACHINE
ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
STEXI
@table @option
@@ -1441,7 +1559,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_NETWORK) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_NETWORK
DEFHEADING(Network options:)
STEXI
@table @option
@@ -1995,7 +2116,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_CHARACTER) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_CHARACTER
DEFHEADING(Character device options:)
STEXI
@@ -2273,7 +2397,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_URL) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_URL
DEFHEADING(Device URL Syntax:)
STEXI
@@ -2482,7 +2609,10 @@ ETEXI
STEXI
@end table
ETEXI
+#endif
+#if defined(QEMU_HELP_SELECT_BT) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_BT
DEFHEADING(Bluetooth(R) options:)
STEXI
@table @option
@@ -2557,7 +2687,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_TPM) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_TPM
#ifdef CONFIG_TPM
DEFHEADING(TPM device options:)
@@ -2632,7 +2765,10 @@ ETEXI
DEFHEADING()
#endif
+#endif
+#if defined(QEMU_HELP_SELECT_KERNEL) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_KERNEL
DEFHEADING(Linux/Multiboot boot specific:)
STEXI
@@ -2688,7 +2824,10 @@ STEXI
@end table
ETEXI
DEFHEADING()
+#endif
+#if defined(QEMU_HELP_SELECT_EXPERT) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_EXPERT
DEFHEADING(Debug/Expert options:)
STEXI
@table @option
@@ -3510,7 +3649,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
" Output vmstate information in JSON format to file.\n"
" Use the scripts/vmstate-static-checker.py file to\n"
" check for possible regressions in migration code\n"
- " by comparing two such vmstate dumps.",
+ " by comparing two such vmstate dumps.\n",
QEMU_ARCH_ALL)
STEXI
@item -dump-vmstate @var{file}
@@ -3518,7 +3657,10 @@ STEXI
Dump json-encoded vmstate information for current machine type to file
in @var{file}
ETEXI
+#endif
+#if defined(QEMU_HELP_SELECT_OBJECT) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_OBJECT
DEFHEADING(Generic object creation)
DEF("object", HAS_ARG, QEMU_OPTION_object,
@@ -3571,7 +3713,7 @@ to the RNG daemon.
@end table
ETEXI
-
+#endif
HXCOMM This is the last statement. Insert new options before this line!
STEXI
diff --git a/vl.c b/vl.c
index 584ca88..e581dd2 100644
--- a/vl.c
+++ b/vl.c
@@ -1931,6 +1931,101 @@ static void help(int exitcode)
exit(exitcode);
}
+#define QEMU_HELP_SELECT
+static void help_standard(int exitcode)
+{
+#define QEMU_HELP_SELECT_STANDARD
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_block(int exitcode)
+{
+#define QEMU_HELP_SELECT_BLOCK
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_usb(int exitcode)
+{
+#define QEMU_HELP_SELECT_USB
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_display(int exitcode)
+{
+#define QEMU_HELP_SELECT_DISPLAY
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_machine(int exitcode)
+{
+#define QEMU_HELP_SELECT_MACHINE
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_network(int exitcode)
+{
+#define QEMU_HELP_SELECT_NETWORK
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_character(int exitcode)
+{
+#define QEMU_HELP_SELECT_CHARACTER
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_url(int exitcode)
+{
+#define QEMU_HELP_SELECT_URL
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_bt(int exitcode)
+{
+#define QEMU_HELP_SELECT_BT
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_tpm(int exitcode)
+{
+#define QEMU_HELP_SELECT_TPM
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_kernel(int exitcode)
+{
+#define QEMU_HELP_SELECT_KERNEL
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_expert(int exitcode)
+{
+#define QEMU_HELP_SELECT_EXPERT
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+static void help_object(int exitcode)
+{
+#define QEMU_HELP_SELECT_OBJECT
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
+#undef QEMU_HELP_SELECT
+
+
#define HAS_ARG 0x0001
typedef struct QEMUOption {
@@ -3318,6 +3413,42 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_h:
help(0);
break;
+ case QEMU_OPTION_h_standard:
+ help_standard(0);
+ break;
+ case QEMU_OPTION_h_block:
+ help_block(0);
+ break;
+ case QEMU_OPTION_h_usb:
+ help_usb(0);
+ break;
+ case QEMU_OPTION_h_display:
+ help_display(0);
+ break;
+ case QEMU_OPTION_h_machine:
+ help_machine(0);
+ break;
+ case QEMU_OPTION_h_network:
+ help_network(0);
+ break;
+ case QEMU_OPTION_h_character:
+ help_character(0);
+ break;
+ case QEMU_OPTION_h_url:
+ help_url(0);
+ break;
+ case QEMU_OPTION_h_bt:
+ help_bt(0);
+ break;
+ case QEMU_OPTION_h_kernel:
+ help_kernel(0);
+ break;
+ case QEMU_OPTION_h_expert:
+ help_expert(0);
+ break;
+ case QEMU_OPTION_h_object:
+ help_object(0);
+ break;
case QEMU_OPTION_version:
version();
exit(0);
@@ -3330,6 +3461,9 @@ int main(int argc, char **argv, char **envp)
}
break;
#ifdef CONFIG_TPM
+ case QEMU_OPTION_h_tpm:
+ help_tpm(0);
+ break;
case QEMU_OPTION_tpmdev:
if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
exit(1);
--
2.1.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 1/2] " Laurent Vivier
@ 2015-08-27 22:22 ` Laurent Vivier
2015-09-02 17:06 ` Eric Blake
2015-08-27 22:43 ` [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options Eric Blake
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Laurent Vivier @ 2015-08-27 22:22 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
A slight change of behavior:
-help-all displays all helps (like -help/-h before)
-help/-h lists only the available help commands
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
v3: add this patch to add an help section, -help displays only this section
qemu-options.hx | 29 +++++++++++++++++++++++++----
vl.c | 12 +++++++++++-
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/qemu-options.hx b/qemu-options.hx
index 49b78df..f89d4e2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -6,21 +6,29 @@ HXCOMM construct option structures, enums and help message for specified
HXCOMM architectures.
HXCOMM HXCOMM can be used for comments, discarded from both texi and C
-#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
-#undef QEMU_HELP_SELECT_STANDARD
-DEFHEADING(Standard options:)
+#if defined(QEMU_HELP_SELECT_HELP) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_HELP
+DEFHEADING(Help/version options:)
STEXI
@table @option
ETEXI
DEF("help", 0, QEMU_OPTION_h,
- "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
+ "-h or -help list all help options\n", QEMU_ARCH_ALL)
STEXI
@item -h
@findex -h
Display all help options and exit
ETEXI
+DEF("help-all", 0, QEMU_OPTION_h_all,
+ "-help-all display all help options\n", QEMU_ARCH_ALL)
+STEXI
+@item -help-all
+@findex -help-all
+Display all help options and exit
+ETEXI
+
DEF("help-standard", 0, QEMU_OPTION_h_standard,
"-help-standard display standard options\n", QEMU_ARCH_ALL)
STEXI
@@ -133,6 +141,19 @@ STEXI
Display version information and exit
ETEXI
+STEXI
+@end table
+ETEXI
+DEFHEADING()
+#endif
+
+#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
+#undef QEMU_HELP_SELECT_STANDARD
+DEFHEADING(Standard options:)
+STEXI
+@table @option
+ETEXI
+
DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
"-machine [type=]name[,prop[=value][,...]]\n"
" selects emulated machine ('-machine help' for list)\n"
diff --git a/vl.c b/vl.c
index e581dd2..85d02cb 100644
--- a/vl.c
+++ b/vl.c
@@ -1911,7 +1911,7 @@ static void version(void)
printf("QEMU emulator version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n");
}
-static void help(int exitcode)
+static void help_all(int exitcode)
{
version();
printf("usage: %s [options] [disk_image]\n\n"
@@ -1932,6 +1932,13 @@ static void help(int exitcode)
}
#define QEMU_HELP_SELECT
+static void help(int exitcode)
+{
+#define QEMU_HELP_SELECT_HELP
+#define QEMU_OPTIONS_GENERATE_HELP
+#include "qemu-options-wrapper.h"
+ exit(exitcode);
+}
static void help_standard(int exitcode)
{
#define QEMU_HELP_SELECT_STANDARD
@@ -3413,6 +3420,9 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_h:
help(0);
break;
+ case QEMU_OPTION_h_all:
+ help_all(0);
+ break;
case QEMU_OPTION_h_standard:
help_standard(0);
break;
--
2.1.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands Laurent Vivier
@ 2015-09-02 17:06 ` Eric Blake
0 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2015-09-02 17:06 UTC (permalink / raw)
To: Laurent Vivier, Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
[-- Attachment #1: Type: text/plain, Size: 1202 bytes --]
On 08/27/2015 04:22 PM, Laurent Vivier wrote:
> A slight change of behavior:
>
> -help-all displays all helps (like -help/-h before)
> -help/-h lists only the available help commands
I like the change. However, I think that it is missing the overall
summary; bare help should still include the lead-in lines that mention
usage; I'm less concerned if the version line is present (we have
--version for that), but it may be easier to include it too. That is,
this part from pre-patch should probably still show:
$ ./x86_64-softmmu/qemu-system-x86_64 --help
QEMU emulator version 2.4.50, Copyright (c) 2003-2008 Fabrice Bellard
usage: qemu-system-x86_64 [options] [disk_image]
'disk_image' is a raw hard disk image for IDE hard disk 0
Help/version options:
...
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v3: add this patch to add an help section, -help displays only this section
> qemu-options.hx | 29 +++++++++++++++++++++++++----
> vl.c | 12 +++++++++++-
> 2 files changed, 36 insertions(+), 5 deletions(-)
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 1/2] " Laurent Vivier
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands Laurent Vivier
@ 2015-08-27 22:43 ` Eric Blake
2015-09-02 16:45 ` Laurent Vivier
2015-09-02 17:02 ` Eric Blake
3 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2015-08-27 22:43 UTC (permalink / raw)
To: Laurent Vivier, Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
On 08/27/2015 04:22 PM, Laurent Vivier wrote:
> As '-help' output is 400 lines long it is not easy
> to find information, but generally we know from
> which area we want the information.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v3: add a 2nd patch to add an help section, -help displays only this section
> v2: simplify the dance of #define/#undef, thanks to Marc-André.
It's best to send new versions as new top-level threads; some of the
maintainer tooling doesn't respond well to patches embedded as replies
to existing threads.
http://wiki.qemu.org/Contribute/SubmitAPatch
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 1/2] " Laurent Vivier
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands Laurent Vivier
2015-08-27 22:43 ` [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options Eric Blake
@ 2015-09-02 16:45 ` Laurent Vivier
2015-09-02 17:02 ` Eric Blake
3 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2015-09-02 16:45 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
Any comments on this series ?
On 28/08/2015 00:22, Laurent Vivier wrote:
> As '-help' output is 400 lines long it is not easy
> to find information, but generally we know from
> which area we want the information.
>
> As subsections already exist in the help description,
> add some command options to only display the wanted
> subsection.
>
> As more is better, this patch adds 13 lines to the -help output:
>
> -help-standard display standard options
> -help-block display block options
> -help-usb display usb options
> -help-display display display options
> -help-machine display machine options
> -help-network display network options
> -help-character display character options
> -help-url display url options
> -help-bt display bt options
> -help-tpm display tpm options
> -help-kernel display kernel options
> -help-expert display expert options
> -help-object display object options
>
> Example:
>
> $ qemu-system-x86_64 -help-kernel
> Linux/Multiboot boot specific:
> -kernel bzImage use 'bzImage' as kernel image
> -append cmdline use 'cmdline' as kernel command line
> -initrd file use 'file' as initial ram disk
> -dtb file use 'file' as device tree image
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v3: add a 2nd patch to add an help section, -help displays only this section
> v2: simplify the dance of #define/#undef, thanks to Marc-André.
> qemu-options.hx | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> vl.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 280 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 77f5853..49b78df 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -6,17 +6,123 @@ HXCOMM construct option structures, enums and help message for specified
> HXCOMM architectures.
> HXCOMM HXCOMM can be used for comments, discarded from both texi and C
>
> +#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_STANDARD
> DEFHEADING(Standard options:)
> STEXI
> @table @option
> ETEXI
>
> DEF("help", 0, QEMU_OPTION_h,
> - "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
> + "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
> STEXI
> @item -h
> @findex -h
> -Display help and exit
> +Display all help options and exit
> +ETEXI
> +
> +DEF("help-standard", 0, QEMU_OPTION_h_standard,
> + "-help-standard display standard options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-standard
> +@findex -help-standard
> +Display standard options
> +ETEXI
> +
> +DEF("help-block", 0, QEMU_OPTION_h_block,
> + "-help-block display block options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-block
> +@findex -help-block
> +Display block options
> +ETEXI
> +
> +DEF("help-usb", 0, QEMU_OPTION_h_usb,
> + "-help-usb display usb options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-usb
> +@findex -help-usb
> +Display usb options
> +ETEXI
> +
> +DEF("help-display", 0, QEMU_OPTION_h_display,
> + "-help-display display display options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-display
> +@findex -help-display
> +Display display options
> +ETEXI
> +
> +DEF("help-machine", 0, QEMU_OPTION_h_machine,
> + "-help-machine display machine options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-machine
> +@findex -help-machine
> +Display machine options
> +ETEXI
> +
> +DEF("help-network", 0, QEMU_OPTION_h_network,
> + "-help-network display network options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-network
> +@findex -help-network
> +Display network options
> +ETEXI
> +
> +DEF("help-character", 0, QEMU_OPTION_h_character,
> + "-help-character display character options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-character
> +@findex -help-character
> +Display character options
> +ETEXI
> +
> +DEF("help-url", 0, QEMU_OPTION_h_url,
> + "-help-url display url options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-url
> +@findex -help-url
> +Display url options
> +ETEXI
> +
> +DEF("help-bt", 0, QEMU_OPTION_h_bt,
> + "-help-bt display bt options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-bt
> +@findex -help-bt
> +Display bt options
> +ETEXI
> +
> +DEF("help-tpm", 0, QEMU_OPTION_h_tpm,
> + "-help-tpm display tpm options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-tpm
> +@findex -help-tpm
> +Display tpm options
> +ETEXI
> +
> +DEF("help-kernel", 0, QEMU_OPTION_h_kernel,
> + "-help-kernel display kernel options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-kernel
> +@findex -help-kernel
> +Display kernel options
> +ETEXI
> +
> +DEF("help-expert", 0, QEMU_OPTION_h_expert,
> + "-help-expert display expert options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-expert
> +@findex -help-expert
> +Display expert options
> +ETEXI
> +
> +DEF("help-object", 0, QEMU_OPTION_h_object,
> + "-help-object display object options\n", QEMU_ARCH_ALL)
> +STEXI
> +@item -help-object
> +@findex -help-object
> +Display object options
> ETEXI
>
> DEF("version", 0, QEMU_OPTION_version,
> @@ -410,7 +516,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_BLOCK) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_BLOCK
> DEFHEADING(Block device options:)
> STEXI
> @table @option
> @@ -798,7 +907,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_USB) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_USB
> DEFHEADING(USB options:)
> STEXI
> @table @option
> @@ -862,7 +974,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_DISPLAY) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_DISPLAY
> DEFHEADING(Display options:)
> STEXI
> @table @option
> @@ -1329,7 +1444,10 @@ STEXI
> @end table
> ETEXI
> ARCHHEADING(, QEMU_ARCH_I386)
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_MACHINE) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_MACHINE
> ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
> STEXI
> @table @option
> @@ -1441,7 +1559,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_NETWORK) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_NETWORK
> DEFHEADING(Network options:)
> STEXI
> @table @option
> @@ -1995,7 +2116,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_CHARACTER) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_CHARACTER
> DEFHEADING(Character device options:)
> STEXI
>
> @@ -2273,7 +2397,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_URL) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_URL
> DEFHEADING(Device URL Syntax:)
> STEXI
>
> @@ -2482,7 +2609,10 @@ ETEXI
> STEXI
> @end table
> ETEXI
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_BT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_BT
> DEFHEADING(Bluetooth(R) options:)
> STEXI
> @table @option
> @@ -2557,7 +2687,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_TPM) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_TPM
> #ifdef CONFIG_TPM
> DEFHEADING(TPM device options:)
>
> @@ -2632,7 +2765,10 @@ ETEXI
> DEFHEADING()
>
> #endif
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_KERNEL) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_KERNEL
> DEFHEADING(Linux/Multiboot boot specific:)
> STEXI
>
> @@ -2688,7 +2824,10 @@ STEXI
> @end table
> ETEXI
> DEFHEADING()
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_EXPERT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_EXPERT
> DEFHEADING(Debug/Expert options:)
> STEXI
> @table @option
> @@ -3510,7 +3649,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
> " Output vmstate information in JSON format to file.\n"
> " Use the scripts/vmstate-static-checker.py file to\n"
> " check for possible regressions in migration code\n"
> - " by comparing two such vmstate dumps.",
> + " by comparing two such vmstate dumps.\n",
> QEMU_ARCH_ALL)
> STEXI
> @item -dump-vmstate @var{file}
> @@ -3518,7 +3657,10 @@ STEXI
> Dump json-encoded vmstate information for current machine type to file
> in @var{file}
> ETEXI
> +#endif
>
> +#if defined(QEMU_HELP_SELECT_OBJECT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_OBJECT
> DEFHEADING(Generic object creation)
>
> DEF("object", HAS_ARG, QEMU_OPTION_object,
> @@ -3571,7 +3713,7 @@ to the RNG daemon.
> @end table
>
> ETEXI
> -
> +#endif
>
> HXCOMM This is the last statement. Insert new options before this line!
> STEXI
> diff --git a/vl.c b/vl.c
> index 584ca88..e581dd2 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1931,6 +1931,101 @@ static void help(int exitcode)
> exit(exitcode);
> }
>
> +#define QEMU_HELP_SELECT
> +static void help_standard(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_STANDARD
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_block(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_BLOCK
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_usb(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_USB
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_display(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_DISPLAY
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_machine(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_MACHINE
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_network(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_NETWORK
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_character(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_CHARACTER
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_url(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_URL
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_bt(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_BT
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_tpm(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_TPM
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_kernel(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_KERNEL
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_expert(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_EXPERT
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +static void help_object(int exitcode)
> +{
> +#define QEMU_HELP_SELECT_OBJECT
> +#define QEMU_OPTIONS_GENERATE_HELP
> +#include "qemu-options-wrapper.h"
> + exit(exitcode);
> +}
> +#undef QEMU_HELP_SELECT
> +
> +
> #define HAS_ARG 0x0001
>
> typedef struct QEMUOption {
> @@ -3318,6 +3413,42 @@ int main(int argc, char **argv, char **envp)
> case QEMU_OPTION_h:
> help(0);
> break;
> + case QEMU_OPTION_h_standard:
> + help_standard(0);
> + break;
> + case QEMU_OPTION_h_block:
> + help_block(0);
> + break;
> + case QEMU_OPTION_h_usb:
> + help_usb(0);
> + break;
> + case QEMU_OPTION_h_display:
> + help_display(0);
> + break;
> + case QEMU_OPTION_h_machine:
> + help_machine(0);
> + break;
> + case QEMU_OPTION_h_network:
> + help_network(0);
> + break;
> + case QEMU_OPTION_h_character:
> + help_character(0);
> + break;
> + case QEMU_OPTION_h_url:
> + help_url(0);
> + break;
> + case QEMU_OPTION_h_bt:
> + help_bt(0);
> + break;
> + case QEMU_OPTION_h_kernel:
> + help_kernel(0);
> + break;
> + case QEMU_OPTION_h_expert:
> + help_expert(0);
> + break;
> + case QEMU_OPTION_h_object:
> + help_object(0);
> + break;
> case QEMU_OPTION_version:
> version();
> exit(0);
> @@ -3330,6 +3461,9 @@ int main(int argc, char **argv, char **envp)
> }
> break;
> #ifdef CONFIG_TPM
> + case QEMU_OPTION_h_tpm:
> + help_tpm(0);
> + break;
> case QEMU_OPTION_tpmdev:
> if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
> exit(1);
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 1/2] " Laurent Vivier
` (2 preceding siblings ...)
2015-09-02 16:45 ` Laurent Vivier
@ 2015-09-02 17:02 ` Eric Blake
3 siblings, 0 replies; 11+ messages in thread
From: Eric Blake @ 2015-09-02 17:02 UTC (permalink / raw)
To: Laurent Vivier, Paolo Bonzini, qemu-devel, marcandre.lureau; +Cc: armbru
[-- Attachment #1: Type: text/plain, Size: 4863 bytes --]
On 08/27/2015 04:22 PM, Laurent Vivier wrote:
> As '-help' output is 400 lines long it is not easy
> to find information, but generally we know from
> which area we want the information.
>
> As subsections already exist in the help description,
> add some command options to only display the wanted
> subsection.
>
> As more is better, this patch adds 13 lines to the -help output:
>
> -help-standard display standard options
> -help-block display block options
> -help-usb display usb options
> -help-display display display options
> -help-machine display machine options
> -help-network display network options
> -help-character display character options
> -help-url display url options
> -help-bt display bt options
> -help-tpm display tpm options
> -help-kernel display kernel options
> -help-expert display expert options
> -help-object display object options
Here you are proposing multiple options, which each cause an exit. If I do:
$ ./x86_64-softmmu/qemu-system-x86_64 --help-block --help-usb
I do NOT get usb help, because --help-block already caused an exit.
I think a nicer approach might be:
--help[=LIST]
so that I could do:
$ ./x86_64-softmmu/qemu-system-x86_64 --help
short help, that documents that I can add =LIST for more details
$ ./x86_64-softmmu/qemu-system-x86_64 --help=block,usb
both the block and usb help blurbs
$ ./x86_64-softmmu/qemu-system-x86_64 --help=all
all help
> Example:
>
> $ qemu-system-x86_64 -help-kernel
> Linux/Multiboot boot specific:
> -kernel bzImage use 'bzImage' as kernel image
> -append cmdline use 'cmdline' as kernel command line
> -initrd file use 'file' as initial ram disk
> -dtb file use 'file' as device tree image
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v3: add a 2nd patch to add an help section, -help displays only this section
> v2: simplify the dance of #define/#undef, thanks to Marc-André.
I like the idea of breaking help into sections, but think that adding
separate options rather than an optional list to a single option is more
useful. Also, I think you'll get a better review of v4 if it occurs as
a top-level thread.
> qemu-options.hx | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
> vl.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 280 insertions(+), 4 deletions(-)
>
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 77f5853..49b78df 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -6,17 +6,123 @@ HXCOMM construct option structures, enums and help message for specified
> HXCOMM architectures.
> HXCOMM HXCOMM can be used for comments, discarded from both texi and C
>
> +#if defined(QEMU_HELP_SELECT_STANDARD) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_STANDARD
> DEFHEADING(Standard options:)
> STEXI
> @table @option
> ETEXI
>
> DEF("help", 0, QEMU_OPTION_h,
> - "-h or -help display this help and exit\n", QEMU_ARCH_ALL)
> + "-h or -help display all help options and exit\n", QEMU_ARCH_ALL)
> STEXI
> @item -h
> @findex -h
> -Display help and exit
> +Display all help options and exit
> +ETEXI
> +
> +DEF("help-standard", 0, QEMU_OPTION_h_standard,
> + "-help-standard display standard options\n", QEMU_ARCH_ALL)
> +STEXI
This documents all the sub-helps up front. But I'd rather see a simple
'--help' to output at most a screenful of information; if that is not
possible, then I'd rather see the sub-helps mentioned at the END of the
long help (that is, if I don't know that --help is going to be multiple
screenfuls or that subhelps even exist, then the LAST thing left on my
screen should be the information that helps me further refine my next
command line).
> +#if defined(QEMU_HELP_SELECT_EXPERT) || !defined(QEMU_HELP_SELECT)
> +#undef QEMU_HELP_SELECT_EXPERT
> DEFHEADING(Debug/Expert options:)
> STEXI
> @table @option
> @@ -3510,7 +3649,7 @@ DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
> " Output vmstate information in JSON format to file.\n"
> " Use the scripts/vmstate-static-checker.py file to\n"
> " check for possible regressions in migration code\n"
> - " by comparing two such vmstate dumps.",
> + " by comparing two such vmstate dumps.\n",
> QEMU_ARCH_ALL)
It might help to separate minor whitespace changes (adding or
rearranging where newlines appear) to be a different patch than the one
turning on grouping.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-09-02 17:06 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27 15:20 [Qemu-devel] [PATCH, RFC] Use help sub-sections to create sub-help options Laurent Vivier
2015-08-27 15:44 ` Marc-André Lureau
2015-08-27 15:50 ` Laurent Vivier
2015-08-27 17:07 ` [Qemu-devel] [PATCH, RFC v2] " Laurent Vivier
2015-08-27 21:37 ` Marc-André Lureau
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 1/2] " Laurent Vivier
2015-08-27 22:22 ` [Qemu-devel] [PATCH v3 2/2] -help lists only -help-* commands Laurent Vivier
2015-09-02 17:06 ` Eric Blake
2015-08-27 22:43 ` [Qemu-devel] [PATCH v3 1/2] Use help sub-sections to create sub-help options Eric Blake
2015-09-02 16:45 ` Laurent Vivier
2015-09-02 17:02 ` Eric Blake
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).