[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH] os-posix: fix regression for install-less datadir location
From: |
Marc-André Lureau |
Subject: |
[RFC PATCH] os-posix: fix regression for install-less datadir location |
Date: |
Thu, 16 Jul 2020 18:11:00 +0400 |
os_find_datadir() used to check the ../share/qemu location (regardless
of CONFIG_QEMU_DATADIR). It turns out that people rely on that location
for running qemu in an arbitrary "install-less/portable" fashion. Change
the logic to return that directory as a last resort.
(this is an alternative to the patch "[PATCH 1/1] os_find_datadir: search
as in version 4.2" from Joe Slater)
Fixes: 6dd2dacedd83d12328 ("os-posix: simplify os_find_datadir")
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
os-posix.c | 15 ++++++++++++---
scripts/create_config | 2 +-
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/os-posix.c b/os-posix.c
index b674b20b1b1..bd0ed0c14d1 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -82,8 +82,13 @@ void os_setup_signal_handling(void)
/*
* Find a likely location for support files using the location of the binary.
- * When running from the build tree this will be "$bindir/../pc-bios".
- * Otherwise, this is CONFIG_QEMU_DATADIR.
+ *
+ * If running from the install location (CONFIG_BINDIR), this will be
+ * CONFIG_QEMU_DATADIR.
+ *
+ * Otherwise, fallback on "$execdir/../pc-bios" if it exists (the build tree
+ * location), else on "$execdir/../share/qemu" (for the install-less/"portable"
+ * version).
*/
char *os_find_datadir(void)
{
@@ -93,12 +98,16 @@ char *os_find_datadir(void)
exec_dir = qemu_get_exec_dir();
g_return_val_if_fail(exec_dir != NULL, NULL);
+ if (g_str_has_prefix(exec_dir, CONFIG_BINDIR)) {
+ return g_strdup(CONFIG_QEMU_DATADIR);
+ }
+
dir = g_build_filename(exec_dir, "..", "pc-bios", NULL);
if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
return g_steal_pointer(&dir);
}
- return g_strdup(CONFIG_QEMU_DATADIR);
+ return g_build_filename(exec_dir, "..", "share", "qemu", NULL);
}
void os_set_proc_name(const char *s)
diff --git a/scripts/create_config b/scripts/create_config
index 6d8f08b39da..03f8cb1dc10 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_*path=*) # qemu-specific directory configuration
+ bindir=* | 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.27.0.221.ga08a83db2b
- [RFC PATCH] os-posix: fix regression for install-less datadir location,
Marc-André Lureau <=