RFC: Only display help options that are accepted by the architecture
Hi all,
As the subject says, this is an RFC.
I have a few patches (to follow), that change the help output from QEMU so that we only display options that are accepted by the arch of the running binary.
So for example qemu-system-ppc64 will not tell you about i386 options like -no-acpi, -no-hpet etc.
We already have almost all the information we need, it just requires actually filtering the options as we print them in the help text - and some related cruft, see the patches for details.
I'd argue it's generally a sane change, but it also has the benefit that it makes libvirt's life easier. For better or worse libvirt parses the output of qemu -h to see what options are supported. At the moment that is problematic because the ppc64 emulator claims to support -no-acpi etc. So with this change libvirt could more reliably determine what is supported.
cheers
PATCH 1/3 Add arch mask to headings but don't use it yet
Make it possible to specify what architecture a heading in the help doco applies to.
---
A possibly nicer way to do this would be to add a new macro, perhaps ARCHHEADING, that is used for architecture specific headings. That would make the help source nicer, in that most headings would just be DEFHEADINGS - but it would mean we need to #define/undef another set of macros at each location we include the options.
--- qemu-options.h | 2 +- qemu-options.hx | 42 +++++++++++++++++++++--------------------- scripts/hxtool | 2 +- vl.c | 4 ++-- 4 files changed, 25 insertions(+), 25 deletions(-)
qemu-options.h +1 -1
@@ -31,7 +31,7 @@ enum { #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ opt_enum, -#define DEFHEADING (text) +#define DEFHEADING (text, arch_mask)#include "qemu-options.def" #undef DEF#undef DEFHEADING
qemu-options.hx +21 -21
127 lines not on this page · raw message
scripts/hxtool +1 -1
@@ -45,7 +45,7 @@ hxtotexi() fi ;; DEFHEADING*) - echo "$(expr "$str" : "DEFHEADING(\(.*\))")" + echo "$(expr "$str" : "DEFHEADING(\(.*\),.*)")" ;; *) test $flag -eq 1 && echo "$str"
vl.c +2 -2
@@ -1495,7 +1495,7 @@ static void help(int exitcode)const char *options_help = #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ opt_help -#define DEFHEADING(text) stringify(text) "\n" +#define DEFHEADING(text, arch_mask) stringify(text) "\n"#include "qemu-options.def" #undef DEF#undef DEFHEADING
@@ -1531,7 +1531,7 @@ static const QEMUOption qemu_options[] = { { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, #define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ { option, opt_arg, opt_enum, arch_mask }, -#define DEFHEADING(text) +#define DEFHEADING(text, arch_mask) #include "qemu-options.def" #undef DEF #undef DEFHEADING
Signature · 1 line
1.7.7.3
PATCH 2/3 vl.c: Fold constant string into printf rather than using %s
In help() we do what boils down to:
printf("%s", "qemu");This seems to be an artifact of be995c27640a82c7056b6f53d02ec823570114e5 ("removed unused code"), which removed some ifdef'ery that used to print a different name depending on CONFIG_SOFTMMU.
But now that is gone and we always use "qemu" we may as well just put that in the format string.
--- vl.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
vl.c +1 -2
@@ -1502,7 +1502,7 @@ static void help(int exitcode)#undef GEN_DOCS ;version (); -printf ("usage: %s [options] [disk_image]\n" +printf ("usage: qemu [options] [disk_image]\n" "\n" "'disk_image' is a raw hard disk image for IDE hard disk 0\n" "\n"
@@ -1513,7 +1513,6 @@ static void help(int exitcode)"ctrl-alt toggle mouse and keyboard grab\n" "\n" "When using -nographic, press 'ctrl-a h' to get some help.\n" , -"qemu" , options_help);exit (exitcode); }
Signature · 1 line
1.7.7.3
Re: [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s
Am 12.12.2011 09:21, schrieb Michael Ellerman:
Quoted 10 lines
In
help()we do what boils down to:printf("%s", "qemu");This seems to be an artifact of
be995c27640a82c7056b6f53d02ec823570114e5("removed unused code"), which removed some ifdef'ery that used to print a different name depending onCONFIG_SOFTMMU.But now that is gone and we always use "qemu" we may as well just put that in the format string.
I would rather propose to save argv[0] and use that. By now "qemu" is not even correct for i386.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH 3/3 In qemu -h output, only print options for the arch we are running as
In reply to Michael EllermanOnly print options in the help output that are accepted by our arch.
--- vl.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-)
vl.c +17 -14
@@ -1492,28 +1492,31 @@ static void version(void)static void help (int exitcode) { -const char *options_help = -#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \ - opt_help -#define DEFHEADING(text, arch_mask) stringify(text) "\n" +version (); +printf ("usage: qemu [options] [disk_image]\n" +"\n" +"'disk_image' is a raw hard disk image for IDE hard disk 0\n\n" ); + +#define DEF (option, opt_arg, opt_enum, opt_help, arch_mask) \ + if ((arch_mask) & arch_type) \ + fputs(opt_help, stdout); + +#define DEFHEADING (text, arch_mask) \ + if ((arch_mask) & arch_type) \ + puts(stringify(text)); +#include "qemu-options.def" #undef DEF#undef DEFHEADING#undef GEN_DOCS - ; -version (); -printf ("usage: qemu [options] [disk_image]\n" -"\n" -"'disk_image' is a raw hard disk image for IDE hard disk 0\n" -"\n" -"%s\n" -"During emulation, the following keys are useful:\n" + +printf ("\nDuring emulation, the following keys are useful:\n" "ctrl-alt-f toggle full screen\n" "ctrl-alt-n switch to virtual console 'n'\n" "ctrl-alt toggle mouse and keyboard grab\n" "\n" -"When using -nographic, press 'ctrl-a h' to get some help.\n" , - options_help); +"When using -nographic, press 'ctrl-a h' to get some help.\n" ); +exit (exitcode); }
Signature · 1 line
1.7.7.3