qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vl.c: Add '-L help' which lists data dirs.
@ 2016-05-16 13:37 Richard W.M. Jones
  2016-05-16 13:37 ` Richard W.M. Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Richard W.M. Jones @ 2016-05-16 13:37 UTC (permalink / raw)
  To: pbonzini; +Cc: qemu-devel, berrange, peter.maydell

v1 -> v2:

Avoid mentioning -L ? in the manual, commit messages etc.
Because I'm using the is_help_option function, -L ? is still accepted.

Rich.

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

* [Qemu-devel] [PATCH v2] vl.c: Add '-L help' which lists data dirs.
  2016-05-16 13:37 [Qemu-devel] [PATCH v2] vl.c: Add '-L help' which lists data dirs Richard W.M. Jones
@ 2016-05-16 13:37 ` Richard W.M. Jones
  2016-05-16 16:01   ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: Richard W.M. Jones @ 2016-05-16 13:37 UTC (permalink / raw)
  To: pbonzini; +Cc: qemu-devel, berrange, peter.maydell

QEMU compiles a list of data directories from various sources.  When
consuming a QEMU binary it's useful to be able to get this list of
data directories: a primary reason is so you can list what BIOSes or
keymaps ship with this version of QEMU.  However without reproducing
the method that QEMU uses internally, it's not possible to get the
list of data directories.

This commit adds a simple '-L help' option that just lists out the
data directories as qemu calculates them:

$ ./x86_64-softmmu/qemu-system-x86_64 -L help
/home/rjones/d/qemu/pc-bios
/usr/local/share/qemu

$ ./x86_64-softmmu/qemu-system-x86_64 -L /tmp -L help
/tmp
/home/rjones/d/qemu/pc-bios
/usr/local/share/qemu

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
 qemu-options.hx |  2 ++
 vl.c            | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 6106520..bec0210 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3199,6 +3199,8 @@ STEXI
 @item -L  @var{path}
 @findex -L
 Set the directory for the BIOS, VGA BIOS and keymaps.
+
+To list all the data directories, use @code{-L help}.
 ETEXI
 
 DEF("bios", HAS_ARG, QEMU_OPTION_bios, \
diff --git a/vl.c b/vl.c
index 5fd22cb..b3c14e8 100644
--- a/vl.c
+++ b/vl.c
@@ -2990,6 +2990,7 @@ int main(int argc, char **argv, char **envp)
     FILE *vmstate_dump_file = NULL;
     Error *main_loop_err = NULL;
     Error *err = NULL;
+    bool list_data_dirs = 0;
 
     qemu_init_cpu_loop();
     qemu_mutex_lock_iothread();
@@ -3371,7 +3372,9 @@ int main(int argc, char **argv, char **envp)
                 add_device_config(DEV_GDB, optarg);
                 break;
             case QEMU_OPTION_L:
-                if (data_dir_idx < ARRAY_SIZE(data_dir)) {
+                if (is_help_option(optarg)) {
+                    list_data_dirs = 1;
+                } else if (data_dir_idx < ARRAY_SIZE(data_dir)) {
                     data_dir[data_dir_idx++] = optarg;
                 }
                 break;
@@ -4128,6 +4131,14 @@ int main(int argc, char **argv, char **envp)
         data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR;
     }
 
+    /* -L help lists the data directories and exits. */
+    if (list_data_dirs) {
+        for (i = 0; i < data_dir_idx; i++) {
+            printf("%s\n", data_dir[i]);
+        }
+        exit(0);
+    }
+
     smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
 
     machine_class->max_cpus = machine_class->max_cpus ?: 1; /* Default to UP */
-- 
2.7.4

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

* Re: [Qemu-devel] [PATCH v2] vl.c: Add '-L help' which lists data dirs.
  2016-05-16 13:37 ` Richard W.M. Jones
@ 2016-05-16 16:01   ` Eric Blake
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Blake @ 2016-05-16 16:01 UTC (permalink / raw)
  To: Richard W.M. Jones, pbonzini; +Cc: peter.maydell, qemu-devel

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

On 05/16/2016 07:37 AM, Richard W.M. Jones wrote:
> QEMU compiles a list of data directories from various sources.  When
> consuming a QEMU binary it's useful to be able to get this list of
> data directories: a primary reason is so you can list what BIOSes or
> keymaps ship with this version of QEMU.  However without reproducing
> the method that QEMU uses internally, it's not possible to get the
> list of data directories.
> 
> This commit adds a simple '-L help' option that just lists out the
> data directories as qemu calculates them:
> 
> $ ./x86_64-softmmu/qemu-system-x86_64 -L help
> /home/rjones/d/qemu/pc-bios
> /usr/local/share/qemu
> 
> $ ./x86_64-softmmu/qemu-system-x86_64 -L /tmp -L help
> /tmp
> /home/rjones/d/qemu/pc-bios
> /usr/local/share/qemu
> 
> Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
> ---
>  qemu-options.hx |  2 ++
>  vl.c            | 13 ++++++++++++-
>  2 files changed, 14 insertions(+), 1 deletion(-)

I'm in favor of the idea.

> +++ b/vl.c
> @@ -2990,6 +2990,7 @@ int main(int argc, char **argv, char **envp)
>      FILE *vmstate_dump_file = NULL;
>      Error *main_loop_err = NULL;
>      Error *err = NULL;
> +    bool list_data_dirs = 0;

s/0/false/ - might as well actually use the boolean type that we declared.

>  
>      qemu_init_cpu_loop();
>      qemu_mutex_lock_iothread();
> @@ -3371,7 +3372,9 @@ int main(int argc, char **argv, char **envp)
>                  add_device_config(DEV_GDB, optarg);
>                  break;
>              case QEMU_OPTION_L:
> -                if (data_dir_idx < ARRAY_SIZE(data_dir)) {
> +                if (is_help_option(optarg)) {
> +                    list_data_dirs = 1;

s/1/true/

With those changes, you can add:
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
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] 3+ messages in thread

end of thread, other threads:[~2016-05-16 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-16 13:37 [Qemu-devel] [PATCH v2] vl.c: Add '-L help' which lists data dirs Richard W.M. Jones
2016-05-16 13:37 ` Richard W.M. Jones
2016-05-16 16:01   ` 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).