qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] Make QEMU installation relocatable
@ 2020-09-01  6:20 Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 01/13] fuzz: use qemu_get_exec_dir Paolo Bonzini
                   ` (13 more replies)
  0 siblings, 14 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Right now, the installation of QEMU is not relocatable; there is
a local hack in os_find_datadir() so that Windows binaries look
for ROMs in the executable directory, but that has several limitations:

- it does not extend to configuration files, icons, etc.

- it does not allow changing the data directory in any way

- it does not apply to POSIX platforms

This series fixes that by making all paths within the installation
prefix relative to the executable.  This in practice means all paths
will be relocatable, except for /etc and /var if they're moved
outside the prefix.

Here is an example of relocatability; before:

  $ make DESTDIR=$PWD/test install
  $ cd test/usr/local/bin
  $ ./qemu-system-ppc -L help
  /usr/local/share/qemu-firmware
  /usr/local/share/qemu

After:

  $ make DESTDIR=$PWD/test install
  $ cd test/usr/local/bin
  $ ./qemu-system-ppc -L help
  /home/pbonzini/work/upstream/qemu/+build/test/usr/local/bin/../share/qemu-firmware
  /home/pbonzini/work/upstream/qemu/+build/test/usr/local/bin/../share/qemu

The main benefit of this is on Windows, as mentioned above; but it also
makes behavior more consistent across platforms and allows the removal
of the hack that hides the "c:/Program Files/QEMU" prefix from Meson
during cross compilation.

Paolo

Paolo Bonzini (13):
  fuzz: use qemu_get_exec_dir
  oslib: do not call g_strdup from qemu_get_exec_dir
  oslib-posix: default exec_dir to bindir
  cutils: introduce get_relocated_path
  oslib-posix: relocate path to /var
  module: relocate path to modules
  net: relocate paths to helpers and scripts
  vl: relocate paths to data directories
  vl: relocate path to configuration file
  qemu-bridge-helper: relocate path to default ACL
  qga: relocate path to default configuration and hook
  ui: relocate paths to icons and translations
  configure: use a platform-neutral prefix

 configure               | 30 ++++++++------------
 include/net/net.h       |  4 +--
 include/qemu-common.h   |  1 -
 include/qemu/cutils.h   | 12 ++++++++
 include/qemu/osdep.h    |  8 ++----
 include/sysemu/sysemu.h |  2 +-
 meson.build             |  4 +--
 net/tap.c               | 28 ++++++++++++++-----
 os-posix.c              | 24 ----------------
 os-win32.c              | 11 --------
 qemu-bridge-helper.c    |  9 ++++--
 qga/main.c              |  8 ++++--
 softmmu/vl.c            | 43 ++++++++++++++++++++---------
 tests/qtest/fuzz/fuzz.c | 12 ++++----
 ui/gtk.c                | 10 +++++--
 ui/sdl2.c               |  9 ++++--
 util/cutils.c           | 61 +++++++++++++++++++++++++++++++++++++++++
 util/module.c           | 10 ++-----
 util/oslib-posix.c      | 35 +++++++++++------------
 util/oslib-win32.c      | 14 +++++++---
 20 files changed, 205 insertions(+), 130 deletions(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 01/13] fuzz: use qemu_get_exec_dir
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01  9:18   ` Thomas Huth
  2020-09-01 14:36   ` Alexander Bulekov
  2020-09-01  6:20 ` [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir Paolo Bonzini
                   ` (12 subsequent siblings)
  13 siblings, 2 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Make things consistent with how softmmu/vl.c uses os_find_datadir.
Initializing the path to the executables will also be needed for
get_relocatable_path to work.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/qtest/fuzz/fuzz.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index 1ceea84702..391223219d 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -152,6 +152,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
     module_call_init(MODULE_INIT_QOM);
     module_call_init(MODULE_INIT_LIBQOS);
 
+    qemu_init_exec_dir(**argv);
     target_name = strstr(**argv, "-target-");
     if (target_name) {        /* The binary name specifies the target */
         target_name += strlen("-target-");
@@ -164,7 +165,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
          * location of the executable. Using this we add exec_dir/pc-bios to
          * the datadirs.
          */
-        bindir = g_path_get_dirname(**argv);
+        bindir = qemu_get_exec_dir();
         datadir = g_build_filename(bindir, "pc-bios", NULL);
         g_free(bindir);
         if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 01/13] fuzz: use qemu_get_exec_dir Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-02 10:30   ` Thomas Huth
  2020-09-01  6:20 ` [PATCH 03/13] oslib-posix: default exec_dir to bindir Paolo Bonzini
                   ` (11 subsequent siblings)
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Just return the directory without requiring the caller to free it.
This also removes a bogus check for NULL in os_find_datadir and
module_load_one; g_strdup of a static variable cannot return NULL.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/osdep.h    |  8 ++------
 os-posix.c              |  6 +-----
 os-win32.c              |  2 +-
 tests/qtest/fuzz/fuzz.c |  4 ++--
 util/module.c           |  7 +------
 util/oslib-posix.c      |  8 +++++---
 util/oslib-win32.c      | 12 ++++++++----
 7 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 412962d91a..db2cfffaff 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -590,12 +590,8 @@ char *qemu_get_local_state_pathname(const char *relative_pathname);
  * Try OS specific API first, if not working, parse from argv0. */
 void qemu_init_exec_dir(const char *argv0);
 
-/* Get the saved exec dir.
- *
- * The caller is responsible for releasing the value returned with g_free()
- * after use.
- */
-char *qemu_get_exec_dir(void);
+/* Get the saved exec dir.  */
+const char *qemu_get_exec_dir(void);
 
 /**
  * qemu_getauxval:
diff --git a/os-posix.c b/os-posix.c
index bf98508b6d..8d8e7fc15c 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -90,13 +90,9 @@ void os_setup_signal_handling(void)
  */
 char *os_find_datadir(void)
 {
-    g_autofree char *exec_dir = NULL;
     g_autofree char *dir = NULL;
 
-    exec_dir = qemu_get_exec_dir();
-    g_return_val_if_fail(exec_dir != NULL, NULL);
-
-    dir = g_build_filename(exec_dir, "pc-bios", NULL);
+    dir = g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL);
     if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
         return g_steal_pointer(&dir);
     }
diff --git a/os-win32.c b/os-win32.c
index c9c3afe648..eb8501b9e5 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -65,7 +65,7 @@ void os_setup_early_signal_handling(void)
  */
 char *os_find_datadir(void)
 {
-    return qemu_get_exec_dir();
+    return g_strdup(qemu_get_exec_dir());
 }
 
 void os_set_line_buffering(void)
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index 391223219d..1811cb1d88 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -143,7 +143,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
 {
 
     char *target_name;
-    char *bindir, *datadir;
+    const char *bindir;
+    char *datadir;
     bool serialize = false;
 
     /* Initialize qgraph and modules */
@@ -167,7 +168,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
          */
         bindir = qemu_get_exec_dir();
         datadir = g_build_filename(bindir, "pc-bios", NULL);
-        g_free(bindir);
         if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
             qemu_add_data_dir(datadir);
         }
diff --git a/util/module.c b/util/module.c
index 6e63006a8f..aed04b578a 100644
--- a/util/module.c
+++ b/util/module.c
@@ -172,7 +172,6 @@ bool module_load_one(const char *prefix, const char *lib_name)
 
 #ifdef CONFIG_MODULES
     char *fname = NULL;
-    char *exec_dir;
 #ifdef CONFIG_MODULE_UPGRADES
     char *version_dir;
 #endif
@@ -199,13 +198,12 @@ bool module_load_one(const char *prefix, const char *lib_name)
         return true;
     }
 
-    exec_dir = qemu_get_exec_dir();
     search_dir = getenv("QEMU_MODULE_DIR");
     if (search_dir != NULL) {
         dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
     }
     dirs[n_dirs++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR);
-    dirs[n_dirs++] = g_strdup_printf("%s", exec_dir ? : "");
+    dirs[n_dirs++] = g_strdup(qemu_get_exec_dir());
 
 #ifdef CONFIG_MODULE_UPGRADES
     version_dir = g_strcanon(g_strdup(QEMU_PKGVERSION),
@@ -216,9 +214,6 @@ bool module_load_one(const char *prefix, const char *lib_name)
 
     assert(n_dirs <= ARRAY_SIZE(dirs));
 
-    g_free(exec_dir);
-    exec_dir = NULL;
-
     for (i = 0; i < n_dirs; i++) {
         fname = g_strdup_printf("%s/%s%s",
                 dirs[i], module_name, CONFIG_HOST_DSOSUF);
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index ad8001a4ad..0dd8d24076 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -366,7 +366,9 @@ void qemu_init_exec_dir(const char *argv0)
     char *p = NULL;
     char buf[PATH_MAX];
 
-    assert(!exec_dir[0]);
+    if (exec_dir[0]) {
+        return;
+    }
 
 #if defined(__linux__)
     {
@@ -439,9 +441,9 @@ void qemu_init_exec_dir(const char *argv0)
     g_free(dir);
 }
 
-char *qemu_get_exec_dir(void)
+const char *qemu_get_exec_dir(void)
 {
-    return g_strdup(exec_dir);
+    return exec_dir;
 }
 
 static void sigbus_handler(int signal)
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index c654dafd93..1a33912944 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[PATH_MAX];
+static char *exec_dir;
 
 void qemu_init_exec_dir(const char *argv0)
 {
@@ -324,6 +324,10 @@ void qemu_init_exec_dir(const char *argv0)
     char buf[MAX_PATH];
     DWORD len;
 
+    if (exec_dir) {
+        return;
+    }
+
     len = GetModuleFileName(NULL, buf, sizeof(buf) - 1);
     if (len == 0) {
         return;
@@ -336,13 +340,13 @@ void qemu_init_exec_dir(const char *argv0)
     }
     *p = 0;
     if (access(buf, R_OK) == 0) {
-        pstrcpy(exec_dir, sizeof(exec_dir), buf);
+        exec_dir = g_strdup(buf);
     }
 }
 
-char *qemu_get_exec_dir(void)
+const char *qemu_get_exec_dir(void)
 {
-    return g_strdup(exec_dir);
+    return exec_dir;
 }
 
 #if !GLIB_CHECK_VERSION(2, 50, 0)
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 03/13] oslib-posix: default exec_dir to bindir
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 01/13] fuzz: use qemu_get_exec_dir Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01 18:04   ` Richard Henderson
  2020-09-01  6:20 ` [PATCH 04/13] cutils: introduce get_relocated_path Paolo Bonzini
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

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 |  2 ++
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/meson.build b/meson.build
index 93182d36e3..10ab189bc5 100644
--- a/meson.build
+++ b/meson.build
@@ -415,7 +415,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 0dd8d24076..a68fccb52d 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 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 = g_strdup(CONFIG_BINDIR);
+    }
 }
 
 const char *qemu_get_exec_dir(void)
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 1a33912944..8d3f940a54 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -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 = g_strdup(CONFIG_BINDIR);
     }
 }
 
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 04/13] cutils: introduce get_relocated_path
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (2 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 03/13] oslib-posix: default exec_dir to bindir Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 05/13] oslib-posix: relocate path to /var Paolo Bonzini
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Add the function that will compute a relocated version of the
directories in CONFIG_QEMU_*DIR and CONFIG_QEMU_*PATH.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu/cutils.h | 12 +++++++++
 meson.build           |  4 +--
 util/cutils.c         | 61 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index eb59852dfd..3a86ec0321 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -184,4 +184,16 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *n);
  */
 int qemu_pstrcmp0(const char **str1, const char **str2);
 
+
+/**
+ * get_relocated_path:
+ * @dir: the directory (typically a `CONFIG_*DIR` variable) to be relocated.
+ *
+ * Returns a path for @dir that uses the directory of the running executable
+ * as the prefix.  For example, if `bindir` is `/usr/bin` and @dir is
+ * `/usr/share/qemu`, the function will append `../share/qemu` to the
+ * directory that contains the running executable and return the result.
+ */
+char *get_relocated_path(const char *dir);
+
 #endif
diff --git a/meson.build b/meson.build
index 10ab189bc5..5ff005b835 100644
--- a/meson.build
+++ b/meson.build
@@ -415,9 +415,9 @@ 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', 'bindir', 'qemu_confdir', 'qemu_datadir',
+strings = ['HOST_DSOSUF', 'CONFIG_IASL', 'bindir', 'prefix', 'qemu_confdir', 'qemu_datadir',
            'qemu_moddir', 'qemu_localstatedir', 'qemu_helperdir', 'qemu_localedir',
-           'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath']
+           'qemu_icondir', 'qemu_desktopdir', 'qemu_firmwarepath', 'sysconfdir']
 foreach k, v: config_host
   if arrays.contains(k)
     if v != ''
diff --git a/util/cutils.c b/util/cutils.c
index 36ce712271..8da34e04b0 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -889,3 +889,64 @@ int qemu_pstrcmp0(const char **str1, const char **str2)
 {
     return g_strcmp0(*str1, *str2);
 }
+
+static inline bool starts_with_prefix(const char *dir)
+{
+    size_t prefix_len = strlen(CONFIG_PREFIX);
+    return !memcmp(dir, CONFIG_PREFIX, prefix_len) &&
+        (!dir[prefix_len] || G_IS_DIR_SEPARATOR(dir[prefix_len]));
+}
+
+/* Return the next path component in dir, and store its length in *p_len.  */
+static inline const char *next_component(const char *dir, int *p_len)
+{
+    int len;
+    while (*dir && G_IS_DIR_SEPARATOR(*dir)) {
+        dir++;
+    }
+    len = 0;
+    while (dir[len] && !G_IS_DIR_SEPARATOR(dir[len])) {
+        len++;
+    }
+    *p_len = len;
+    return dir;
+}
+
+char *get_relocated_path(const char *dir)
+{
+    size_t prefix_len = strlen(CONFIG_PREFIX);
+    const char *bindir = CONFIG_BINDIR;
+    const char *exec_dir = qemu_get_exec_dir();
+    GString *result;
+    int len_dir, len_bindir;
+
+    /* Fail if qemu_init_exec_dir was not called.  */
+    assert(exec_dir[0]);
+    if (!starts_with_prefix(dir) || !starts_with_prefix(bindir)) {
+        return strdup(dir);
+    }
+
+    result = g_string_new(exec_dir);
+
+    /* Advance over common components.  */
+    len_dir = len_bindir = prefix_len;
+    do {
+        dir += len_dir;
+        bindir += len_bindir;
+        dir = next_component(dir, &len_dir);
+        bindir = next_component(bindir, &len_bindir);
+    } while (len_dir == len_bindir && !memcmp(dir, bindir, len_dir));
+
+    /* Ascend from bindir to the common prefix with dir.  */
+    while (len_bindir) {
+        bindir += len_bindir;
+        g_string_append(result, "/..");
+        bindir = next_component(bindir, &len_bindir);
+    }
+
+    if (*dir) {
+        assert(G_IS_DIR_SEPARATOR(dir[-1]));
+        g_string_append(result, dir - 1);
+    }
+    return result->str;
+}
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 05/13] oslib-posix: relocate path to /var
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (3 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 04/13] cutils: introduce get_relocated_path Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-02  8:20   ` Philippe Mathieu-Daudé
  2020-09-01  6:20 ` [PATCH 06/13] module: relocate path to modules Paolo Bonzini
                   ` (8 subsequent siblings)
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 util/oslib-posix.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index a68fccb52d..8e23b8fac0 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -339,8 +339,10 @@ int qemu_pipe(int pipefd[2])
 char *
 qemu_get_local_state_pathname(const char *relative_pathname)
 {
-    return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR,
-                           relative_pathname);
+    g_autofree char *dir = g_strdup_printf("%s/%s",
+                                           CONFIG_QEMU_LOCALSTATEDIR,
+                                           relative_pathname);
+    return get_relocated_path(dir);
 }
 
 void qemu_set_tty_echo(int fd, bool echo)
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 06/13] module: relocate path to modules
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (4 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 05/13] oslib-posix: relocate path to /var Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 07/13] net: relocate paths to helpers and scripts Paolo Bonzini
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 util/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util/module.c b/util/module.c
index aed04b578a..c117d770fd 100644
--- a/util/module.c
+++ b/util/module.c
@@ -19,6 +19,7 @@
 #endif
 #include "qemu/queue.h"
 #include "qemu/module.h"
+#include "qemu/cutils.h"
 #ifdef CONFIG_MODULE_UPGRADES
 #include "qemu-version.h"
 #endif
@@ -202,7 +203,7 @@ bool module_load_one(const char *prefix, const char *lib_name)
     if (search_dir != NULL) {
         dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
     }
-    dirs[n_dirs++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR);
+    dirs[n_dirs++] = get_relocated_path(CONFIG_QEMU_MODDIR);
     dirs[n_dirs++] = g_strdup(qemu_get_exec_dir());
 
 #ifdef CONFIG_MODULE_UPGRADES
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 07/13] net: relocate paths to helpers and scripts
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (5 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 06/13] module: relocate path to modules Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-02  8:24   ` Philippe Mathieu-Daudé
  2020-09-01  6:20 ` [PATCH 08/13] vl: relocate paths to data directories Paolo Bonzini
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/net/net.h |  4 ++--
 net/tap.c         | 28 +++++++++++++++++++++-------
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/include/net/net.h b/include/net/net.h
index e7ef42d62b..897b2d7595 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -209,8 +209,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
 int net_hub_id_for_client(NetClientState *nc, int *id);
 NetClientState *net_hub_port_find(int hub_id);
 
-#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
-#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
+#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup"
+#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown"
 #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
 #define DEFAULT_BRIDGE_INTERFACE "br0"
 
diff --git a/net/tap.c b/net/tap.c
index 14dc904fca..a271046461 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -582,14 +582,20 @@ int net_init_bridge(const Netdev *netdev, const char *name,
                     NetClientState *peer, Error **errp)
 {
     const NetdevBridgeOptions *bridge;
-    const char *helper, *br;
+    g_autofree char *default_helper = NULL;
+    const char *helper;
+    const char *br;
     TAPState *s;
     int fd, vnet_hdr;
 
     assert(netdev->type == NET_CLIENT_DRIVER_BRIDGE);
     bridge = &netdev->u.bridge;
 
-    helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
+    if (!bridge->has_helper) {
+        helper = default_helper = get_relocated_path(DEFAULT_BRIDGE_HELPER);
+    } else {
+        helper = bridge->helper;
+    }
     br     = bridge->has_br     ? bridge->br     : DEFAULT_BRIDGE_INTERFACE;
 
     fd = net_bridge_run_helper(helper, br, errp);
@@ -773,8 +779,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
     const NetdevTapOptions *tap;
     int fd, vnet_hdr = 0, i = 0, queues;
     /* for the no-fd, no-helper case */
-    const char *script = NULL; /* suppress wrong "uninit'd use" gcc warning */
-    const char *downscript = NULL;
+    const char *script;
+    const char *downscript;
     Error *err = NULL;
     const char *vhostfdname;
     char ifname[128];
@@ -784,6 +790,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
     tap = &netdev->u.tap;
     queues = tap->has_queues ? tap->queues : 1;
     vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL;
+    script = tap->has_script ? tap->script : NULL;
+    downscript = tap->has_downscript ? tap->downscript : NULL;
 
     /* QEMU hubs do not support multiqueue tap, in this case peer is set.
      * For -netdev, peer is always NULL. */
@@ -934,13 +942,19 @@ free_fail:
             return -1;
         }
     } else {
+        g_autofree char *default_script = NULL;
+        g_autofree char *default_downscript = NULL;
         if (tap->has_vhostfds) {
             error_setg(errp, "vhostfds= is invalid if fds= wasn't specified");
             return -1;
         }
-        script = tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT;
-        downscript = tap->has_downscript ? tap->downscript :
-            DEFAULT_NETWORK_DOWN_SCRIPT;
+
+        if (!tap->has_script) {
+            script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
+        }
+        if (!tap->has_downscript) {
+            downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
+        }
 
         if (tap->has_ifname) {
             pstrcpy(ifname, sizeof ifname, tap->ifname);
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 08/13] vl: relocate paths to data directories
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (6 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 07/13] net: relocate paths to helpers and scripts Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-02  8:28   ` Philippe Mathieu-Daudé
  2020-09-01  6:20 ` [PATCH 09/13] vl: relocate path to configuration file Paolo Bonzini
                   ` (5 subsequent siblings)
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

As an additional advantage, the logic is now unified between
POSIX and Win32 systems.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/qemu-common.h   |  1 -
 include/sysemu/sysemu.h |  2 +-
 os-posix.c              | 20 --------------------
 os-win32.c              | 11 -----------
 softmmu/vl.c            | 40 ++++++++++++++++++++++++++++------------
 tests/qtest/fuzz/fuzz.c |  5 +++--
 6 files changed, 32 insertions(+), 47 deletions(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index bb9496bd80..b856bfcec4 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -131,7 +131,6 @@ char *qemu_find_file(int type, const char *name);
 
 /* OS specific functions */
 void os_setup_early_signal_handling(void);
-char *os_find_datadir(void);
 int os_parse_cmd_args(int index, const char *optarg);
 
 /*
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 4b6a5c459c..817ff4cf75 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -14,7 +14,7 @@ extern const char *qemu_name;
 extern QemuUUID qemu_uuid;
 extern bool qemu_uuid_set;
 
-void qemu_add_data_dir(const char *path);
+void qemu_add_data_dir(char *path);
 
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
diff --git a/os-posix.c b/os-posix.c
index 8d8e7fc15c..af91089c01 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -80,26 +80,6 @@ void os_setup_signal_handling(void)
     sigaction(SIGTERM, &act, NULL);
 }
 
-/*
- * 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.
- *
- * The caller must use g_free() to free the returned data when it is
- * no longer required.
- */
-char *os_find_datadir(void)
-{
-    g_autofree char *dir = NULL;
-
-    dir = g_build_filename(qemu_get_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);
-}
-
 void os_set_proc_name(const char *s)
 {
 #if defined(PR_SET_NAME)
diff --git a/os-win32.c b/os-win32.c
index eb8501b9e5..fd1137bab1 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -57,17 +57,6 @@ void os_setup_early_signal_handling(void)
     atexit(os_undo_timer_resolution);
 }
 
-/*
- * Look for support files in the same directory as the executable.
- *
- * The caller must use g_free() to free the returned data when it is
- * no longer required.
- */
-char *os_find_datadir(void)
-{
-    return g_strdup(qemu_get_exec_dir());
-}
-
 void os_set_line_buffering(void)
 {
     setbuf(stdout, NULL);
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 0cc86b0766..81e325fa44 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2005,7 +2005,7 @@ char *qemu_find_file(int type, const char *name)
     return NULL;
 }
 
-void qemu_add_data_dir(const char *path)
+void qemu_add_data_dir(char *path)
 {
     int i;
 
@@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path)
     }
     for (i = 0; i < data_dir_idx; i++) {
         if (strcmp(data_dir[i], path) == 0) {
-            return; /* duplicate */
+            g_free(path); /* duplicate */
+            return;
         }
     }
-    data_dir[data_dir_idx++] = g_strdup(path);
+    data_dir[data_dir_idx++] = path;
 }
 
 static inline bool nonempty_str(const char *str)
@@ -2829,6 +2830,26 @@ static void create_default_memdev(MachineState *ms, const char *path)
                             &error_fatal);
 }
 
+/*
+ * 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 (possibly relocated).
+ *
+ * The caller must use g_free() to free the returned data when it is
+ * no longer required.
+ */
+static char *find_datadir(void)
+{
+    g_autofree char *dir = NULL;
+
+    dir = g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL);
+    if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
+        return g_steal_pointer(&dir);
+    }
+
+    return get_relocated_path(CONFIG_QEMU_DATADIR);
+}
+
 void qemu_init(int argc, char **argv, char **envp)
 {
     int i;
@@ -2862,7 +2883,7 @@ void qemu_init(int argc, char **argv, char **envp)
     Error *main_loop_err = NULL;
     Error *err = NULL;
     bool list_data_dirs = false;
-    char *dir, **dirs;
+    char **dirs;
     const char *mem_path = NULL;
     bool have_custom_ram_size;
     BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
@@ -3195,7 +3216,7 @@ void qemu_init(int argc, char **argv, char **envp)
                 if (is_help_option(optarg)) {
                     list_data_dirs = true;
                 } else {
-                    qemu_add_data_dir(optarg);
+                    qemu_add_data_dir(g_strdup(optarg));
                 }
                 break;
             case QEMU_OPTION_bios:
@@ -3927,17 +3948,12 @@ void qemu_init(int argc, char **argv, char **envp)
     /* add configured firmware directories */
     dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
     for (i = 0; dirs[i] != NULL; i++) {
-        qemu_add_data_dir(dirs[i]);
+        qemu_add_data_dir(get_relocated_path(dirs[i]));
     }
     g_strfreev(dirs);
 
     /* try to find datadir relative to the executable path */
-    dir = os_find_datadir();
-    qemu_add_data_dir(dir);
-    g_free(dir);
-
-    /* add the datadir specified when building */
-    qemu_add_data_dir(CONFIG_QEMU_DATADIR);
+    qemu_add_data_dir(find_datadir());
 
     /* -L help lists the data directories and exits. */
     if (list_data_dirs) {
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index 1811cb1d88..d9ef4b3e1e 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -170,8 +170,9 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
         datadir = g_build_filename(bindir, "pc-bios", NULL);
         if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
             qemu_add_data_dir(datadir);
-        }
-        g_free(datadir);
+        } else {
+            g_free(datadir);
+	}
     } else if (*argc > 1) {  /* The target is specified as an argument */
         target_name = (*argv)[1];
         if (!strstr(target_name, "--fuzz-target=")) {
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 09/13] vl: relocate path to configuration file
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (7 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 08/13] vl: relocate paths to data directories Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-02  8:28   ` Philippe Mathieu-Daudé
  2020-09-01  6:20 ` [PATCH 10/13] qemu-bridge-helper: relocate path to default ACL Paolo Bonzini
                   ` (4 subsequent siblings)
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 softmmu/vl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 81e325fa44..b79de9cd66 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2676,8 +2676,9 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
 static int qemu_read_default_config_file(void)
 {
     int ret;
+    g_autofree char *file = get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf");
 
-    ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
+    ret = qemu_read_config_file(file);
     if (ret < 0 && ret != -ENOENT) {
         return ret;
     }
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 10/13] qemu-bridge-helper: relocate path to default ACL
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (8 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 09/13] vl: relocate path to configuration file Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 11/13] qga: relocate path to default configuration and hook Paolo Bonzini
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-bridge-helper.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/qemu-bridge-helper.c b/qemu-bridge-helper.c
index 88b26747fc..a26e1663f0 100644
--- a/qemu-bridge-helper.c
+++ b/qemu-bridge-helper.c
@@ -40,6 +40,7 @@
 #endif
 
 #include "qemu/queue.h"
+#include "qemu/cutils.h"
 
 #include "net/tap-linux.h"
 
@@ -245,6 +246,7 @@ int main(int argc, char **argv)
     ACLList acl_list;
     int access_allowed, access_denied;
     int ret = EXIT_SUCCESS;
+    g_autofree char *acl_file = NULL;
 
 #ifdef CONFIG_LIBCAP_NG
     /* if we're run from an suid binary, immediately drop privileges preserving
@@ -257,6 +259,8 @@ int main(int argc, char **argv)
     }
 #endif
 
+    qemu_init_exec_dir(argv[0]);
+
     /* parse arguments */
     for (index = 1; index < argc; index++) {
         if (strcmp(argv[index], "--use-vnet") == 0) {
@@ -282,9 +286,10 @@ int main(int argc, char **argv)
 
     /* parse default acl file */
     QSIMPLEQ_INIT(&acl_list);
-    if (parse_acl_file(DEFAULT_ACL_FILE, &acl_list) == -1) {
+    acl_file = get_relocated_path(DEFAULT_ACL_FILE);
+    if (parse_acl_file(acl_file, &acl_list) == -1) {
         fprintf(stderr, "failed to parse default acl file `%s'\n",
-                DEFAULT_ACL_FILE);
+                acl_file);
         ret = EXIT_FAILURE;
         goto cleanup;
     }
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 11/13] qga: relocate path to default configuration and hook
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (9 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 10/13] qemu-bridge-helper: relocate path to default ACL Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01  6:20 ` [PATCH 12/13] ui: relocate paths to icons and translations Paolo Bonzini
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qga/main.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/qga/main.c b/qga/main.c
index 3febf3b0fd..740f5f7303 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -29,6 +29,7 @@
 #include "qapi/error.h"
 #include "channel.h"
 #include "qemu/bswap.h"
+#include "qemu/cutils.h"
 #include "qemu/help_option.h"
 #include "qemu/sockets.h"
 #include "qemu/systemd.h"
@@ -968,7 +969,7 @@ static void config_load(GAConfig *config)
 {
     GError *gerr = NULL;
     GKeyFile *keyfile;
-    const char *conf = g_getenv("QGA_CONF") ?: QGA_CONF_DEFAULT;
+    g_autofree char *conf = g_strdup(g_getenv("QGA_CONF")) ?: get_relocated_path(QGA_CONF_DEFAULT);
 
     /* read system config */
     keyfile = g_key_file_new();
@@ -1027,7 +1028,7 @@ end:
     if (gerr &&
         !(gerr->domain == G_FILE_ERROR && gerr->code == G_FILE_ERROR_NOENT)) {
         g_critical("error loading configuration from path: %s, %s",
-                   QGA_CONF_DEFAULT, gerr->message);
+                   conf, gerr->message);
         exit(EXIT_FAILURE);
     }
     g_clear_error(&gerr);
@@ -1141,7 +1142,7 @@ static void config_parse(GAConfig *config, int argc, char **argv)
 #ifdef CONFIG_FSFREEZE
         case 'F':
             g_free(config->fsfreeze_hook);
-            config->fsfreeze_hook = g_strdup(optarg ?: QGA_FSFREEZE_HOOK_DEFAULT);
+            config->fsfreeze_hook = g_strdup(optarg) ?: get_relocated_path(QGA_FSFREEZE_HOOK_DEFAULT);
             break;
 #endif
         case 't':
@@ -1463,6 +1464,7 @@ int main(int argc, char **argv)
 
     config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL;
 
+    qemu_init_exec_dir(argv[0]);
     qga_qmp_init_marshal(&ga_commands);
 
     init_dfl_pathnames();
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 12/13] ui: relocate paths to icons and translations
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (10 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 11/13] qga: relocate path to default configuration and hook Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-02  8:29   ` Philippe Mathieu-Daudé
  2020-09-01  6:20 ` [PATCH 13/13] configure: use a platform-neutral prefix Paolo Bonzini
  2020-09-01 21:14 ` [PATCH 00/13] Make QEMU installation relocatable Mark Cave-Ayland
  13 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 ui/gtk.c  | 10 ++++++++--
 ui/sdl2.c |  9 +++++++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index b0cc08ad6d..597f829ad9 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -51,6 +51,7 @@
 #include <math.h>
 
 #include "trace.h"
+#include "qemu/cutils.h"
 #include "ui/input.h"
 #include "sysemu/runstate.h"
 #include "sysemu/sysemu.h"
@@ -2200,6 +2201,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     GtkDisplayState *s = g_malloc0(sizeof(*s));
     GdkDisplay *window_display;
     GtkIconTheme *theme;
+    char *dir;
 
     if (!gtkinit) {
         fprintf(stderr, "gtk initialization failed\n");
@@ -2209,7 +2211,9 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
     s->opts = opts;
 
     theme = gtk_icon_theme_get_default();
-    gtk_icon_theme_prepend_search_path(theme, CONFIG_QEMU_ICONDIR);
+    dir = get_relocated_path(CONFIG_QEMU_ICONDIR);
+    gtk_icon_theme_prepend_search_path(theme, dir);
+    g_free(dir);
     g_set_prgname("qemu");
 
     s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -2225,7 +2229,9 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
      * sure that we don't accidentally break implicit assumptions.  */
     setlocale(LC_MESSAGES, "");
     setlocale(LC_CTYPE, "C.UTF-8");
-    bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
+    dir = get_relocated_path(CONFIG_QEMU_LOCALEDIR);
+    bindtextdomain("qemu", dir);
+    g_free(dir);
     bind_textdomain_codeset("qemu", "UTF-8");
     textdomain("qemu");
 
diff --git a/ui/sdl2.c b/ui/sdl2.c
index b23a8f0a8e..abad7f981e 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -25,6 +25,7 @@
 
 #include "qemu/osdep.h"
 #include "qemu/module.h"
+#include "qemu/cutils.h"
 #include "ui/console.h"
 #include "ui/input.h"
 #include "ui/sdl2.h"
@@ -795,6 +796,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
     int i;
     SDL_SysWMinfo info;
     SDL_Surface *icon = NULL;
+    char *dir;
 
     assert(o->type == DISPLAY_TYPE_SDL);
 
@@ -868,15 +870,18 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
     }
 
 #ifdef CONFIG_SDL_IMAGE
-    icon = IMG_Load(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
+    dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
+    icon = IMG_Load(dir);
 #else
     /* Load a 32x32x4 image. White pixels are transparent. */
-    icon = SDL_LoadBMP(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
+    dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
+    icon = SDL_LoadBMP(dir);
     if (icon) {
         uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255);
         SDL_SetColorKey(icon, SDL_TRUE, colorkey);
     }
 #endif
+    g_free(dir);
     if (icon) {
         SDL_SetWindowIcon(sdl2_console[0].real_window, icon);
     }
-- 
2.26.2




^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 13/13] configure: use a platform-neutral prefix
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (11 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 12/13] ui: relocate paths to icons and translations Paolo Bonzini
@ 2020-09-01  6:20 ` Paolo Bonzini
  2020-09-01 21:14 ` [PATCH 00/13] Make QEMU installation relocatable Mark Cave-Ayland
  13 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01  6:20 UTC (permalink / raw)
  To: qemu-devel; +Cc: Mark Cave-Ayland

Now that the installation is relocatable, there is no need to compile a
Windows-format prefix into Win32 binaries.  Instead, the prefix will
only be used to compute installation-relative paths, and it can be
any string.

Drop the "Program Files" path completely: it is only usable on English
versions of Windows; therefore, using the NSIS installer to get the
"correct" path to the Program Files folder is recommended, and NSIS
works just as well with any prefix.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/configure b/configure
index 105e780c09..558b3579db 100755
--- a/configure
+++ b/configure
@@ -1009,7 +1009,7 @@ if test "$mingw32" = "yes" ; then
   if compile_prog "" "-liberty" ; then
     LIBS="-liberty $LIBS"
   fi
-  prefix="c:/Program Files/QEMU"
+  prefix="/qemu"
   qemu_suffix=""
   libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32 $libs_qga"
 fi
@@ -8145,17 +8145,9 @@ echo "strip = $(meson_quote $strip)" >> $cross
 echo "windres = $(meson_quote $windres)" >> $cross
 if test -n "$cross_prefix"; then
     cross_arg="--cross-file config-meson.cross"
-    # Hack: Meson expects an absolute path for the *build* machine
-    # for the prefix, so add a slash in front of a Windows path that
-    # includes a drive letter.
-    #
-    # See https://github.com/mesonbuild/meson/issues/7577.
     echo "[host_machine]" >> $cross
     if test "$mingw32" = "yes" ; then
         echo "system = 'windows'" >> $cross
-        case $prefix in
-            ?:*) pre_prefix=/ ;;
-        esac
     fi
     case "$ARCH" in
         i386|x86_64)
@@ -8181,16 +8173,16 @@ mv $cross config-meson.cross
 
 rm -rf meson-private meson-info meson-logs
 NINJA=${ninja:-$PWD/ninjatool} $meson setup \
