vl.c: Add '-L help' which lists data dirs.
PATCH v3 1/1 vl.c: Add '-L help' which lists data dirs.
v2 -> v3:
- Use constants true/false for list_data_dirs variable.
Rich.
PATCH v3 1/1 vl.c: Add '-L help' which lists data dirs.
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
--- qemu-options.hx | 2 ++ vl.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)
qemu-options.hx +2 -0
@@ -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, \
vl.c +12 -1
@@ -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 = false;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 = true; + }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 */
Signature · 1 line
2.7.4
Any further objections to this one? It's a pretty useful patch for us.
Quoted 80 lines · Richard W.M. Jones
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/qemuSigned-off-by Richard W.M. Jones <[email protected]>Reviewed-by Eric Blake <[email protected]>--- qemu-options.hx | 2 ++ vl.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)qemu-options.hx +2
-0@@ -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, \vl.c +12
-1@@ -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 = false;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 = true; + }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 */ Signature · 1 line
2.7.4
Rich.
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Paolo Bonzini
AppliedQuoted 68 lines · Richard W.M. Jones
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/qemuSigned-off-by Richard W.M. Jones <[email protected]>Reviewed-by Eric Blake <[email protected]>--- qemu-options.hx | 2 ++ vl.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-)qemu-options.hx +2
-0@@ -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, \vl.c +5
-1@@ -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 = false;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 = true; + }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. */
vl.c int main(int argc, char **argv, char **envp) · line 4144
Quoted 10 lines
vl.c +7
-0+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 */
Queued, thanks.
Quoted 22 lines · Paolo Bonzini
Quoted 21 lines · Richard W.M. Jones
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/qemuSigned-off-by Richard W.M. Jones <[email protected]>Reviewed-by Eric Blake <[email protected]>
[...]
Quoted 1 line
Queued, thanks.
Thanks. This is a good patch and I think we should have it in qemu.
However the semi-related "bios-fast" patch needs more work, and so I'd like to withdraw that one from consideration (if it was being considered ..)
Rich.
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW