qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] RFC: Only display help options that are accepted by the architecture
@ 2011-12-12  8:14 Michael Ellerman
  2011-12-12  8:21 ` [Qemu-devel] [PATCH 1/3] Add arch mask to headings but don't use it yet Michael Ellerman
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2011-12-12  8:14 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* [Qemu-devel] [PATCH 1/3] Add arch mask to headings but don't use it yet
  2011-12-12  8:14 [Qemu-devel] RFC: Only display help options that are accepted by the architecture Michael Ellerman
@ 2011-12-12  8:21 ` Michael Ellerman
  2011-12-12  8:21   ` [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s Michael Ellerman
  2011-12-12  8:21   ` [Qemu-devel] [PATCH 3/3] In qemu -h output, only print options for the arch we are running as Michael Ellerman
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Ellerman @ 2011-12-12  8:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Ellerman

Make it possible to specify what architecture a heading in the help
doco applies to.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>

---

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(-)

diff --git a/qemu-options.h b/qemu-options.h
index c96f994..c8c3022 100644
--- a/qemu-options.h
+++ b/qemu-options.h
@@ -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
diff --git a/qemu-options.hx b/qemu-options.hx
index 681eaf1..cf03763 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -6,7 +6,7 @@ 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
 
-DEFHEADING(Standard options:)
+DEFHEADING(Standard options:, QEMU_ARCH_ALL)
 STEXI
 @table @option
 ETEXI
@@ -525,9 +525,9 @@ possible drivers and properties, use @code{-device ?} and
 @code{-device @var{driver},?}.
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
-DEFHEADING(File system options:)
+DEFHEADING(File system options:, QEMU_ARCH_ALL)
 
 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
     "-fsdev fsdriver,id=id,path=path,[security_model={mapped|passthrough|none}]\n"
@@ -583,9 +583,9 @@ Specifies the tag name to be used by the guest to mount this export point
 
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
-DEFHEADING(Virtual File system pass-through options:)
+DEFHEADING(Virtual File system pass-through options:, QEMU_ARCH_ALL)
 
 DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
     "-virtfs local,path=path,mount_tag=tag,security_model=[mapped|passthrough|none]\n"
@@ -640,7 +640,7 @@ STEXI
 Create synthetic file system image
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
 DEF("name", HAS_ARG, QEMU_OPTION_name,
     "-name string1[,process=string2]\n"
@@ -669,9 +669,9 @@ STEXI
 @end table
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
-DEFHEADING(Display options:)
+DEFHEADING(Display options:, QEMU_ARCH_ALL)
 
 STEXI
 @table @option
@@ -1062,9 +1062,9 @@ STEXI
 @end table
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_I386)
 
-DEFHEADING(i386 target only:)
+DEFHEADING(i386 target only:, QEMU_ARCH_I386)
 STEXI
 @table @option
 ETEXI
@@ -1160,12 +1160,12 @@ Specify SMBIOS type 0 fields
 Specify SMBIOS type 1 fields
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 STEXI
 @end table
 ETEXI
 
-DEFHEADING(Network options:)
+DEFHEADING(Network options:, QEMU_ARCH_ALL)
 STEXI
 @table @option
 ETEXI
@@ -1484,9 +1484,9 @@ is activated if no @option{-net} options are provided.
 @end table
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
-DEFHEADING(Character device options:)
+DEFHEADING(Character device options:, QEMU_ARCH_ALL)
 
 DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
     "-chardev null,id=id[,mux=on|off]\n"
@@ -1734,10 +1734,10 @@ Connect to a spice virtual machine channel, such as vdiport.
 @end table
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
 STEXI
-DEFHEADING(Device URL Syntax:)
+DEFHEADING(Device URL Syntax:, QEMU_ARCH_ALL)
 
 In addition to using normal file images for the emulated storage devices,
 QEMU can also use networked resources such as iSCSI devices. These are