-        --prefix "${pre_prefix}$prefix" \
-        --libdir "${pre_prefix}$libdir" \
-        --libexecdir "${pre_prefix}$libexecdir" \
-        --bindir "${pre_prefix}$bindir" \
-        --includedir "${pre_prefix}$includedir" \
-        --datadir "${pre_prefix}$datadir" \
-        --mandir "${pre_prefix}$mandir" \
-        --sysconfdir "${pre_prefix}$sysconfdir" \
-        --localstatedir "${pre_prefix}$local_statedir" \
-        -Ddocdir="${pre_prefix}$docdir" \
+        --prefix "$prefix" \
+        --libdir "$libdir" \
+        --libexecdir "$libexecdir" \
+        --bindir "$bindir" \
+        --includedir "$includedir" \
+        --datadir "$datadir" \
+        --mandir "$mandir" \
+        --sysconfdir "$sysconfdir" \
+        --localstatedir "$local_statedir" \
+        -Ddocdir="$docdir" \
         -Dqemu_suffix="$qemu_suffix" \
         -Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
         -Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 01/13] fuzz: use qemu_get_exec_dir
  2020-09-01  6:20 ` [PATCH 01/13] fuzz: use qemu_get_exec_dir Paolo Bonzini
@ 2020-09-01  9:18   ` Thomas Huth
  2020-09-01 14:36   ` Alexander Bulekov
  1 sibling, 0 replies; 36+ messages in thread
From: Thomas Huth @ 2020-09-01  9:18 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Alexander Bulekov, Mark Cave-Ayland

On 01/09/2020 08.20, Paolo Bonzini wrote:
> Make things consistent with how softmmu/vl.c uses os_find_datadir.
> Initializing the path to the executables will also be needed for
> get_relocatable_path to work.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/qtest/fuzz/fuzz.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
> index 1ceea84702..391223219d 100644
> --- a/tests/qtest/fuzz/fuzz.c
> +++ b/tests/qtest/fuzz/fuzz.c
> @@ -152,6 +152,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>      module_call_init(MODULE_INIT_QOM);
>      module_call_init(MODULE_INIT_LIBQOS);
>  
> +    qemu_init_exec_dir(**argv);
>      target_name = strstr(**argv, "-target-");
>      if (target_name) {        /* The binary name specifies the target */
>          target_name += strlen("-target-");
> @@ -164,7 +165,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>           * location of the executable. Using this we add exec_dir/pc-bios to
>           * the datadirs.
>           */
> -        bindir = g_path_get_dirname(**argv);
> +        bindir = qemu_get_exec_dir();
>          datadir = g_build_filename(bindir, "pc-bios", NULL);
>          g_free(bindir);
>          if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 01/13] fuzz: use qemu_get_exec_dir
  2020-09-01  6:20 ` [PATCH 01/13] fuzz: use qemu_get_exec_dir Paolo Bonzini
  2020-09-01  9:18   ` Thomas Huth
@ 2020-09-01 14:36   ` Alexander Bulekov
  1 sibling, 0 replies; 36+ messages in thread
From: Alexander Bulekov @ 2020-09-01 14:36 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Mark Cave-Ayland, qemu-devel

On 200901 0220, Paolo Bonzini wrote:
> Make things consistent with how softmmu/vl.c uses os_find_datadir.
> Initializing the path to the executables will also be needed for
> get_relocatable_path to work.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/qtest/fuzz/fuzz.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
> index 1ceea84702..391223219d 100644
> --- a/tests/qtest/fuzz/fuzz.c
> +++ b/tests/qtest/fuzz/fuzz.c
> @@ -152,6 +152,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>      module_call_init(MODULE_INIT_QOM);
>      module_call_init(MODULE_INIT_LIBQOS);
>  
> +    qemu_init_exec_dir(**argv);
>      target_name = strstr(**argv, "-target-");
>      if (target_name) {        /* The binary name specifies the target */
>          target_name += strlen("-target-");
> @@ -164,7 +165,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>           * location of the executable. Using this we add exec_dir/pc-bios to
>           * the datadirs.
>           */
> -        bindir = g_path_get_dirname(**argv);
> +        bindir = qemu_get_exec_dir();
>          datadir = g_build_filename(bindir, "pc-bios", NULL);
>          g_free(bindir);
>          if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
> -- 
> 2.26.2
> 
> 
> 

Thanks.

I think this should be applied after
[PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir
for bisectability, since before 02/13, calling qemu_init_exec_dir
twice causes an assertion failure.

Otherwise,
Reviewed-by: Alexander Bulekov <alxndr@bu.edu>


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 03/13] oslib-posix: default exec_dir to bindir
  2020-09-01  6:20 ` [PATCH 03/13] oslib-posix: default exec_dir to bindir Paolo Bonzini
@ 2020-09-01 18:04   ` Richard Henderson
  2020-09-01 18:40     ` Paolo Bonzini
  0 siblings, 1 reply; 36+ messages in thread
From: Richard Henderson @ 2020-09-01 18:04 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 8/31/20 11:20 PM, Paolo Bonzini wrote:
> +        exec_dir = g_strdup(CONFIG_BINDIR);

Why the strdup?  The string constant should be fine, IIUC.


r~


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 03/13] oslib-posix: default exec_dir to bindir
  2020-09-01 18:04   ` Richard Henderson
@ 2020-09-01 18:40     ` Paolo Bonzini
  0 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01 18:40 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: Mark Cave-Ayland

On 01/09/20 20:04, Richard Henderson wrote:
> On 8/31/20 11:20 PM, Paolo Bonzini wrote:
>> +        exec_dir = g_strdup(CONFIG_BINDIR);
> 
> Why the strdup?  The string constant should be fine, IIUC.

Of course it is.

Paolo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
                   ` (12 preceding siblings ...)
  2020-09-01  6:20 ` [PATCH 13/13] configure: use a platform-neutral prefix Paolo Bonzini
@ 2020-09-01 21:14 ` Mark Cave-Ayland
  2020-09-01 21:22   ` Paolo Bonzini
  13 siblings, 1 reply; 36+ messages in thread
From: Mark Cave-Ayland @ 2020-09-01 21:14 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: luoyonggang

On 01/09/2020 07:20, Paolo Bonzini wrote:

> Right now, the installation of QEMU is not relocatable; there is
> a local hack in os_find_datadir() so that Windows binaries look
> for ROMs in the executable directory, but that has several limitations:
> 
> - it does not extend to configuration files, icons, etc.
> 
> - it does not allow changing the data directory in any way
> 
> - it does not apply to POSIX platforms
> 
> This series fixes that by making all paths within the installation
> prefix relative to the executable.  This in practice means all paths
> will be relocatable, except for /etc and /var if they're moved
> outside the prefix.
> 
> Here is an example of relocatability; before:
> 
>   $ make DESTDIR=$PWD/test install
>   $ cd test/usr/local/bin
>   $ ./qemu-system-ppc -L help
>   /usr/local/share/qemu-firmware
>   /usr/local/share/qemu
> 
> After:
> 
>   $ make DESTDIR=$PWD/test install
>   $ cd test/usr/local/bin
>   $ ./qemu-system-ppc -L help
>   /home/pbonzini/work/upstream/qemu/+build/test/usr/local/bin/../share/qemu-firmware
>   /home/pbonzini/work/upstream/qemu/+build/test/usr/local/bin/../share/qemu
> 
> The main benefit of this is on Windows, as mentioned above; but it also
> makes behavior more consistent across platforms and allows the removal
> of the hack that hides the "c:/Program Files/QEMU" prefix from Meson
> during cross compilation.
> 
> Paolo

Hi Paolo,

I've managed to give this a quick go this evening and I see the same link error
reported by Yonggang Luo at
https://lists.gnu.org/archive/html/qemu-devel/2020-09/msg00586.html, i.e.:

"cc"  -o storage-daemon/qemu-storage-daemon.exe version.rc_version.o
storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-introspect.c.obj storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-commands.c.obj
storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-emit-events.c.obj
storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-events.c.obj
storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-visit.c.obj
storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-init-commands.c.obj
storage-daemon/qemu-storage-daemon.exe.p/meson-generated_.._qapi_qapi-types.c.obj
storage-daemon/qemu-storage-daemon.exe.p/qemu-storage-daemon.c.obj
storage-daemon/qemu-storage-daemon.exe.p/.._iothread.c.obj
storage-daemon/qemu-storage-daemon.exe.p/.._blockdev-nbd.c.obj
storage-daemon/qemu-storage-daemon.exe.p/.._blockdev.c.obj
storage-daemon/qemu-storage-daemon.exe.p/.._job-qmp.c.obj
"-L/home/Mark/qemu/build/dtc/libfdt" "-Wl,--allow-shlib-undefined"
"-Wl,--whole-archive" "libqmp.fa" "libblock.fa" "crypto/libcrypto.fa"
"authz/libauthz.fa" "qom/libqom.fa" "io/libio.fa" "chardev/libchardev.fa"
"-Wl,--no-whole-archive" "-Wl,--nxcompat" "-Wl,--no-seh" "-Wl,--dynamicbase"
"-Wl,--warn-common" "-m64" "-fstack-protector-strong" "-Wl,--start-group"
"libqemuutil.a" "libqmp.fa" "libblock.fa" "crypto/libcrypto.fa" "authz/libauthz.fa"
"qom/libqom.fa" "io/libio.fa" "chardev/libchardev.fa" "@block.syms" "-lwinmm"
"-LC:/msys64/mingw64/lib" "-lgio-2.0" "-lgobject-2.0" "-lglib-2.0" "-lintl"
"-pthread" "-lm" "-LC:/msys64/mingw64/lib" "-lgthread-2.0" "-lglib-2.0" "-lintl"
"-lws2_32" "-LC:/msys64/mingw64/lib" "-lzstd" "-LC:/msys64/mingw64/lib" "-lxml2"
"-LC:/msys64/mingw64/lib" "-lz" "-lbz2" "-LC:/msys64/mingw64/lib" "-lgthread-2.0"
"-lglib-2.0" "-lintl" "-mconsole" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool"
"-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group"
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lfdt
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lcapstone
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lfdt
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lcapstone
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lslirp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
cannot find -lslirp
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile.ninja:1405: qemu-system-ppc.exe] Error 1
make[1]: *** Waiting for unfinished jobs....
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile.ninja:1407: qemu-system-ppcw.exe] Error 1
make[1]: Leaving directory '/home/Mark/qemu/build'
make: *** [GNUmakefile:11: install] Error 2

I think this means that it's missing something from Yonggang Luo's patch here:
https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg07668.html. I haven't looked
at patch 1 in that series for converting undefsym.sh to undefsym.py yet, although
last time I was able to get a working build without it.

Also patch 13 wouldn't apply for me to git master: I ended up having to make the
changes by hand, so looks like something requiring a rebase has recently snuck in.


ATB,

Mark.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-01 21:14 ` [PATCH 00/13] Make QEMU installation relocatable Mark Cave-Ayland
@ 2020-09-01 21:22   ` Paolo Bonzini
  2020-09-02  6:09     ` Mark Cave-Ayland
  0 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-01 21:22 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: Yonggang Luo, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 725 bytes --]

Il mar 1 set 2020, 23:15 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ha scritto:

> I think this means that it's missing something from Yonggang Luo's patch
> here:
> https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg07668.html.


Yes, I am a bit afraid of that patch. I don't understand exactly why it's
needed and I need to look more closely.

Paolo

I haven't looked
> at patch 1 in that series for converting undefsym.sh to undefsym.py yet,
> although
> last time I was able to get a working build without it.
>
> Also patch 13 wouldn't apply for me to git master: I ended up having to
> make the
> changes by hand, so looks like something requiring a rebase has recently
> snuck in.
>
>
> ATB,
>
> Mark.
>
>

