[PATCH] os-posix: Restore firmware location ../share/qemu

azoff@azoff.se posted 1 patch 3 years, 8 months ago
Test docker-quick@centos7 failed
Test docker-mingw@fedora failed
Test checkpatch failed
Test FreeBSD failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200826075705.8961-1-azoff@svenskalinuxforeningen.se
os-posix.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] os-posix: Restore firmware location ../share/qemu
Posted by azoff@azoff.se 3 years, 8 months ago
Prior to commit 6dd2dacedd83d12328afa8559bffb2b9ec5c89ed (v5.0.0), the
binary relative path ../share/qemu was searched for firmware, but in
that commit, this path got lost.

Consider the following use-case:
* QEMU is built in a docker image on one system.
* QEMU is supposed to be executed on a plethora of distributions/systems
* QEMU is not installed system wide on the executors
When building QEMU, the --prefix configure flag is used to generate a
tree containing all the QEMU resources that needs to be transfered to
the executors. The path to the root of the QEMU tree might be different
for the different executors, therefore, the path stored in
CONFIG_QEMU_DATADIR is likely not the right one.
With this use-case, the only likely path is one that is expressed as
relative to the root of the QEMU binary tree or the QEMU binary iself.

Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
---
 os-posix.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/os-posix.c b/os-posix.c
index bf98508b6d..f016ac374c 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -96,6 +96,11 @@ char *os_find_datadir(void)
     exec_dir = qemu_get_exec_dir();
     g_return_val_if_fail(exec_dir != NULL, NULL);
 
+    dir = g_build_filename(exec_dir, "..", "share", "qemu", NULL);
+    if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
+        return g_steal_pointer(&dir);
+    }
+
     dir = g_build_filename(exec_dir, "pc-bios", NULL);
     if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
         return g_steal_pointer(&dir);
-- 
2.26.2


Re: [PATCH] os-posix: Restore firmware location ../share/qemu
Posted by Paolo Bonzini 3 years, 8 months ago
Hi, I will post next week a patch to make all searches relative to the
executable path. I will CC you so you can test it.

Thanks!

Paolo

Il mer 26 ago 2020, 10:01 <azoff@azoff.se> ha scritto:

> Prior to commit 6dd2dacedd83d12328afa8559bffb2b9ec5c89ed (v5.0.0), the
> binary relative path ../share/qemu was searched for firmware, but in
> that commit, this path got lost.
>
> Consider the following use-case:
> * QEMU is built in a docker image on one system.
> * QEMU is supposed to be executed on a plethora of distributions/systems
> * QEMU is not installed system wide on the executors
> When building QEMU, the --prefix configure flag is used to generate a
> tree containing all the QEMU resources that needs to be transfered to
> the executors. The path to the root of the QEMU tree might be different
> for the different executors, therefore, the path stored in
> CONFIG_QEMU_DATADIR is likely not the right one.
> With this use-case, the only likely path is one that is expressed as
> relative to the root of the QEMU binary tree or the QEMU binary iself.
>
> Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
> ---
>  os-posix.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/os-posix.c b/os-posix.c
> index bf98508b6d..f016ac374c 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -96,6 +96,11 @@ char *os_find_datadir(void)
>      exec_dir = qemu_get_exec_dir();
>      g_return_val_if_fail(exec_dir != NULL, NULL);
>
> +    dir = g_build_filename(exec_dir, "..", "share", "qemu", NULL);
> +    if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
> +        return g_steal_pointer(&dir);
> +    }
> +
>      dir = g_build_filename(exec_dir, "pc-bios", NULL);
>      if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
>          return g_steal_pointer(&dir);
> --
> 2.26.2
>
>