* [Qemu-devel] [PATCH 0/2] Add --firmwarepath to configure
@ 2017-09-13 12:09 Gerd Hoffmann
2017-09-13 12:09 ` [Qemu-devel] [PATCH 1/2] add qemu_add_data_dir() Gerd Hoffmann
2017-09-13 12:09 ` [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure Gerd Hoffmann
0 siblings, 2 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2017-09-13 12:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
Patch #1 is a cleanup to factor out code and simplify patch #2 a bit.
Patch #2 is the actual change, see patch commit log for details.
Gerd Hoffmann (2):
add qemu_add_data_dir()
Add --firmwarepath to configure
configure | 6 ++++++
vl.c | 44 +++++++++++++++++++++++++++++++-------------
scripts/create_config | 2 +-
3 files changed, 38 insertions(+), 14 deletions(-)
--
2.9.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 1/2] add qemu_add_data_dir()
2017-09-13 12:09 [Qemu-devel] [PATCH 0/2] Add --firmwarepath to configure Gerd Hoffmann
@ 2017-09-13 12:09 ` Gerd Hoffmann
2017-09-13 12:09 ` [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure Gerd Hoffmann
1 sibling, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2017-09-13 12:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Paolo Bonzini
Add helper function to add a directory to the qemu search path, so we
don't duplicate the checks. Add a check for duplicate entries, so we
stop trying to open files twice.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
vl.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/vl.c b/vl.c
index fb1f05b937..37a3401920 100644
--- a/vl.c
+++ b/vl.c
@@ -2272,6 +2272,24 @@ char *qemu_find_file(int type, const char *name)
return NULL;
}
+static void qemu_add_data_dir(const char *path)
+{
+ int i;
+
+ if (path == NULL) {
+ return;
+ }
+ if (data_dir_idx == ARRAY_SIZE(data_dir)) {
+ return;
+ }
+ for (i = 0; i < data_dir_idx; i++) {
+ if (strcmp(data_dir[i], path) == 0) {
+ return; /* duplicate */
+ }
+ }
+ data_dir[data_dir_idx++] = path;
+}
+
static inline bool nonempty_str(const char *str)
{
return str && *str;
@@ -3450,8 +3468,8 @@ int main(int argc, char **argv, char **envp)
case QEMU_OPTION_L:
if (is_help_option(optarg)) {
list_data_dirs = true;
- } else if (data_dir_idx < ARRAY_SIZE(data_dir)) {
- data_dir[data_dir_idx++] = optarg;
+ } else {
+ qemu_add_data_dir(optarg);
}
break;
case QEMU_OPTION_bios:
@@ -4216,16 +4234,10 @@ int main(int argc, char **argv, char **envp)
/* If no data_dir is specified then try to find it relative to the
executable path. */
- if (data_dir_idx < ARRAY_SIZE(data_dir)) {
- data_dir[data_dir_idx] = os_find_datadir();
- if (data_dir[data_dir_idx] != NULL) {
- data_dir_idx++;
- }
- }
+ qemu_add_data_dir(os_find_datadir());
+
/* If all else fails use the install path specified when building. */
- if (data_dir_idx < ARRAY_SIZE(data_dir)) {
- data_dir[data_dir_idx++] = CONFIG_QEMU_DATADIR;
- }
+ qemu_add_data_dir(CONFIG_QEMU_DATADIR);
/* -L help lists the data directories and exits. */
if (list_data_dirs) {
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure
2017-09-13 12:09 [Qemu-devel] [PATCH 0/2] Add --firmwarepath to configure Gerd Hoffmann
2017-09-13 12:09 ` [Qemu-devel] [PATCH 1/2] add qemu_add_data_dir() Gerd Hoffmann
@ 2017-09-13 12:09 ` Gerd Hoffmann
2017-09-13 20:43 ` Paolo Bonzini
1 sibling, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2017-09-13 12:09 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Paolo Bonzini
Add a firmware path config option to configure. Multiple directories
are accepted, with the usual colon as separator. Default value is
${prefix}/share/qemu-firmware. The path is searched in addition to the
current search path (typically ${prefix}/share/qemu).
This prepares qemu for the planned split of the prebuilt firmware blobs
into a separate project.
Distributions can also use this to get rid of the firmware symlink farm
and add -- for example -- /usr/share/seabios to the firmware path
instead.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
configure | 6 ++++++
vl.c | 12 +++++++++---
scripts/create_config | 2 +-
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/configure b/configure
index fd7e3a5e81..870bdbd3e4 100755
--- a/configure
+++ b/configure
@@ -332,6 +332,7 @@ modules="no"
prefix="/usr/local"
mandir="\${prefix}/share/man"
datadir="\${prefix}/share"
+firmwarepath="\${prefix}/share/qemu-firmware"
qemu_docdir="\${prefix}/share/doc/qemu"
bindir="\${prefix}/bin"
libdir="\${prefix}/lib"
@@ -915,6 +916,8 @@ for opt do
;;
--localstatedir=*) local_statedir="$optarg"
;;
+ --firmwarepath=*) firmwarepath="$optarg"
+ ;;
--sbindir=*|--sharedstatedir=*|\
--oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
--htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
@@ -1418,6 +1421,7 @@ Advanced options (experts only):
--libdir=PATH install libraries in PATH
--sysconfdir=PATH install config in PATH$confsuffix
--localstatedir=PATH install local state in PATH (set at runtime on win32)
+ --firmwarepath=PATH search PATH for firmware files
--with-confsuffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir [$confsuffix]
--enable-debug enable common debug build options
--disable-strip disable stripping binaries
@@ -5259,6 +5263,7 @@ libs_softmmu="$pixman_libs $libs_softmmu"
echo "Install prefix $prefix"
echo "BIOS directory $(eval echo $qemu_datadir)"
+echo "firmware path $(eval echo $firmwarepath)"
echo "binary directory $(eval echo $bindir)"
echo "library directory $(eval echo $libdir)"
echo "module directory $(eval echo $qemu_moddir)"
@@ -5450,6 +5455,7 @@ echo "mandir=$mandir" >> $config_host_mak
echo "sysconfdir=$sysconfdir" >> $config_host_mak
echo "qemu_confdir=$qemu_confdir" >> $config_host_mak
echo "qemu_datadir=$qemu_datadir" >> $config_host_mak
+echo "qemu_firmwarepath=$firmwarepath" >> $config_host_mak
echo "qemu_docdir=$qemu_docdir" >> $config_host_mak
echo "qemu_moddir=$qemu_moddir" >> $config_host_mak
if test "$mingw32" = "no" ; then
diff --git a/vl.c b/vl.c
index 37a3401920..8f4bbe3825 100644
--- a/vl.c
+++ b/vl.c
@@ -3048,6 +3048,7 @@ int main(int argc, char **argv, char **envp)
Error *main_loop_err = NULL;
Error *err = NULL;
bool list_data_dirs = false;
+ char **dirs;
typedef struct BlockdevOptions_queue {
BlockdevOptions *bdo;
Location loc;
@@ -4232,11 +4233,16 @@ int main(int argc, char **argv, char **envp)
qemu_set_log(0);
}
- /* If no data_dir is specified then try to find it relative to the
- executable path. */
+ /* add configured firmware directories */
+ dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, ":", 0);
+ for (i = 0; dirs[i] != NULL; i++) {
+ qemu_add_data_dir(dirs[i]);
+ }
+
+ /* try to find datadir relative to the executable path */
qemu_add_data_dir(os_find_datadir());
- /* If all else fails use the install path specified when building. */
+ /* add the datadir specified when building */
qemu_add_data_dir(CONFIG_QEMU_DATADIR);
/* -L help lists the data directories and exits. */
diff --git a/scripts/create_config b/scripts/create_config
index e6929dd61e..603b826886 100755
--- a/scripts/create_config
+++ b/scripts/create_config
@@ -15,7 +15,7 @@ case $line in
echo "#define QEMU_VERSION_MINOR $minor"
echo "#define QEMU_VERSION_MICRO $micro"
;;
- qemu_*dir=*) # qemu-specific directory configuration
+ qemu_*dir=* | qemu_*path=*) # qemu-specific directory configuration
name=${line%=*}
value=${line#*=}
define_name=$(echo $name | LC_ALL=C tr '[a-z]' '[A-Z]')
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure
2017-09-13 12:09 ` [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure Gerd Hoffmann
@ 2017-09-13 20:43 ` Paolo Bonzini
2017-09-14 8:36 ` Gerd Hoffmann
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2017-09-13 20:43 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel
On 13/09/2017 14:09, Gerd Hoffmann wrote:
> Add a firmware path config option to configure. Multiple directories
> are accepted, with the usual colon as separator. Default value is
> ${prefix}/share/qemu-firmware. The path is searched in addition to the
> current search path (typically ${prefix}/share/qemu).
>
> This prepares qemu for the planned split of the prebuilt firmware blobs
> into a separate project.
>
> Distributions can also use this to get rid of the firmware symlink farm
> and add -- for example -- /usr/share/seabios to the firmware path
> instead.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> configure | 6 ++++++
> vl.c | 12 +++++++++---
> scripts/create_config | 2 +-
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index fd7e3a5e81..870bdbd3e4 100755
> --- a/configure
> +++ b/configure
> @@ -332,6 +332,7 @@ modules="no"
> prefix="/usr/local"
> mandir="\${prefix}/share/man"
> datadir="\${prefix}/share"
> +firmwarepath="\${prefix}/share/qemu-firmware"
> qemu_docdir="\${prefix}/share/doc/qemu"
> bindir="\${prefix}/bin"
> libdir="\${prefix}/lib"
> @@ -915,6 +916,8 @@ for opt do
> ;;
> --localstatedir=*) local_statedir="$optarg"
> ;;
> + --firmwarepath=*) firmwarepath="$optarg"
> + ;;
> --sbindir=*|--sharedstatedir=*|\
> --oldincludedir=*|--datarootdir=*|--infodir=*|--localedir=*|\
> --htmldir=*|--dvidir=*|--pdfdir=*|--psdir=*)
> @@ -1418,6 +1421,7 @@ Advanced options (experts only):
> --libdir=PATH install libraries in PATH
> --sysconfdir=PATH install config in PATH$confsuffix
> --localstatedir=PATH install local state in PATH (set at runtime on win32)
> + --firmwarepath=PATH search PATH for firmware files
Maybe --firmwaredir or --with-firmwaredir (because firmwaredir is not
one of the "standard" directories)?
> @@ -4232,11 +4233,16 @@ int main(int argc, char **argv, char **envp)
> qemu_set_log(0);
> }
>
> - /* If no data_dir is specified then try to find it relative to the
> - executable path. */
> + /* add configured firmware directories */
> + dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, ":", 0);
Windows probably wants to use ; here, so you can use
G_SEARCHPATH_SEPARATOR_S instead of ":".
Thanks,
Paolo
> + for (i = 0; dirs[i] != NULL; i++) {
> + qemu_add_data_dir(dirs[i]);
> + }
> +
> + /* try to find datadir relative to the executable path */
> qemu_add_data_dir(os_find_datadir());
>
> - /* If all else fails use the install path specified when building. */
> + /* add the datadir specified when building */
> qemu_add_data_dir(CONFIG_QEMU_DATADIR);
>
> /* -L help lists the data directories and exits. */
> diff --git a/scripts/create_config b/scripts/create_config
> index e6929dd61e..603b826886 100755
> --- a/scripts/create_config
> +++ b/scripts/create_config
> @@ -15,7 +15,7 @@ case $line in
> echo "#define QEMU_VERSION_MINOR $minor"
> echo "#define QEMU_VERSION_MICRO $micro"
> ;;
> - qemu_*dir=*) # qemu-specific directory configuration
> + qemu_*dir=* | qemu_*path=*) # qemu-specific directory configuration
> name=${line%=*}
> value=${line#*=}
> define_name=$(echo $name | LC_ALL=C tr '[a-z]' '[A-Z]')
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure
2017-09-13 20:43 ` Paolo Bonzini
@ 2017-09-14 8:36 ` Gerd Hoffmann
2017-09-14 11:37 ` Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2017-09-14 8:36 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel
Hi,
> > + --firmwarepath=PATH search PATH for firmware files
>
> Maybe --firmwaredir or --with-firmwaredir (because firmwaredir is not
> one of the "standard" directories)?
I've intentionally named this "path" because it can actually have
multiple directories.
Or do you mean something else? If so --verbose please.
> > + /* add configured firmware directories */
> > + dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, ":", 0);
>
> Windows probably wants to use ; here, so you can use
> G_SEARCHPATH_SEPARATOR_S instead of ":".
Ah, cool, didn't know this exists. Fixing ...
cheers,
Gerd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure
2017-09-14 8:36 ` Gerd Hoffmann
@ 2017-09-14 11:37 ` Paolo Bonzini
0 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2017-09-14 11:37 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel
On 14/09/2017 10:36, Gerd Hoffmann wrote:
> Hi,
>
>>> + --firmwarepath=PATH search PATH for firmware files
>>
>> Maybe --firmwaredir or --with-firmwaredir (because firmwaredir is not
>> one of the "standard" directories)?
>
> I've intentionally named this "path" because it can actually have
> multiple directories.
>
> Or do you mean something else? If so --verbose please.
No, you're right.
Paolo
>>> + /* add configured firmware directories */
>>> + dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, ":", 0);
>>
>> Windows probably wants to use ; here, so you can use
>> G_SEARCHPATH_SEPARATOR_S instead of ":".
>
> Ah, cool, didn't know this exists. Fixing ...
>
> cheers,
> Gerd
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-14 11:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13 12:09 [Qemu-devel] [PATCH 0/2] Add --firmwarepath to configure Gerd Hoffmann
2017-09-13 12:09 ` [Qemu-devel] [PATCH 1/2] add qemu_add_data_dir() Gerd Hoffmann
2017-09-13 12:09 ` [Qemu-devel] [PATCH 2/2] Add --firmwarepath to configure Gerd Hoffmann
2017-09-13 20:43 ` Paolo Bonzini
2017-09-14 8:36 ` Gerd Hoffmann
2017-09-14 11:37 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.