[-- Attachment #2: Type: text/html, Size: 1481 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-01 21:22   ` Paolo Bonzini
@ 2020-09-02  6:09     ` Mark Cave-Ayland
  2020-09-02  6:42       ` Paolo Bonzini
  0 siblings, 1 reply; 36+ messages in thread
From: Mark Cave-Ayland @ 2020-09-02  6:09 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Yonggang Luo, qemu-devel

On 01/09/2020 22:22, Paolo Bonzini wrote:

> Il mar 1 set 2020, 23:15 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk
> <mailto:mark.cave-ayland@ilande.co.uk>> ha scritto:
> 
>     I think this means that it's missing something from Yonggang Luo's patch here:
>     https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg07668.html.
> 
> 
> Yes, I am a bit afraid of that patch. I don't understand exactly why it's needed and
> I need to look more closely.
> 
> Paolo

I did a quick experiment first thing this morning and it really is just the Windows
linker ld.exe that requires a Windows-style path, since I was able to successfully
build with just this:

diff --git a/configure b/configure
index f6638abadf..cb56d31a5d 100755
--- a/configure
+++ b/configure
@@ -1015,6 +1015,9 @@ if test "$mingw32" = "yes" ; then
   prefix="/qemu"
   confsuffix=""
   libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32
$libs_qga"
+  ld_pwd=$(pwd -W)
+else
+  ld_pwd=$(pwd)
 fi

 werror=""
@@ -4290,7 +4293,7 @@ EOF
               symlink "$source_path/dtc/Makefile" "dtc/Makefile"
           fi
           fdt_cflags="-I${source_path}/dtc/libfdt"
-          fdt_ldflags="-L$PWD/dtc/libfdt"
+          fdt_ldflags="-L${ld_pwd}/dtc/libfdt"
           fdt_libs="$fdt_libs"
       elif test "$fdt" = "yes" ; then
           # Not a git build & no libfdt found, prompt for system install
@@ -5275,7 +5278,7 @@ case "$capstone" in
     else
       LIBCAPSTONE=libcapstone.a
     fi
-    capstone_libs="-L$PWD/capstone -lcapstone"
+    capstone_libs="-L${ld_pwd}/capstone -lcapstone"
     capstone_cflags="-I${source_path}/capstone/include"
     ;;

@@ -6276,7 +6279,7 @@ case "$slirp" in
     fi
     mkdir -p slirp
     slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
-    slirp_libs="-L$PWD/slirp -lslirp"
+    slirp_libs="-L${ld_pwd}/slirp -lslirp"
     if test "$mingw32" = "yes" ; then
       slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
     fi


I'll try again with the relocatable install later - do I still need to pass --prefix
into configure or should I leave that for now and just use DESTDIR?


ATB,

Mark.


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-02  6:09     ` Mark Cave-Ayland
@ 2020-09-02  6:42       ` Paolo Bonzini
  2020-09-02 11:42         ` Mark Cave-Ayland
  0 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-02  6:42 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: Yonggang Luo, qemu-devel

On 02/09/20 08:09, Mark Cave-Ayland wrote:
> diff --git a/configure b/configure
> index f6638abadf..cb56d31a5d 100755
> --- a/configure
> +++ b/configure
> @@ -1015,6 +1015,9 @@ if test "$mingw32" = "yes" ; then
>    prefix="/qemu"
>    confsuffix=""
>    libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32
> $libs_qga"
> +  ld_pwd=$(pwd -W)
> +else
> +  ld_pwd=$(pwd)
>  fi

That wouldn't work for cross-compilation, but I got the idea. :)

>  werror=""
> @@ -4290,7 +4293,7 @@ EOF
>                symlink "$source_path/dtc/Makefile" "dtc/Makefile"
>            fi
>            fdt_cflags="-I${source_path}/dtc/libfdt"
> -          fdt_ldflags="-L$PWD/dtc/libfdt"
> +          fdt_ldflags="-L${ld_pwd}/dtc/libfdt"
>            fdt_libs="$fdt_libs"
>        elif test "$fdt" = "yes" ; then
>            # Not a git build & no libfdt found, prompt for system install
> @@ -5275,7 +5278,7 @@ case "$capstone" in
>      else
>        LIBCAPSTONE=libcapstone.a
>      fi
> -    capstone_libs="-L$PWD/capstone -lcapstone"
> +    capstone_libs="-L${ld_pwd}/capstone -lcapstone"
>      capstone_cflags="-I${source_path}/capstone/include"
>      ;;
> 
> @@ -6276,7 +6279,7 @@ case "$slirp" in
>      fi
>      mkdir -p slirp
>      slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
> -    slirp_libs="-L$PWD/slirp -lslirp"
> +    slirp_libs="-L${ld_pwd}/slirp -lslirp"
>      if test "$mingw32" = "yes" ; then
>        slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
>      fi

Since there is no recursive make anymore, these can be just
-Ldtc/libfdt, -Lcapstone and -Lslirp.  Nice. :)

> I'll try again with the relocatable install later - do I still need to pass --prefix
> into configure or should I leave that for now and just use DESTDIR?

You can just use DESTDIR.

Paolo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 05/13] oslib-posix: relocate path to /var
  2020-09-01  6:20 ` [PATCH 05/13] oslib-posix: relocate path to /var Paolo Bonzini
@ 2020-09-02  8:20   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-02  8:20 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 9/1/20 8:20 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  util/oslib-posix.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index a68fccb52d..8e23b8fac0 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -339,8 +339,10 @@ int qemu_pipe(int pipefd[2])
>  char *
>  qemu_get_local_state_pathname(const char *relative_pathname)
>  {
> -    return g_strdup_printf("%s/%s", CONFIG_QEMU_LOCALSTATEDIR,
> -                           relative_pathname);
> +    g_autofree char *dir = g_strdup_printf("%s/%s",
> +                                           CONFIG_QEMU_LOCALSTATEDIR,
> +                                           relative_pathname);
> +    return get_relocated_path(dir);
>  }
>  
>  void qemu_set_tty_echo(int fd, bool echo)
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/13] net: relocate paths to helpers and scripts
  2020-09-01  6:20 ` [PATCH 07/13] net: relocate paths to helpers and scripts Paolo Bonzini
@ 2020-09-02  8:24   ` Philippe Mathieu-Daudé
  2020-09-02  8:40     ` Paolo Bonzini
  0 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-02  8:24 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 9/1/20 8:20 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/net/net.h |  4 ++--
>  net/tap.c         | 28 +++++++++++++++++++++-------
>  2 files changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/include/net/net.h b/include/net/net.h
> index e7ef42d62b..897b2d7595 100644
> --- a/include/net/net.h
> +++ b/include/net/net.h
> @@ -209,8 +209,8 @@ void netdev_add(QemuOpts *opts, Error **errp);
>  int net_hub_id_for_client(NetClientState *nc, int *id);
>  NetClientState *net_hub_port_find(int hub_id);
>  
> -#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
> -#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
> +#define DEFAULT_NETWORK_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifup"
> +#define DEFAULT_NETWORK_DOWN_SCRIPT CONFIG_SYSCONFDIR "/qemu-ifdown"
>  #define DEFAULT_BRIDGE_HELPER CONFIG_QEMU_HELPERDIR "/qemu-bridge-helper"
>  #define DEFAULT_BRIDGE_INTERFACE "br0"
>  
> diff --git a/net/tap.c b/net/tap.c
> index 14dc904fca..a271046461 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -582,14 +582,20 @@ int net_init_bridge(const Netdev *netdev, const char *name,
>                      NetClientState *peer, Error **errp)
>  {
>      const NetdevBridgeOptions *bridge;
> -    const char *helper, *br;
> +    g_autofree char *default_helper = NULL;
> +    const char *helper;
> +    const char *br;
>      TAPState *s;
>      int fd, vnet_hdr;
>  
>      assert(netdev->type == NET_CLIENT_DRIVER_BRIDGE);
>      bridge = &netdev->u.bridge;
>  
> -    helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
> +    if (!bridge->has_helper) {
> +        helper = default_helper = get_relocated_path(DEFAULT_BRIDGE_HELPER);
> +    } else {
> +        helper = bridge->helper;
> +    }

Nitpicking, I find easier to review adding simply once after out of the
if() statement:

  helper = bridge->helper;

>      br     = bridge->has_br     ? bridge->br     : DEFAULT_BRIDGE_INTERFACE;
>  
>      fd = net_bridge_run_helper(helper, br, errp);
> @@ -773,8 +779,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
>      const NetdevTapOptions *tap;
>      int fd, vnet_hdr = 0, i = 0, queues;
>      /* for the no-fd, no-helper case */
> -    const char *script = NULL; /* suppress wrong "uninit'd use" gcc warning */
> -    const char *downscript = NULL;
> +    const char *script;
> +    const char *downscript;
>      Error *err = NULL;
>      const char *vhostfdname;
>      char ifname[128];
> @@ -784,6 +790,8 @@ int net_init_tap(const Netdev *netdev, const char *name,
>      tap = &netdev->u.tap;
>      queues = tap->has_queues ? tap->queues : 1;
>      vhostfdname = tap->has_vhostfd ? tap->vhostfd : NULL;
> +    script = tap->has_script ? tap->script : NULL;
> +    downscript = tap->has_downscript ? tap->downscript : NULL;
>  
>      /* QEMU hubs do not support multiqueue tap, in this case peer is set.
>       * For -netdev, peer is always NULL. */
> @@ -934,13 +942,19 @@ free_fail:
>              return -1;
>          }
>      } else {
> +        g_autofree char *default_script = NULL;
> +        g_autofree char *default_downscript = NULL;
>          if (tap->has_vhostfds) {
>              error_setg(errp, "vhostfds= is invalid if fds= wasn't specified");
>              return -1;
>          }
> -        script = tap->has_script ? tap->script : DEFAULT_NETWORK_SCRIPT;
> -        downscript = tap->has_downscript ? tap->downscript :
> -            DEFAULT_NETWORK_DOWN_SCRIPT;
> +
> +        if (!tap->has_script) {
> +            script = default_script = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
> +        }
> +        if (!tap->has_downscript) {
> +            downscript = default_downscript = get_relocated_path(DEFAULT_NETWORK_SCRIPT);
> +        }

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>  
>          if (tap->has_ifname) {
>              pstrcpy(ifname, sizeof ifname, tap->ifname);
> 



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/13] vl: relocate paths to data directories
  2020-09-01  6:20 ` [PATCH 08/13] vl: relocate paths to data directories Paolo Bonzini
@ 2020-09-02  8:28   ` Philippe Mathieu-Daudé
  2020-09-02  8:35     ` Paolo Bonzini
  0 siblings, 1 reply; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-02  8:28 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 9/1/20 8:20 AM, Paolo Bonzini wrote:
> As an additional advantage, the logic is now unified between
> POSIX and Win32 systems.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu-common.h   |  1 -
>  include/sysemu/sysemu.h |  2 +-
>  os-posix.c              | 20 --------------------
>  os-win32.c              | 11 -----------
>  softmmu/vl.c            | 40 ++++++++++++++++++++++++++++------------
>  tests/qtest/fuzz/fuzz.c |  5 +++--
>  6 files changed, 32 insertions(+), 47 deletions(-)
> 
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index bb9496bd80..b856bfcec4 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -131,7 +131,6 @@ char *qemu_find_file(int type, const char *name);
>  
>  /* OS specific functions */
>  void os_setup_early_signal_handling(void);
> -char *os_find_datadir(void);
>  int os_parse_cmd_args(int index, const char *optarg);
>  
>  /*
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index 4b6a5c459c..817ff4cf75 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -14,7 +14,7 @@ extern const char *qemu_name;
>  extern QemuUUID qemu_uuid;
>  extern bool qemu_uuid_set;
>  
> -void qemu_add_data_dir(const char *path);
> +void qemu_add_data_dir(char *path);
>  
>  void qemu_add_exit_notifier(Notifier *notify);
>  void qemu_remove_exit_notifier(Notifier *notify);
> diff --git a/os-posix.c b/os-posix.c
> index 8d8e7fc15c..af91089c01 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -80,26 +80,6 @@ void os_setup_signal_handling(void)
>      sigaction(SIGTERM, &act, NULL);
>  }
>  
> -/*
> - * 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.
> - *
> - * The caller must use g_free() to free the returned data when it is
> - * no longer required.
> - */
> -char *os_find_datadir(void)
> -{
> -    g_autofree char *dir = NULL;
> -
> -    dir = g_build_filename(qemu_get_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);
> -}
> -
>  void os_set_proc_name(const char *s)
>  {
>  #if defined(PR_SET_NAME)
> diff --git a/os-win32.c b/os-win32.c
> index eb8501b9e5..fd1137bab1 100644
> --- a/os-win32.c
> +++ b/os-win32.c
> @@ -57,17 +57,6 @@ void os_setup_early_signal_handling(void)
>      atexit(os_undo_timer_resolution);
>  }
>  
> -/*
> - * Look for support files in the same directory as the executable.
> - *
> - * The caller must use g_free() to free the returned data when it is
> - * no longer required.
> - */
> -char *os_find_datadir(void)
> -{
> -    return g_strdup(qemu_get_exec_dir());
> -}
> -
>  void os_set_line_buffering(void)
>  {
>      setbuf(stdout, NULL);
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 0cc86b0766..81e325fa44 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -2005,7 +2005,7 @@ char *qemu_find_file(int type, const char *name)
>      return NULL;
>  }
>  
> -void qemu_add_data_dir(const char *path)
> +void qemu_add_data_dir(char *path)

But we have 'const char *data_dir[16];', why remove the const?

>  {
>      int i;
>  
> @@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path)
>      }
>      for (i = 0; i < data_dir_idx; i++) {
>          if (strcmp(data_dir[i], path) == 0) {
> -            return; /* duplicate */
> +            g_free(path); /* duplicate */
> +            return;
>          }
>      }
> -    data_dir[data_dir_idx++] = g_strdup(path);
> +    data_dir[data_dir_idx++] = path;
>  }
>  
>  static inline bool nonempty_str(const char *str)
> @@ -2829,6 +2830,26 @@ static void create_default_memdev(MachineState *ms, const char *path)
>                              &error_fatal);
>  }
>  
> +/*
> + * 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 (possibly relocated).
> + *
> + * The caller must use g_free() to free the returned data when it is
> + * no longer required.
> + */
> +static char *find_datadir(void)
> +{
> +    g_autofree char *dir = NULL;
> +
> +    dir = g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL);
> +    if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
> +        return g_steal_pointer(&dir);
> +    }
> +
> +    return get_relocated_path(CONFIG_QEMU_DATADIR);
> +}
> +
>  void qemu_init(int argc, char **argv, char **envp)
>  {
>      int i;
> @@ -2862,7 +2883,7 @@ void qemu_init(int argc, char **argv, char **envp)
>      Error *main_loop_err = NULL;
>      Error *err = NULL;
>      bool list_data_dirs = false;
> -    char *dir, **dirs;
> +    char **dirs;
>      const char *mem_path = NULL;
>      bool have_custom_ram_size;
>      BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
> @@ -3195,7 +3216,7 @@ void qemu_init(int argc, char **argv, char **envp)
>                  if (is_help_option(optarg)) {
>                      list_data_dirs = true;
>                  } else {
> -                    qemu_add_data_dir(optarg);
> +                    qemu_add_data_dir(g_strdup(optarg));
>                  }
>                  break;
>              case QEMU_OPTION_bios:
> @@ -3927,17 +3948,12 @@ void qemu_init(int argc, char **argv, char **envp)
>      /* add configured firmware directories */
>      dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
>      for (i = 0; dirs[i] != NULL; i++) {
> -        qemu_add_data_dir(dirs[i]);
> +        qemu_add_data_dir(get_relocated_path(dirs[i]));
>      }
>      g_strfreev(dirs);
>  
>      /* try to find datadir relative to the executable path */
> -    dir = os_find_datadir();
> -    qemu_add_data_dir(dir);
> -    g_free(dir);
> -
> -    /* add the datadir specified when building */
> -    qemu_add_data_dir(CONFIG_QEMU_DATADIR);
> +    qemu_add_data_dir(find_datadir());
>  
>      /* -L help lists the data directories and exits. */
>      if (list_data_dirs) {
> diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
> index 1811cb1d88..d9ef4b3e1e 100644
> --- a/tests/qtest/fuzz/fuzz.c
> +++ b/tests/qtest/fuzz/fuzz.c
> @@ -170,8 +170,9 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>          datadir = g_build_filename(bindir, "pc-bios", NULL);
>          if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
>              qemu_add_data_dir(datadir);
> -        }
> -        g_free(datadir);
> +        } else {
> +            g_free(datadir);
> +	}
>      } else if (*argc > 1) {  /* The target is specified as an argument */
>          target_name = (*argv)[1];
>          if (!strstr(target_name, "--fuzz-target=")) {
> 



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 09/13] vl: relocate path to configuration file
  2020-09-01  6:20 ` [PATCH 09/13] vl: relocate path to configuration file Paolo Bonzini
@ 2020-09-02  8:28   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-02  8:28 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 9/1/20 8:20 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  softmmu/vl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/softmmu/vl.c b/softmmu/vl.c
> index 81e325fa44..b79de9cd66 100644
> --- a/softmmu/vl.c
> +++ b/softmmu/vl.c
> @@ -2676,8 +2676,9 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
>  static int qemu_read_default_config_file(void)
>  {
>      int ret;
> +    g_autofree char *file = get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf");
>  
> -    ret = qemu_read_config_file(CONFIG_QEMU_CONFDIR "/qemu.conf");
> +    ret = qemu_read_config_file(file);
>      if (ret < 0 && ret != -ENOENT) {
>          return ret;
>      }
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 12/13] ui: relocate paths to icons and translations
  2020-09-01  6:20 ` [PATCH 12/13] ui: relocate paths to icons and translations Paolo Bonzini
@ 2020-09-02  8:29   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-02  8:29 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 9/1/20 8:20 AM, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  ui/gtk.c  | 10 ++++++++--
>  ui/sdl2.c |  9 +++++++--
>  2 files changed, 15 insertions(+), 4 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/13] vl: relocate paths to data directories
  2020-09-02  8:28   ` Philippe Mathieu-Daudé
@ 2020-09-02  8:35     ` Paolo Bonzini
  2020-09-02  8:41       ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-02  8:35 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Mark Cave-Ayland

On 02/09/20 10:28, Philippe Mathieu-Daudé wrote:
>>  
>> -void qemu_add_data_dir(const char *path)
>> +void qemu_add_data_dir(char *path)
> But we have 'const char *data_dir[16];', why remove the const?

In order to free duplicates: before this patch the directory can be
statically- or stack-allocated, now it's always heap-allocated.

Paolo

>  {
>      int i;
>  
> @@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path)
>      }
>      for (i = 0; i < data_dir_idx; i++) {
>          if (strcmp(data_dir[i], path) == 0) {
> -            return; /* duplicate */
> +            g_free(path); /* duplicate */
> +            return;
>          }
>      }
> -    data_dir[data_dir_idx++] = g_strdup(path);
> +    data_dir[data_dir_idx++] = path;
>  }

Paolo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 07/13] net: relocate paths to helpers and scripts
  2020-09-02  8:24   ` Philippe Mathieu-Daudé
@ 2020-09-02  8:40     ` Paolo Bonzini
  0 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-02  8:40 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: Mark Cave-Ayland

On 02/09/20 10:24, Philippe Mathieu-Daudé wrote:
>> -    helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
>> +    if (!bridge->has_helper) {
>> +        helper = default_helper = get_relocated_path(DEFAULT_BRIDGE_HELPER);
>> +    } else {
>> +        helper = bridge->helper;
>> +    }
> Nitpicking, I find easier to review adding simply once after out of the
> if() statement:
> 
>   helper = bridge->helper;
> 

Even better,

-    helper = bridge->has_helper ? bridge->helper : DEFAULT_BRIDGE_HELPER;
+    helper = bridge->has_helper ? bridge->helper : NULL;

and move the get_relocated_path in net_bridge_run_helper.

