[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/92] oslib-posix: default exec_dir to bindir
From: |
Paolo Bonzini |
Subject: |
[PULL 41/92] oslib-posix: default exec_dir to bindir |
Date: |
Thu, 24 Sep 2020 05:22:23 -0400 |
If the exec_dir cannot be retrieved, just assume it's the installation
directory that was specified at configure time. This makes it simpler
to reason about what the callers will do if they get back an empty
path.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
meson.build | 2 +-
util/oslib-posix.c | 23 ++++++++---------------
util/oslib-win32.c | 4 +++-
3 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/meson.build b/meson.build
index fedf44ed79..9a4ade7f98 100644
--- a/meson.build
+++ b/meson.build
@@ -560,7 +560,7 @@ config_host_data.set('QEMU_VERSION_MINOR',
meson.project_version().split('.')[1]
config_host_data.set('QEMU_VERSION_MICRO',
meson.project_version().split('.')[2])
arrays = ['CONFIG_AUDIO_DRIVERS', 'CONFIG_BDRV_RW_WHITELIST',
'CONFIG_BDRV_RO_WHITELIST']
-strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'qemu_confdir', 'qemu_datadir',
+strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'bindir', 'qemu_confdir',
'qemu_datadir',
'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir',
'qemu_localedir',
'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath']
foreach k, v: config_host
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 18531fc859..1739930e65 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -358,15 +358,14 @@ void qemu_set_tty_echo(int fd, bool echo)
tcsetattr(fd, TCSANOW, &tty);
}
-static char exec_dir[PATH_MAX];
+static const char *exec_dir;
void qemu_init_exec_dir(const char *argv0)
{
- char *dir;
char *p = NULL;
char buf[PATH_MAX];
- if (exec_dir[0]) {
+ if (exec_dir) {
return;
}
@@ -425,20 +424,14 @@ void qemu_init_exec_dir(const char *argv0)
#endif
/* If we don't have any way of figuring out the actual executable
location then try argv[0]. */
- if (!p) {
- if (!argv0) {
- return;
- }
+ if (!p && argv0) {
p = realpath(argv0, buf);
- if (!p) {
- return;
- }
}
- dir = g_path_get_dirname(p);
-
- pstrcpy(exec_dir, sizeof(exec_dir), dir);
-
- g_free(dir);
+ if (p) {
+ exec_dir = g_path_get_dirname(p);
+ } else {
+ exec_dir = CONFIG_BINDIR;
+ }
}
const char *qemu_get_exec_dir(void)
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 1a33912944..051afb217b 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -315,7 +315,7 @@ void qemu_set_tty_echo(int fd, bool echo)
}
}
-static char *exec_dir;
+static const char *exec_dir;
void qemu_init_exec_dir(const char *argv0)
{
@@ -341,6 +341,8 @@ void qemu_init_exec_dir(const char *argv0)
*p = 0;
if (access(buf, R_OK) == 0) {
exec_dir = g_strdup(buf);
+ } else {
+ exec_dir = CONFIG_BINDIR;
}
}
--
2.26.2
- [PULL 18/92] configure: rename QEMU_GA_MSI_ENABLED to CONFIG_QGA_MSI, (continued)
- [PULL 18/92] configure: rename QEMU_GA_MSI_ENABLED to CONFIG_QGA_MSI, Paolo Bonzini, 2020/09/24
- [PULL 29/92] meson: move libudev test, Paolo Bonzini, 2020/09/24
- [PULL 31/92] meson: extend libmpathpersist test for static linking, Paolo Bonzini, 2020/09/24
- [PULL 22/92] hw/char/serial: Rename I/O read/write trace events, Paolo Bonzini, 2020/09/24
- [PULL 30/92] meson: move libmpathpersist test, Paolo Bonzini, 2020/09/24
- [PULL 33/92] configure: fix --meson=/path/to/meson, Paolo Bonzini, 2020/09/24
- [PULL 32/92] configure: move malloc_trim/tcmalloc/jemalloc to meson, Paolo Bonzini, 2020/09/24
- [PULL 26/92] hw: megasas: return -1 when 'megasas_map_sgl' fails, Paolo Bonzini, 2020/09/24
- [PULL 35/92] configure: do not limit Hypervisor.framework test to Darwin, Paolo Bonzini, 2020/09/24
- [PULL 24/92] hw/char/serial-{isa, pci}: Alias QDEV properties from generic serial object, Paolo Bonzini, 2020/09/24
- [PULL 41/92] oslib-posix: default exec_dir to bindir,
Paolo Bonzini <=
- [PULL 36/92] meson: qtest: set "depends" correctly, Paolo Bonzini, 2020/09/24
- [PULL 38/92] meson: report accelerator support, Paolo Bonzini, 2020/09/24
- [PULL 37/92] mtest2make: add support for introspected test dependencies, Paolo Bonzini, 2020/09/24
- [PULL 39/92] oslib: do not call g_strdup from qemu_get_exec_dir, Paolo Bonzini, 2020/09/24
- [PULL 46/92] vl: relocate paths to data directories, Paolo Bonzini, 2020/09/24
- [PULL 34/92] configure: move cocoa option to Meson, Paolo Bonzini, 2020/09/24
- [PULL 40/92] fuzz: use qemu_get_exec_dir, Paolo Bonzini, 2020/09/24
- [PULL 42/92] cutils: introduce get_relocated_path, Paolo Bonzini, 2020/09/24
- [PULL 44/92] module: relocate path to modules, Paolo Bonzini, 2020/09/24
- [PULL 51/92] configure: use a platform-neutral prefix, Paolo Bonzini, 2020/09/24