@@ -1823,7 +1823,7 @@ See also @url{http://http://www.osrg.net/sheepdog/}.
 @end table
 ETEXI
 
-DEFHEADING(Bluetooth(R) options:)
+DEFHEADING(Bluetooth(R) options:, QEMU_ARCH_ALL)
 
 DEF("bt", HAS_ARG, QEMU_OPTION_bt, \
     "-bt hci,null    dumb bluetooth HCI - doesn't respond to commands\n" \
@@ -1893,9 +1893,9 @@ Virtual wireless keyboard implementing the HIDP bluetooth profile.
 @end table
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
-DEFHEADING(Linux/Multiboot boot specific:)
+DEFHEADING(Linux/Multiboot boot specific:, QEMU_ARCH_ALL)
 STEXI
 
 When using these options, you can use a given Linux or Multiboot
@@ -1941,9 +1941,9 @@ STEXI
 @end table
 ETEXI
 
-DEFHEADING()
+DEFHEADING(, QEMU_ARCH_ALL)
 
-DEFHEADING(Debug/Expert options:)
+DEFHEADING(Debug/Expert options:, QEMU_ARCH_ALL)
 
 STEXI
 @table @option
diff --git a/scripts/hxtool b/scripts/hxtool
index 7ca83ed..8d07f01 100644
--- a/scripts/hxtool
+++ b/scripts/hxtool
@@ -45,7 +45,7 @@ hxtotexi()
             fi
             ;;
             DEFHEADING*)
-            echo "$(expr "$str" : "DEFHEADING(\(.*\))")"
+            echo "$(expr "$str" : "DEFHEADING(\(.*\),.*)")"
             ;;
             *)
             test $flag -eq 1 && echo "$str"
diff --git a/vl.c b/vl.c
index a50842b..6a2ca6f 100644
--- a/vl.c
+++ b/vl.c
@@ -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
-- 
1.7.7.3

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

* [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s
  2011-12-12  8:21 ` [Qemu-devel] [PATCH 1/3] Add arch mask to headings but don't use it yet Michael Ellerman
@ 2011-12-12  8:21   ` Michael Ellerman
  2011-12-12  9:40     ` Andreas Färber
  2011-12-12  8:21   ` [Qemu-devel] [PATCH 3/3] In qemu -h output, only print options for the arch we are running as Michael Ellerman
  1 sibling, 1 reply; 5+ messages in thread
From: Michael Ellerman @ 2011-12-12  8:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Ellerman

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.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 vl.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index 6a2ca6f..b492f8c 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
 }
-- 
1.7.7.3

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

* [Qemu-devel] [PATCH 3/3] In qemu -h output, only print options for the arch we are running as
  2011-12-12  8:21 ` [Qemu-devel] [PATCH 1/3] Add arch mask to headings but don't use it yet Michael Ellerman
  2011-12-12  8:21   ` [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s Michael Ellerman
@ 2011-12-12  8:21   ` Michael Ellerman
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2011-12-12  8:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Ellerman

Only print options in the help output that are accepted by our arch.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 vl.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/vl.c b/vl.c
index b492f8c..ba8e76d 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
 }
 
-- 
1.7.7.3

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

* Re: [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s
  2011-12-12  8:21   ` [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s Michael Ellerman
@ 2011-12-12  9:40     ` Andreas Färber
  0 siblings, 0 replies; 5+ messages in thread
From: Andreas Färber @ 2011-12-12  9:40 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: qemu-devel

Am 12.12.2011 09:21, schrieb Michael Ellerman:
> 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.

I would rather propose to save argv[0] and use that. By now "qemu" is
not even correct for i386.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

end of thread, other threads:[~2011-12-12  9:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-12  8:14 [Qemu-devel] RFC: Only display help options that are accepted by the architecture Michael Ellerman
2011-12-12  8:21 ` [Qemu-devel] [PATCH 1/3] Add arch mask to headings but don't use it yet Michael Ellerman
2011-12-12  8:21   ` [Qemu-devel] [PATCH 2/3] vl.c: Fold constant string into printf rather than using %s Michael Ellerman
2011-12-12  9:40     ` Andreas Färber
2011-12-12  8:21   ` [Qemu-devel] [PATCH 3/3] In qemu -h output, only print options for the arch we are running as Michael Ellerman

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).