Paolo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 08/13] vl: relocate paths to data directories
  2020-09-02  8:35     ` Paolo Bonzini
@ 2020-09-02  8:41       ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 36+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-02  8:41 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 9/2/20 10:35 AM, Paolo Bonzini wrote:
> On 02/09/20 10:28, Philippe Mathieu-Daudé wrote:
>>>  
>>> -void qemu_add_data_dir(const char *path)
>>> +void qemu_add_data_dir(char *path)
>> But we have 'const char *data_dir[16];', why remove the const?
> 
> In order to free duplicates: before this patch the directory can be
> statically- or stack-allocated, now it's always heap-allocated.

Oh I missed that, thanks.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> 
> Paolo
> 
>>  {
>>      int i;
>>  
>> @@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path)
>>      }
>>      for (i = 0; i < data_dir_idx; i++) {
>>          if (strcmp(data_dir[i], path) == 0) {
>> -            return; /* duplicate */
>> +            g_free(path); /* duplicate */
>> +            return;
>>          }
>>      }
>> -    data_dir[data_dir_idx++] = g_strdup(path);
>> +    data_dir[data_dir_idx++] = path;
>>  }
> 
> Paolo
> 



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir
  2020-09-01  6:20 ` [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir Paolo Bonzini
@ 2020-09-02 10:30   ` Thomas Huth
  0 siblings, 0 replies; 36+ messages in thread
From: Thomas Huth @ 2020-09-02 10:30 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: Mark Cave-Ayland

On 01/09/2020 08.20, Paolo Bonzini wrote:
> Just return the directory without requiring the caller to free it.
> This also removes a bogus check for NULL in os_find_datadir and
> module_load_one; g_strdup of a static variable cannot return NULL.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  include/qemu/osdep.h    |  8 ++------
>  os-posix.c              |  6 +-----
>  os-win32.c              |  2 +-
>  tests/qtest/fuzz/fuzz.c |  4 ++--
>  util/module.c           |  7 +------
>  util/oslib-posix.c      |  8 +++++---
>  util/oslib-win32.c      | 12 ++++++++----
>  7 files changed, 20 insertions(+), 27 deletions(-)
> 
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 412962d91a..db2cfffaff 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -590,12 +590,8 @@ char *qemu_get_local_state_pathname(const char *relative_pathname);
>   * Try OS specific API first, if not working, parse from argv0. */
>  void qemu_init_exec_dir(const char *argv0);
>  
> -/* Get the saved exec dir.
> - *
> - * The caller is responsible for releasing the value returned with g_free()
> - * after use.
> - */
> -char *qemu_get_exec_dir(void);
> +/* Get the saved exec dir.  */
> +const char *qemu_get_exec_dir(void);
>  
>  /**
>   * qemu_getauxval:
> diff --git a/os-posix.c b/os-posix.c
> index bf98508b6d..8d8e7fc15c 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -90,13 +90,9 @@ void os_setup_signal_handling(void)
>   */
>  char *os_find_datadir(void)
>  {
> -    g_autofree char *exec_dir = NULL;
>      g_autofree char *dir = NULL;
>  
> -    exec_dir = qemu_get_exec_dir();
> -    g_return_val_if_fail(exec_dir != NULL, NULL);
> -
> -    dir = g_build_filename(exec_dir, "pc-bios", NULL);
> +    dir = g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL);
>      if (g_file_test(dir, G_FILE_TEST_IS_DIR)) {
>          return g_steal_pointer(&dir);
>      }
> diff --git a/os-win32.c b/os-win32.c
> index c9c3afe648..eb8501b9e5 100644
> --- a/os-win32.c
> +++ b/os-win32.c
> @@ -65,7 +65,7 @@ void os_setup_early_signal_handling(void)
>   */
>  char *os_find_datadir(void)
>  {
> -    return qemu_get_exec_dir();
> +    return g_strdup(qemu_get_exec_dir());
>  }
>  
>  void os_set_line_buffering(void)
> diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
> index 391223219d..1811cb1d88 100644
> --- a/tests/qtest/fuzz/fuzz.c
> +++ b/tests/qtest/fuzz/fuzz.c
> @@ -143,7 +143,8 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>  {
>  
>      char *target_name;
> -    char *bindir, *datadir;
> +    const char *bindir;
> +    char *datadir;
>      bool serialize = false;
>  
>      /* Initialize qgraph and modules */
> @@ -167,7 +168,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
>           */
>          bindir = qemu_get_exec_dir();
>          datadir = g_build_filename(bindir, "pc-bios", NULL);
> -        g_free(bindir);
>          if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
>              qemu_add_data_dir(datadir);
>          }
> diff --git a/util/module.c b/util/module.c
> index 6e63006a8f..aed04b578a 100644
> --- a/util/module.c
> +++ b/util/module.c
> @@ -172,7 +172,6 @@ bool module_load_one(const char *prefix, const char *lib_name)
>  
>  #ifdef CONFIG_MODULES
>      char *fname = NULL;
> -    char *exec_dir;
>  #ifdef CONFIG_MODULE_UPGRADES
>      char *version_dir;
>  #endif
> @@ -199,13 +198,12 @@ bool module_load_one(const char *prefix, const char *lib_name)
>          return true;
>      }
>  
> -    exec_dir = qemu_get_exec_dir();
>      search_dir = getenv("QEMU_MODULE_DIR");
>      if (search_dir != NULL) {
>          dirs[n_dirs++] = g_strdup_printf("%s", search_dir);
>      }
>      dirs[n_dirs++] = g_strdup_printf("%s", CONFIG_QEMU_MODDIR);
> -    dirs[n_dirs++] = g_strdup_printf("%s", exec_dir ? : "");
> +    dirs[n_dirs++] = g_strdup(qemu_get_exec_dir());
>  
>  #ifdef CONFIG_MODULE_UPGRADES
>      version_dir = g_strcanon(g_strdup(QEMU_PKGVERSION),
> @@ -216,9 +214,6 @@ bool module_load_one(const char *prefix, const char *lib_name)
>  
>      assert(n_dirs <= ARRAY_SIZE(dirs));
>  
> -    g_free(exec_dir);
> -    exec_dir = NULL;
> -
>      for (i = 0; i < n_dirs; i++) {
>          fname = g_strdup_printf("%s/%s%s",
>                  dirs[i], module_name, CONFIG_HOST_DSOSUF);
> diff --git a/util/oslib-posix.c b/util/oslib-posix.c
> index ad8001a4ad..0dd8d24076 100644
> --- a/util/oslib-posix.c
> +++ b/util/oslib-posix.c
> @@ -366,7 +366,9 @@ void qemu_init_exec_dir(const char *argv0)
>      char *p = NULL;
>      char buf[PATH_MAX];
>  
> -    assert(!exec_dir[0]);
> +    if (exec_dir[0]) {
> +        return;
> +    }
>  
>  #if defined(__linux__)
>      {
> @@ -439,9 +441,9 @@ void qemu_init_exec_dir(const char *argv0)
>      g_free(dir);
>  }
>  
> -char *qemu_get_exec_dir(void)
> +const char *qemu_get_exec_dir(void)
>  {
> -    return g_strdup(exec_dir);
> +    return exec_dir;
>  }
>  
>  static void sigbus_handler(int signal)
> diff --git a/util/oslib-win32.c b/util/oslib-win32.c
> index c654dafd93..1a33912944 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[PATH_MAX];
> +static char *exec_dir;
>  
>  void qemu_init_exec_dir(const char *argv0)
>  {
> @@ -324,6 +324,10 @@ void qemu_init_exec_dir(const char *argv0)
>      char buf[MAX_PATH];
>      DWORD len;
>  
> +    if (exec_dir) {
> +        return;
> +    }
> +
>      len = GetModuleFileName(NULL, buf, sizeof(buf) - 1);
>      if (len == 0) {
>          return;
> @@ -336,13 +340,13 @@ void qemu_init_exec_dir(const char *argv0)
>      }
>      *p = 0;
>      if (access(buf, R_OK) == 0) {
> -        pstrcpy(exec_dir, sizeof(exec_dir), buf);
> +        exec_dir = g_strdup(buf);
>      }
>  }
>  
> -char *qemu_get_exec_dir(void)
> +const char *qemu_get_exec_dir(void)
>  {
> -    return g_strdup(exec_dir);
> +    return exec_dir;
>  }
>  
>  #if !GLIB_CHECK_VERSION(2, 50, 0)
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-02  6:42       ` Paolo Bonzini
@ 2020-09-02 11:42         ` Mark Cave-Ayland
  2020-09-02 11:45           ` Mark Cave-Ayland
  2020-09-02 12:16           ` Paolo Bonzini
  0 siblings, 2 replies; 36+ messages in thread
From: Mark Cave-Ayland @ 2020-09-02 11:42 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Yonggang Luo, qemu-devel

On 02/09/2020 07:42, Paolo Bonzini wrote:
> On 02/09/20 08:09, Mark Cave-Ayland wrote:
>> diff --git a/configure b/configure
>> index f6638abadf..cb56d31a5d 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1015,6 +1015,9 @@ if test "$mingw32" = "yes" ; then
>>    prefix="/qemu"
>>    confsuffix=""
>>    libs_qga="-lws2_32 -lwinmm -lpowrprof -lwtsapi32 -lwininet -liphlpapi -lnetapi32
>> $libs_qga"
>> +  ld_pwd=$(pwd -W)
>> +else
>> +  ld_pwd=$(pwd)
>>  fi
> 
> That wouldn't work for cross-compilation, but I got the idea. :)
> 
>>  werror=""
>> @@ -4290,7 +4293,7 @@ EOF
>>                symlink "$source_path/dtc/Makefile" "dtc/Makefile"
>>            fi
>>            fdt_cflags="-I${source_path}/dtc/libfdt"
>> -          fdt_ldflags="-L$PWD/dtc/libfdt"
>> +          fdt_ldflags="-L${ld_pwd}/dtc/libfdt"
>>            fdt_libs="$fdt_libs"
>>        elif test "$fdt" = "yes" ; then
>>            # Not a git build & no libfdt found, prompt for system install
>> @@ -5275,7 +5278,7 @@ case "$capstone" in
>>      else
>>        LIBCAPSTONE=libcapstone.a
>>      fi
>> -    capstone_libs="-L$PWD/capstone -lcapstone"
>> +    capstone_libs="-L${ld_pwd}/capstone -lcapstone"
>>      capstone_cflags="-I${source_path}/capstone/include"
>>      ;;
>>
>> @@ -6276,7 +6279,7 @@ case "$slirp" in
>>      fi
>>      mkdir -p slirp
>>      slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
>> -    slirp_libs="-L$PWD/slirp -lslirp"
>> +    slirp_libs="-L${ld_pwd}/slirp -lslirp"
>>      if test "$mingw32" = "yes" ; then
>>        slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
>>      fi
> 
> Since there is no recursive make anymore, these can be just
> -Ldtc/libfdt, -Lcapstone and -Lslirp.  Nice. :)

Yes indeed, a quick test with this diff on top of your patchset gives me a working
build and link (minus the manual patch still required to capstone):

diff --git a/configure b/configure
index f6638abadf..ac3ba88d8a 100755
--- a/configure
+++ b/configure
@@ -4290,7 +4290,7 @@ EOF
               symlink "$source_path/dtc/Makefile" "dtc/Makefile"
           fi
           fdt_cflags="-I${source_path}/dtc/libfdt"
-          fdt_ldflags="-L$PWD/dtc/libfdt"
+          fdt_ldflags="-Ldtc/libfdt"
           fdt_libs="$fdt_libs"
       elif test "$fdt" = "yes" ; then
           # Not a git build & no libfdt found, prompt for system install
@@ -5275,7 +5275,7 @@ case "$capstone" in
     else
       LIBCAPSTONE=libcapstone.a
     fi
-    capstone_libs="-L$PWD/capstone -lcapstone"
+    capstone_libs="-Lcapstone -lcapstone"
     capstone_cflags="-I${source_path}/capstone/include"
     ;;

@@ -6276,7 +6276,7 @@ case "$slirp" in
     fi
     mkdir -p slirp
     slirp_cflags="-I${source_path}/slirp/src -I$PWD/slirp/src"
-    slirp_libs="-L$PWD/slirp -lslirp"
+    slirp_libs="-Lslirp -lslirp"
     if test "$mingw32" = "yes" ; then
       slirp_libs="$slirp_libs -lws2_32 -liphlpapi"
     fi

>> I'll try again with the relocatable install later - do I still need to pass --prefix
>> into configure or should I leave that for now and just use DESTDIR?
> 
> You can just use DESTDIR.

This doesn't quite look right: I went with "make V=1 DESTDIR=/home/Mark/rel-qemu-git
install" and the resulting tree came out like this:

/home/Mark/rel-qemu-git:
total 20
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 msys64
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 qemu

/home/Mark/rel-qemu-git/msys64:
total 4
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 qemu

/home/Mark/rel-qemu-git/msys64/qemu:
total 29072
-rwxr-xr-x 1 Mark None   311296 Sep  2 11:26 qemu-edid.exe
-rwxr-xr-x 1 Mark None   496640 Sep  2 11:26 qemu-ga.exe
-rwxr-xr-x 1 Mark None  1650688 Sep  2 11:26 qemu-img.exe
-rwxr-xr-x 1 Mark None  1597440 Sep  2 11:26 qemu-io.exe
-rwxr-xr-x 1 Mark None  2001920 Sep  2 11:26 qemu-storage-daemon.exe
-rwxr-xr-x 1 Mark None 11850752 Sep  2 11:26 qemu-system-ppc.exe
-rwxr-xr-x 1 Mark None 11850752 Sep  2 11:26 qemu-system-ppcw.exe
drwxr-xr-x 1 Mark None        0 Sep  2 11:26 share

/home/Mark/rel-qemu-git/msys64/qemu/share:
total 4
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 locale

/home/Mark/rel-qemu-git/msys64/qemu/share/locale:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 bg
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 de_DE
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 fr_FR
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 hu
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 it
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 sv
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 tr
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 zh_CN

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/bg:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/bg/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1633 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/de_DE:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/de_DE/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1342 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/fr_FR:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/fr_FR/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1363 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/hu:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/hu/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1019 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/it:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/it/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1324 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/sv:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/sv/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1381 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/tr:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/tr/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1047 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/zh_CN:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 LC_MESSAGES

/home/Mark/rel-qemu-git/msys64/qemu/share/locale/zh_CN/LC_MESSAGES:
total 4
-rw-r--r-- 1 Mark None 1393 Sep  2 11:26 qemu.mo

/home/Mark/rel-qemu-git/qemu:
total 12068
drwxr-xr-x 1 Mark None       0 Sep  2 11:26 applications
-rw-r--r-- 1 Mark None    3211 Sep  2 11:26 bamboo.dtb
-rw-r--r-- 1 Mark None  131072 Sep  2 11:26 bios.bin
-rw-r--r-- 1 Mark None  262144 Sep  2 11:26 bios-256k.bin
-rw-r--r-- 1 Mark None   65536 Sep  2 11:26 bios-microvm.bin
-rw-r--r-- 1 Mark None    9779 Sep  2 11:26 canyonlands.dtb
-rw-r--r-- 1 Mark None   42903 Sep  2 11:26 edk2-licenses.txt
-rw-r--r-- 1 Mark None  240128 Sep  2 11:26 efi-e1000.rom
-rw-r--r-- 1 Mark None  240128 Sep  2 11:26 efi-e1000e.rom
-rw-r--r-- 1 Mark None  240128 Sep  2 11:26 efi-eepro100.rom
-rw-r--r-- 1 Mark None  238592 Sep  2 11:26 efi-ne2k_pci.rom
-rw-r--r-- 1 Mark None  238592 Sep  2 11:26 efi-pcnet.rom
-rw-r--r-- 1 Mark None  242688 Sep  2 11:26 efi-rtl8139.rom
-rw-r--r-- 1 Mark None  242688 Sep  2 11:26 efi-virtio.rom
-rw-r--r-- 1 Mark None  236032 Sep  2 11:26 efi-vmxnet3.rom
drwxr-xr-x 1 Mark None       0 Sep  2 11:26 firmware
-rw-r--r-- 1 Mark None  783192 Sep  2 11:26 hppa-firmware.img
drwxr-xr-x 1 Mark None       0 Sep  2 11:26 icons
drwxr-xr-x 1 Mark None       0 Sep  2 11:26 keymaps
-rw-r--r-- 1 Mark None    9216 Sep  2 11:26 kvmvapic.bin
-rw-r--r-- 1 Mark None    1024 Sep  2 11:26 linuxboot.bin
-rw-r--r-- 1 Mark None    1536 Sep  2 11:26 linuxboot_dma.bin
-rw-r--r-- 1 Mark None    1024 Sep  2 11:26 multiboot.bin
-rw-r--r-- 1 Mark None  696912 Sep  2 11:26 openbios-ppc
-rw-r--r-- 1 Mark None  382048 Sep  2 11:26 openbios-sparc32
-rw-r--r-- 1 Mark None 1593408 Sep  2 11:26 openbios-sparc64
-rw-r--r-- 1 Mark None   62144 Sep  2 11:26 opensbi-riscv32-generic-fw_dynamic.bin
-rw-r--r-- 1 Mark None  558668 Sep  2 11:26 opensbi-riscv32-generic-fw_dynamic.elf
-rw-r--r-- 1 Mark None   70792 Sep  2 11:26 opensbi-riscv64-generic-fw_dynamic.bin
-rw-r--r-- 1 Mark None  620424 Sep  2 11:26 opensbi-riscv64-generic-fw_dynamic.elf
-rw-r--r-- 1 Mark None  156328 Sep  2 11:26 palcode-clipper
-rw-r--r-- 1 Mark None    9882 Sep  2 11:26 petalogix-ml605.dtb
-rw-r--r-- 1 Mark None    8161 Sep  2 11:26 petalogix-s3adsp1800.dtb
-rw-r--r-- 1 Mark None    1536 Sep  2 11:26 pvh.bin
-rw-r--r-- 1 Mark None   67072 Sep  2 11:26 pxe-e1000.rom
-rw-r--r-- 1 Mark None   61440 Sep  2 11:26 pxe-eepro100.rom
-rw-r--r-- 1 Mark None   61440 Sep  2 11:26 pxe-ne2k_pci.rom
-rw-r--r-- 1 Mark None   61440 Sep  2 11:26 pxe-pcnet.rom
-rw-r--r-- 1 Mark None   61440 Sep  2 11:26 pxe-rtl8139.rom
-rw-r--r-- 1 Mark None   60416 Sep  2 11:26 pxe-virtio.rom
-rw-r--r-- 1 Mark None     850 Sep  2 11:26 QEMU,cgthree.bin
-rw-r--r-- 1 Mark None    1402 Sep  2 11:26 QEMU,tcx.bin
-rw-r--r-- 1 Mark None   18752 Sep  2 11:26 qemu_vga.ndrv
-rw-r--r-- 1 Mark None  154542 Sep  2 11:26 qemu-nsis.bmp
-rw-r--r-- 1 Mark None   42608 Sep  2 11:26 s390-ccw.img
-rw-r--r-- 1 Mark None   67232 Sep  2 11:26 s390-netboot.img
-rw-r--r-- 1 Mark None    4096 Sep  2 11:26 sgabios.bin
-rw-r--r-- 1 Mark None 1667280 Sep  2 11:26 skiboot.lid
-rw-r--r-- 1 Mark None  968368 Sep  2 11:26 slof.bin
-rw-r--r-- 1 Mark None  348512 Sep  2 11:20 trace-events-all
-rw-r--r-- 1 Mark None  349148 Sep  2 11:26 u-boot.e500
-rw-r--r-- 1 Mark None  524288 Sep  2 11:26 u-boot-sam460-20100605.bin
-rw-r--r-- 1 Mark None   38912 Sep  2 11:26 vgabios.bin
-rw-r--r-- 1 Mark None   39424 Sep  2 11:26 vgabios-ati.bin
-rw-r--r-- 1 Mark None   28672 Sep  2 11:26 vgabios-bochs-display.bin
-rw-r--r-- 1 Mark None   38912 Sep  2 11:26 vgabios-cirrus.bin
-rw-r--r-- 1 Mark None   39424 Sep  2 11:26 vgabios-qxl.bin
-rw-r--r-- 1 Mark None   28672 Sep  2 11:26 vgabios-ramfb.bin
-rw-r--r-- 1 Mark None   39424 Sep  2 11:26 vgabios-stdvga.bin
-rw-r--r-- 1 Mark None   39424 Sep  2 11:26 vgabios-virtio.bin
-rw-r--r-- 1 Mark None   39424 Sep  2 11:26 vgabios-vmware.bin

/home/Mark/rel-qemu-git/qemu/applications:
total 1
-rw-r--r-- 1 Mark None 134 Sep  2 11:26 qemu.desktop

/home/Mark/rel-qemu-git/qemu/firmware:
total 21
-rw-r--r-- 1 Mark None 696 Sep  2 11:19 50-edk2-i386-secure.json
-rw-r--r-- 1 Mark None 721 Sep  2 11:19 50-edk2-x86_64-secure.json
-rw-r--r-- 1 Mark None 602 Sep  2 11:19 60-edk2-aarch64.json
-rw-r--r-- 1 Mark None 590 Sep  2 11:19 60-edk2-arm.json
-rw-r--r-- 1 Mark None 647 Sep  2 11:19 60-edk2-i386.json
-rw-r--r-- 1 Mark None 672 Sep  2 11:19 60-edk2-x86_64.json

/home/Mark/rel-qemu-git/qemu/icons:
total 4
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 hicolor

/home/Mark/rel-qemu-git/qemu/icons/hicolor:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 128x128
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 16x16
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 24x24
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 256x256
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 32x32
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 48x48
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 512x512
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 64x64
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 scalable

/home/Mark/rel-qemu-git/qemu/icons/hicolor/128x128:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/128x128/apps:
total 12
-rw-r--r-- 1 Mark None 8286 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/16x16:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/16x16/apps:
total 4
-rw-r--r-- 1 Mark None 765 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/24x24:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/24x24/apps:
total 4
-rw-r--r-- 1 Mark None 1201 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/256x256:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/256x256/apps:
total 20
-rw-r--r-- 1 Mark None 17572 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/32x32:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/32x32/apps:
total 12
-rw-r--r-- 1 Mark None 4234 Sep  2 11:26 qemu.bmp
-rw-r--r-- 1 Mark None 1696 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/48x48:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/48x48/apps:
total 4
-rw-r--r-- 1 Mark None 2694 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/512x512:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/512x512/apps:
total 40
-rw-r--r-- 1 Mark None 38007 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/64x64:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/64x64/apps:
total 4
-rw-r--r-- 1 Mark None 3807 Sep  2 11:26 qemu.png

/home/Mark/rel-qemu-git/qemu/icons/hicolor/scalable:
total 0
drwxr-xr-x 1 Mark None 0 Sep  2 11:26 apps

/home/Mark/rel-qemu-git/qemu/icons/hicolor/scalable/apps:
total 32
-rw-r--r-- 1 Mark None 30955 Sep  2 11:26 qemu.svg

/home/Mark/rel-qemu-git/qemu/keymaps:
total 12
-rw-r--r-- 1 Mark None 4632 Aug 23 21:31 sl
-rw-r--r-- 1 Mark None 3346 Aug 23 21:31 sv


The main issues I can see are that the .exe files end up under /msys64/qemu and the
ROMs end up directly under /qemu rather than in $DESTDIR/share.

Do we know why there is also a qemu-system-ppcw.exe that appears?


ATB,

Mark.


^ permalink raw reply related	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-02 11:42         ` Mark Cave-Ayland
@ 2020-09-02 11:45           ` Mark Cave-Ayland
  2020-09-02 12:16           ` Paolo Bonzini
  1 sibling, 0 replies; 36+ messages in thread
From: Mark Cave-Ayland @ 2020-09-02 11:45 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Yonggang Luo, qemu-devel

On 02/09/2020 12:42, Mark Cave-Ayland wrote:

> The main issues I can see are that the .exe files end up under /msys64/qemu and the
> ROMs end up directly under /qemu rather than in $DESTDIR/share.
> 
> Do we know why there is also a qemu-system-ppcw.exe that appears?

The other thing to bear in mind is I may have made a mistake patching up patch 13 by
hand - could you push a rebased version to a branch somewhere for me to test?


ATB,

Mark.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-02 11:42         ` Mark Cave-Ayland
  2020-09-02 11:45           ` Mark Cave-Ayland
@ 2020-09-02 12:16           ` Paolo Bonzini
  2020-09-02 18:45             ` Mark Cave-Ayland
  1 sibling, 1 reply; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-02 12:16 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: Yonggang Luo, qemu-devel

On 02/09/20 13:42, Mark Cave-Ayland wrote:
> The main issues I can see are that the .exe files end up under /msys64/qemu
> and the ROMs end up directly under /qemu rather than in $DESTDIR/share.

This series doesn't try to change the layout; it only makes it possible
to do so (because QEMU is now able to look for ROMs relative to the
executable).

Just to be on the same page, how did you run "configure"?

> Do we know why there is also a qemu-system-ppcw.exe that appears?

That executable doesn't bring up a console window.

Paolo



^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-02 12:16           ` Paolo Bonzini
@ 2020-09-02 18:45             ` Mark Cave-Ayland
  2020-09-02 20:20               ` Paolo Bonzini
  0 siblings, 1 reply; 36+ messages in thread
From: Mark Cave-Ayland @ 2020-09-02 18:45 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Yonggang Luo, qemu-devel

On 02/09/2020 13:16, Paolo Bonzini wrote:

> On 02/09/20 13:42, Mark Cave-Ayland wrote:
>> The main issues I can see are that the .exe files end up under /msys64/qemu
>> and the ROMs end up directly under /qemu rather than in $DESTDIR/share.
> 
> This series doesn't try to change the layout; it only makes it possible
> to do so (because QEMU is now able to look for ROMs relative to the
> executable).
> 
> Just to be on the same page, how did you run "configure"?

Ah okay. It was something simple like:

./configure --target-list="ppc-softmmu" --ninja=ninja
make V=1 DESTDIR=/home/Mark/rel-qemu-git install

A quick test shows that I can move qemu-system-ppc.exe to a new directory and as long
as the pc-bios directory is in the same place then it will work fine.

>> Do we know why there is also a qemu-system-ppcw.exe that appears?
> 
> That executable doesn't bring up a console window.

From what I can see neither executable brings up a console window here. I have a
vague memory that mingw needs an extra flag/change of link options for this to work
compared to cygwin but it could use some investigation (for example
qemu-system-ppc.exe just hangs if the pc-bios directory is missing).


ATB,

Mark.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: [PATCH 00/13] Make QEMU installation relocatable
  2020-09-02 18:45             ` Mark Cave-Ayland
@ 2020-09-02 20:20               ` Paolo Bonzini
  0 siblings, 0 replies; 36+ messages in thread
From: Paolo Bonzini @ 2020-09-02 20:20 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: Yonggang Luo, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 844 bytes --]

Il mer 2 set 2020, 20:45 Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
ha scritto:

> On 02/09/2020 13:16, Paolo Bonzini wrote:
>
> > On 02/09/20 13:42, Mark Cave-Ayland wrote:
> >> The main issues I can see are that the .exe files end up under
> /msys64/qemu
> >> and the ROMs end up directly under /qemu rather than in $DESTDIR/share.
> >
> > This series doesn't try to change the layout; it only makes it possible
> > to do so (because QEMU is now able to look for ROMs relative to the
> > executable).
> >
> > Just to be on the same page, how did you run "configure"?
>
> Ah okay. It was something simple like:
>
> ./configure --target-list="ppc-softmmu" --ninja=ninja
> make V=1 DESTDIR=/home/Mark/rel-qemu-git install


That msys64 in the installation prefix is strange though. Can you send the
content of meson-logs directory?

Paolo

[-- Attachment #2: Type: text/html, Size: 1347 bytes --]

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2020-09-02 20:21 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01  6:20 [PATCH 00/13] Make QEMU installation relocatable Paolo Bonzini
2020-09-01  6:20 ` [PATCH 01/13] fuzz: use qemu_get_exec_dir Paolo Bonzini
2020-09-01  9:18   ` Thomas Huth
2020-09-01 14:36   ` Alexander Bulekov
2020-09-01  6:20 ` [PATCH 02/13] oslib: do not call g_strdup from qemu_get_exec_dir Paolo Bonzini
2020-09-02 10:30   ` Thomas Huth
2020-09-01  6:20 ` [PATCH 03/13] oslib-posix: default exec_dir to bindir Paolo Bonzini
2020-09-01 18:04   ` Richard Henderson
2020-09-01 18:40     ` Paolo Bonzini
2020-09-01  6:20 ` [PATCH 04/13] cutils: introduce get_relocated_path Paolo Bonzini
2020-09-01  6:20 ` [PATCH 05/13] oslib-posix: relocate path to /var Paolo Bonzini
2020-09-02  8:20   ` Philippe Mathieu-Daudé
2020-09-01  6:20 ` [PATCH 06/13] module: relocate path to modules Paolo Bonzini
2020-09-01  6:20 ` [PATCH 07/13] net: relocate paths to helpers and scripts Paolo Bonzini
2020-09-02  8:24   ` Philippe Mathieu-Daudé
2020-09-02  8:40     ` Paolo Bonzini
2020-09-01  6:20 ` [PATCH 08/13] vl: relocate paths to data directories Paolo Bonzini
2020-09-02  8:28   ` Philippe Mathieu-Daudé
2020-09-02  8:35     ` Paolo Bonzini
2020-09-02  8:41       ` Philippe Mathieu-Daudé
2020-09-01  6:20 ` [PATCH 09/13] vl: relocate path to configuration file Paolo Bonzini
2020-09-02  8:28   ` Philippe Mathieu-Daudé
2020-09-01  6:20 ` [PATCH 10/13] qemu-bridge-helper: relocate path to default ACL Paolo Bonzini
2020-09-01  6:20 ` [PATCH 11/13] qga: relocate path to default configuration and hook Paolo Bonzini
2020-09-01  6:20 ` [PATCH 12/13] ui: relocate paths to icons and translations Paolo Bonzini
2020-09-02  8:29   ` Philippe Mathieu-Daudé
2020-09-01  6:20 ` [PATCH 13/13] configure: use a platform-neutral prefix Paolo Bonzini
2020-09-01 21:14 ` [PATCH 00/13] Make QEMU installation relocatable Mark Cave-Ayland
2020-09-01 21:22   ` Paolo Bonzini
2020-09-02  6:09     ` Mark Cave-Ayland
2020-09-02  6:42       ` Paolo Bonzini
2020-09-02 11:42         ` Mark Cave-Ayland
2020-09-02 11:45           ` Mark Cave-Ayland
2020-09-02 12:16           ` Paolo Bonzini
2020-09-02 18:45             ` Mark Cave-Ayland
2020-09-02 20:20               ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).