* [PATCH v6 0/7] cutils: Introduce bundle mechanism
@ 2022-06-15 15:56 Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 1/7] datadir: Simplify firmware directory search Akihiko Odaki
` (7 more replies)
0 siblings, 8 replies; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
Developers often run QEMU without installing. The bundle mechanism
allows to look up files which should be present in installation even in
such a situation.
It is a general mechanism and can find any files located relative
to the installation tree. The build tree must have a new directory,
qemu-bundle, to represent what files the installation tree would
have for reference by the executables.
v6: Reuse get_relocated_path() in find_bundle() (Paolo Bonzini)
v5:
* Prefer qemu-bundle if it exists. (Daniel P. Berrangé)
* Check install_blobs option before installing BIOSes (Paolo Bonzini)
* Add common code to set up qemu-bundle to the top level meson.build
(Paolo Bonzini)
v4:
* Add Daniel P. Berrangé to CC. Hopefully this helps merging his patch:
https://mail.gnu.org/archive/html/qemu-devel/2022-06/msg02276.html
* Rebased to the latest QEMU.
v3:
* Note that the bundle mechanism is for any files located relative to the
installation tree including but not limited to datadir. (Peter Maydell)
* Fix "bridge" typo (Philippe Mathieu-Daudé)
v2: Rebased to the latest QEMU.
Akihiko Odaki (7):
datadir: Simplify firmware directory search
qga: Relocate a path emitted in the help text
Remove prefixes from path configuration macros
cutils: Introduce bundle mechanism
datadir: Use bundle mechanism
ui/icons: Use bundle mechanism
net: Use bundle mechanism
.travis.yml | 2 +-
include/qemu/cutils.h | 21 ++++++++++++++-
meson.build | 35 ++++++++++++++++--------
net/tap.c | 2 +-
pc-bios/keymaps/meson.build | 2 ++
pc-bios/meson.build | 19 +++++++------
qemu-options.hx | 11 ++++----
qga/main.c | 2 +-
scripts/oss-fuzz/build.sh | 2 +-
softmmu/datadir.c | 43 +++++++-----------------------
tests/qtest/fuzz/fuzz.c | 15 -----------
tests/vm/fedora | 2 +-
tests/vm/freebsd | 2 +-
tests/vm/netbsd | 2 +-
tests/vm/openbsd | 2 +-
ui/cocoa.m | 2 +-
ui/gtk.c | 2 +-
ui/icons/meson.build | 32 ++++++++++++++++------
ui/sdl2.c | 4 +--
util/cutils.c | 53 ++++++++++++++++++-------------------
20 files changed, 132 insertions(+), 123 deletions(-)
--
2.32.1 (Apple Git-133)
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v6 1/7] datadir: Simplify firmware directory search
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 16:52 ` Daniel P. Berrangé
2022-06-15 15:56 ` [PATCH v6 2/7] qga: Relocate a path emitted in the help text Akihiko Odaki
` (6 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
The old implementation had some code to accept multiple firmware
directories, but it is not used.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
softmmu/datadir.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/softmmu/datadir.c b/softmmu/datadir.c
index 160cac999a6..2a206f2740a 100644
--- a/softmmu/datadir.c
+++ b/softmmu/datadir.c
@@ -105,15 +105,8 @@ static char *find_datadir(void)
void qemu_add_default_firmwarepath(void)
{
- char **dirs;
- size_t i;
-
- /* 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(get_relocated_path(dirs[i]));
- }
- g_strfreev(dirs);
+ /* add the configured firmware directory */
+ qemu_add_data_dir(get_relocated_path(CONFIG_QEMU_FIRMWAREPATH));
/* try to find datadir relative to the executable path */
qemu_add_data_dir(find_datadir());
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v6 2/7] qga: Relocate a path emitted in the help text
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 1/7] datadir: Simplify firmware directory search Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 3/7] Remove prefixes from path configuration macros Akihiko Odaki
` (5 subsequent siblings)
7 siblings, 0 replies; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
qga/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qga/main.c b/qga/main.c
index c373fec3ee6..06e507b9979 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -270,7 +270,7 @@ QEMU_HELP_BOTTOM "\n"
, cmd, QGA_VIRTIO_PATH_DEFAULT, QGA_SERIAL_PATH_DEFAULT,
dfl_pathnames.pidfile,
#ifdef CONFIG_FSFREEZE
- QGA_FSFREEZE_HOOK_DEFAULT,
+ get_relocated_path(QGA_FSFREEZE_HOOK_DEFAULT),
#endif
dfl_pathnames.state_dir);
}
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v6 3/7] Remove prefixes from path configuration macros
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 1/7] datadir: Simplify firmware directory search Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 2/7] qga: Relocate a path emitted in the help text Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 19:25 ` Paolo Bonzini
2022-06-15 15:56 ` [PATCH v6 4/7] cutils: Introduce bundle mechanism Akihiko Odaki
` (4 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
The path configuration macros are often supplied to
get_relocated_path(), and the function had some logics to remove the
prefixes.
With this change, the prefixes are removed from those macros and
get_relocated_path() is also simplified.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
include/qemu/cutils.h | 2 +-
meson.build | 21 ++++++++++-----------
qemu-options.hx | 11 +++++------
util/cutils.c | 34 +++++++---------------------------
4 files changed, 23 insertions(+), 45 deletions(-)
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 40e10e19a7e..57de1da5c95 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -207,7 +207,7 @@ const char *qemu_get_exec_dir(void);
*
* 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
+ * `share/qemu`, the function will append `../share/qemu` to the
* directory that contains the running executable and return the result.
* The returned string should be freed by the caller.
*/
diff --git a/meson.build b/meson.build
index 0c2e11ff071..01d5e32615e 100644
--- a/meson.build
+++ b/meson.build
@@ -1679,18 +1679,17 @@ config_host_data.set_quoted('CONFIG_TLS_PRIORITY', get_option('tls_priority'))
if iasl.found()
config_host_data.set_quoted('CONFIG_IASL', iasl.full_path())
endif
-config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
+config_host_data.set_quoted('CONFIG_BINDIR', get_option('bindir'))
config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
-config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
-config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
-config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
-config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('prefix') / get_option('qemu_firmwarepath'))
-config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
-config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
-config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
-config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
-config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
-config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
+config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', qemu_confdir)
+config_host_data.set_quoted('CONFIG_QEMU_DATADIR', qemu_datadir)
+config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
+config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('libexecdir'))
+config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', qemu_icondir)
+config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('localedir'))
+config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('localstatedir'))
+config_host_data.set_quoted('CONFIG_QEMU_MODDIR', qemu_moddir)
+config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('sysconfdir'))
if config_host.has_key('CONFIG_MODULES')
config_host_data.set('CONFIG_STAMP', run_command(
diff --git a/qemu-options.hx b/qemu-options.hx
index 377d22fbd82..f0ae8f44ff2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2661,12 +2661,11 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
" [,poll-us=n]\n"
" configure a host TAP network backend with ID 'str'\n"
" connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
- " use network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n"
- " to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n"
- " to deconfigure it\n"
+ " use custom network script 'file' to configure it (optional)\n"
+ " use custom network script 'dfile' to deconfigure it (optional)\n"
" use '[down]script=no' to disable script execution\n"
- " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n"
- " configure it\n"
+ " use custom network helper 'helper' to\n"
+ " configure it (optional)\n"
" use 'fd=h' to connect to an already opened TAP interface\n"
" use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces\n"
" use 'sndbuf=nbytes' to limit the size of the send buffer (the\n"
@@ -2684,7 +2683,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
"-netdev bridge,id=str[,br=bridge][,helper=helper]\n"
" configure a host TAP network backend with ID 'str' that is\n"
" connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
- " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER ")\n"
+ " using the custom program 'helper' (optional)\n"
#endif
#ifdef __linux__
"-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]\n"
diff --git a/util/cutils.c b/util/cutils.c
index a58bcfd80e7..983db97b4df 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -917,13 +917,6 @@ 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)
{
@@ -967,7 +960,7 @@ void qemu_init_exec_dir(const char *argv0)
if (access(buf, R_OK) == 0) {
exec_dir = g_strdup(buf);
} else {
- exec_dir = CONFIG_BINDIR;
+ exec_dir = CONFIG_PREFIX G_DIR_SEPARATOR_S CONFIG_BINDIR;
}
#else
char *p = NULL;
@@ -1038,7 +1031,7 @@ void qemu_init_exec_dir(const char *argv0)
if (p) {
exec_dir = g_path_get_dirname(p);
} else {
- exec_dir = CONFIG_BINDIR;
+ exec_dir = CONFIG_PREFIX G_DIR_SEPARATOR_S CONFIG_BINDIR;
}
#endif
}
@@ -1050,39 +1043,26 @@ const char *qemu_get_exec_dir(void)
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;
+ int 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 g_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_dir == len_bindir && !memcmp(dir, bindir, len_dir));
-
/* Ascend from bindir to the common prefix with dir. */
+ len_bindir = 0;
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);
- }
+ g_string_append_c(result, G_DIR_SEPARATOR);
+ g_string_append(result, dir);
+
return g_string_free(result, false);
}
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v6 4/7] cutils: Introduce bundle mechanism
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
` (2 preceding siblings ...)
2022-06-15 15:56 ` [PATCH v6 3/7] Remove prefixes from path configuration macros Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 19:26 ` Paolo Bonzini
2022-06-15 15:56 ` [PATCH v6 5/7] datadir: Use " Akihiko Odaki
` (3 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
Developers often run QEMU without installing. The bundle mechanism
allows to look up files which should be present in installation even in
such a situation.
It is a general mechanism and can find any files located relative
to the installation tree. The build tree must have a new directory,
qemu-bundle, to represent what files the installation tree would
have for reference by the executables.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
include/qemu/cutils.h | 19 +++++++++++++++++++
meson.build | 12 ++++++++++++
util/cutils.c | 23 +++++++++++++++++++++++
3 files changed, 54 insertions(+)
diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
index 57de1da5c95..ca5bddb9e1c 100644
--- a/include/qemu/cutils.h
+++ b/include/qemu/cutils.h
@@ -213,6 +213,25 @@ const char *qemu_get_exec_dir(void);
*/
char *get_relocated_path(const char *dir);
+/**
+ * find_bundle:
+ * @path: Relative path
+ *
+ * Returns a path for the specified directory or file bundled in QEMU. It uses
+ * the directory of the running executable as the prefix first. See
+ * get_relocated_path() for the details. The next candidate is "qemu-bundle"
+ * directory in the directory of the running executable. "qemu-bundle"
+ * directory is typically present in the build tree.
+ *
+ * The returned string should be freed by the caller.
+ *
+ * Returns: a path that can access the bundle, or NULL if no matching bundle
+ * exists.
+ */
+char *find_bundle(const char *path);
+
+void list_bundle_candidates(const char *path);
+
static inline const char *yes_no(bool b)
{
return b ? "yes" : "no";
diff --git a/meson.build b/meson.build
index 01d5e32615e..ab5ab85bf4e 100644
--- a/meson.build
+++ b/meson.build
@@ -32,6 +32,7 @@ if get_option('qemu_suffix').startswith('/')
error('qemu_suffix cannot start with a /')
endif
+qemu_bundledir = meson.project_build_root() / 'qemu-bundle'
qemu_confdir = get_option('sysconfdir') / get_option('qemu_suffix')
qemu_datadir = get_option('datadir') / get_option('qemu_suffix')
qemu_docdir = get_option('docdir') / get_option('qemu_suffix')
@@ -2843,6 +2844,8 @@ target_arch = {}
target_softmmu_arch = {}
target_user_arch = {}
+bundles = {}
+
###############
# Trace files #
###############
@@ -3613,6 +3616,15 @@ if host_machine.system() == 'windows'
alias_target('installer', nsis)
endif
+###########
+# Bundles #
+###########
+
+foreach dst, src: bundles
+ run_command('mkdir', '-p', qemu_bundledir / fs.parent(dst), check: true)
+ run_command('ln', '-sf', src, qemu_bundledir / dst, check: true)
+endforeach
+
#########################
# Configuration summary #
#########################
diff --git a/util/cutils.c b/util/cutils.c
index 983db97b4df..64cb1616b9c 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1066,3 +1066,26 @@ char *get_relocated_path(const char *dir)
return g_string_free(result, false);
}
+
+char *find_bundle(const char *path)
+{
+ char *bundle = g_strdup_printf("%s/qemu-bundle/%s", qemu_get_exec_dir(), path);
+ if (access(bundle, R_OK) == 0) {
+ return bundle;
+ }
+
+ g_free(bundle);
+
+ return get_relocated_path(path);
+}
+
+void list_bundle_candidates(const char *path)
+{
+ const char *dir = qemu_get_exec_dir();
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(bundle_formats); i++) {
+ printf(bundle_formats[i], dir, path);
+ putc('\n', stdout);
+ }
+}
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v6 5/7] datadir: Use bundle mechanism
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
` (3 preceding siblings ...)
2022-06-15 15:56 ` [PATCH v6 4/7] cutils: Introduce bundle mechanism Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 19:23 ` Paolo Bonzini
2022-06-15 15:56 ` [PATCH v6 6/7] ui/icons: " Akihiko Odaki
` (2 subsequent siblings)
7 siblings, 1 reply; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
softmmu/datadir.c had its own implementation to find files in the
build tree, but now bundle mechanism provides the unified
implementation which works for datadir and the other files.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
.travis.yml | 2 +-
pc-bios/keymaps/meson.build | 2 ++
pc-bios/meson.build | 19 +++++++++----------
scripts/oss-fuzz/build.sh | 2 +-
softmmu/datadir.c | 32 ++++++++------------------------
tests/qtest/fuzz/fuzz.c | 15 ---------------
tests/vm/fedora | 2 +-
tests/vm/freebsd | 2 +-
tests/vm/netbsd | 2 +-
tests/vm/openbsd | 2 +-
util/cutils.c | 10 +++-------
11 files changed, 28 insertions(+), 62 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 9afc4a54b8f..9fee2167b95 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -223,7 +223,7 @@ jobs:
- BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$?
- |
if [ "$BUILD_RC" -eq 0 ] ; then
- mv pc-bios/s390-ccw/*.img pc-bios/ ;
+ mv pc-bios/s390-ccw/*.img qemu-bundle/share/qemu ;
${TEST_CMD} ;
else
$(exit $BUILD_RC);
diff --git a/pc-bios/keymaps/meson.build b/pc-bios/keymaps/meson.build
index 44247a12b54..dd103092290 100644
--- a/pc-bios/keymaps/meson.build
+++ b/pc-bios/keymaps/meson.build
@@ -67,3 +67,5 @@ if native_qemu_keymap.found()
endif
install_data(['sl', 'sv'], install_dir: qemu_datadir / 'keymaps')
+
+bundles += { qemu_datadir / 'keymaps': '../../../pc-bios/keymaps' }
diff --git a/pc-bios/meson.build b/pc-bios/meson.build
index 41ba1c0ec7b..0d2119836bd 100644
--- a/pc-bios/meson.build
+++ b/pc-bios/meson.build
@@ -20,6 +20,8 @@ if unpack_edk2_blobs
install: get_option('install_blobs'),
install_dir: qemu_datadir,
command: [ bzip2, '-dc', '@INPUT0@' ])
+
+ bundles += { qemu_datadir / f: '../../../pc-bios' / f }
endforeach
endif
@@ -85,16 +87,13 @@ blobs = [
'vof-nvram.bin',
]
-ln_s = [find_program('ln', required: true), '-sf']
-foreach f : blobs
- roms += custom_target(f,
- build_by_default: have_system,
- output: f,
- input: files('meson.build'), # dummy input
- install: get_option('install_blobs'),
- install_dir: qemu_datadir,
- command: [ ln_s, meson.project_source_root() / 'pc-bios' / f, '@OUTPUT@' ])
-endforeach
+if get_option('install_blobs')
+ install_data(blobs, install_dir: qemu_datadir)
+
+ foreach f : blobs
+ bundles += { qemu_datadir / f: meson.current_source_dir() / f }
+ endforeach
+endif
subdir('descriptors')
subdir('keymaps')
diff --git a/scripts/oss-fuzz/build.sh b/scripts/oss-fuzz/build.sh
index 98b56e05210..cbf8b3080e9 100755
--- a/scripts/oss-fuzz/build.sh
+++ b/scripts/oss-fuzz/build.sh
@@ -88,7 +88,7 @@ if [ "$GITLAB_CI" != "true" ]; then
fi
# Copy over the datadir
-cp -r ../pc-bios/ "$DEST_DIR/pc-bios"
+cp -r ../pc-bios/ "$DEST_DIR/qemu-bundle/share/qemu"
targets=$(./qemu-fuzz-i386 | awk '$1 ~ /\*/ {print $2}')
base_copy="$DEST_DIR/qemu-fuzz-i386-target-$(echo "$targets" | head -n 1)"
diff --git a/softmmu/datadir.c b/softmmu/datadir.c
index 2a206f2740a..338479baddd 100644
--- a/softmmu/datadir.c
+++ b/softmmu/datadir.c
@@ -35,6 +35,7 @@ char *qemu_find_file(int type, const char *name)
int i;
const char *subdir;
char *buf;
+ char *bundle;
/* Try the name as a straight path first */
if (access(name, R_OK) == 0) {
@@ -61,7 +62,12 @@ char *qemu_find_file(int type, const char *name)
}
g_free(buf);
}
- return NULL;
+
+ bundle = g_strdup_printf("%s/%s%s", CONFIG_QEMU_DATADIR, subdir, name);
+ buf = find_bundle(bundle);
+ g_free(bundle);
+ trace_load_file(name, buf);
+ return buf;
}
void qemu_add_data_dir(char *path)
@@ -83,33 +89,10 @@ void qemu_add_data_dir(char *path)
data_dir[data_dir_idx++] = path;
}
-/*
- * 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_add_default_firmwarepath(void)
{
/* add the configured firmware directory */
qemu_add_data_dir(get_relocated_path(CONFIG_QEMU_FIRMWAREPATH));
-
- /* try to find datadir relative to the executable path */
- qemu_add_data_dir(find_datadir());
}
void qemu_list_data_dirs(void)
@@ -118,4 +101,5 @@ void qemu_list_data_dirs(void)
for (i = 0; i < data_dir_idx; i++) {
printf("%s\n", data_dir[i]);
}
+ list_bundle_candidates(CONFIG_QEMU_DATADIR);
}
diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c
index 0ad4ba9e94d..2062b40d82b 100644
--- a/tests/qtest/fuzz/fuzz.c
+++ b/tests/qtest/fuzz/fuzz.c
@@ -174,21 +174,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp)
target_name = strstr(**argv, "-target-");
if (target_name) { /* The binary name specifies the target */
target_name += strlen("-target-");
- /*
- * With oss-fuzz, the executable is kept in the root of a directory (we
- * cannot assume the path). All data (including bios binaries) must be
- * in the same dir, or a subdir. Thus, we cannot place the pc-bios so
- * that it would be in exec_dir/../pc-bios.
- * As a workaround, oss-fuzz allows us to use argv[0] to get the
- * location of the executable. Using this we add exec_dir/pc-bios to
- * the datadirs.
- */
- bindir = qemu_get_exec_dir();
- datadir = g_build_filename(bindir, "pc-bios", NULL);
- if (g_file_test(datadir, G_FILE_TEST_IS_DIR)) {
- qemu_add_data_dir(datadir);
- } else {
- g_free(datadir);
}
} else if (*argc > 1) { /* The target is specified as an argument */
target_name = (*argv)[1];
diff --git a/tests/vm/fedora b/tests/vm/fedora
index 92b78d6e2c9..4ccd31bba61 100755
--- a/tests/vm/fedora
+++ b/tests/vm/fedora
@@ -79,7 +79,7 @@ class FedoraVM(basevm.BaseVM):
self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
+ "-bios", "qemu-bundle/share/qemu/bios-256k.bin",
"-machine", "graphics=off",
"-device", "VGA",
"-cdrom", iso
diff --git a/tests/vm/freebsd b/tests/vm/freebsd
index 805db759d67..2095d8c5204 100755
--- a/tests/vm/freebsd
+++ b/tests/vm/freebsd
@@ -95,7 +95,7 @@ class FreeBSDVM(basevm.BaseVM):
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
+ "-bios", "qemu-bundle/share/qemu/bios-256k.bin",
"-machine", "graphics=off",
"-device", "VGA",
"-cdrom", iso
diff --git a/tests/vm/netbsd b/tests/vm/netbsd
index 45aa9a7fda7..d59cfedb83e 100755
--- a/tests/vm/netbsd
+++ b/tests/vm/netbsd
@@ -86,7 +86,7 @@ class NetBSDVM(basevm.BaseVM):
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
+ "-bios", "qemu-bundle/share/qemu/bios-256k.bin",
"-machine", "graphics=off",
"-cdrom", iso
])
diff --git a/tests/vm/openbsd b/tests/vm/openbsd
index 13c82542140..036907c6243 100755
--- a/tests/vm/openbsd
+++ b/tests/vm/openbsd
@@ -82,7 +82,7 @@ class OpenBSDVM(basevm.BaseVM):
self.print_step("Booting installer")
self.boot(img_tmp, extra_args = [
- "-bios", "pc-bios/bios-256k.bin",
+ "-bios", "qemu-bundle/share/qemu/bios-256k.bin",
"-machine", "graphics=off",
"-device", "VGA",
"-cdrom", iso
diff --git a/util/cutils.c b/util/cutils.c
index 64cb1616b9c..c3aea6c6f68 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -1081,11 +1081,7 @@ char *find_bundle(const char *path)
void list_bundle_candidates(const char *path)
{
- const char *dir = qemu_get_exec_dir();
- int i;
-
- for (i = 0; i < ARRAY_SIZE(bundle_formats); i++) {
- printf(bundle_formats[i], dir, path);
- putc('\n', stdout);
- }
+ char *relocated = get_relocated_path(path);
+ printf("%s/qemu-bundle/%s\n%s\n", qemu_get_exec_dir(), path, relocated);
+ g_free(relocated);
}
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v6 6/7] ui/icons: Use bundle mechanism
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
` (4 preceding siblings ...)
2022-06-15 15:56 ` [PATCH v6 5/7] datadir: Use " Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 7/7] net: " Akihiko Odaki
2022-06-15 19:27 ` [PATCH v6 0/7] cutils: Introduce " Paolo Bonzini
7 siblings, 0 replies; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
ui/cocoa.m | 2 +-
ui/gtk.c | 2 +-
ui/icons/meson.build | 32 ++++++++++++++++++++++++--------
ui/sdl2.c | 4 ++--
4 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 84c84e98fc5..25584cc78ce 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1562,7 +1562,7 @@ - (BOOL)verifyQuit
- (IBAction) do_about_menu_item: (id) sender
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- char *icon_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png");
+ char *icon_path_c = find_bundle(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png");
NSString *icon_path = [NSString stringWithUTF8String:icon_path_c];
g_free(icon_path_c);
NSImage *icon = [[NSImage alloc] initWithContentsOfFile:icon_path];
diff --git a/ui/gtk.c b/ui/gtk.c
index 2a791dd2aa0..27d5a3407cf 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2321,7 +2321,7 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
s->opts = opts;
theme = gtk_icon_theme_get_default();
- dir = get_relocated_path(CONFIG_QEMU_ICONDIR);
+ dir = find_bundle(CONFIG_QEMU_ICONDIR);
gtk_icon_theme_prepend_search_path(theme, dir);
g_free(dir);
g_set_prgname("qemu");
diff --git a/ui/icons/meson.build b/ui/icons/meson.build
index 12c52080ebd..1d99aff10ed 100644
--- a/ui/icons/meson.build
+++ b/ui/icons/meson.build
@@ -1,13 +1,29 @@
+icons = [
+ {
+ 'source': 'qemu_32x32.bmp',
+ 'install': 'hicolor' / '32x32' / 'apps' / 'qemu.bmp',
+ },
+ {
+ 'source': 'qemu.svg',
+ 'install': 'hicolor' / 'scalable' / 'apps' / 'qemu.svg',
+ },
+]
+
foreach s: [16, 24, 32, 48, 64, 128, 256, 512]
s = '@0@x@0@'.format(s.to_string())
- install_data('qemu_@0@.png'.format(s),
- rename: 'qemu.png',
- install_dir: qemu_icondir / 'hicolor' / s / 'apps')
+ icons += {
+ 'source': 'qemu_@0@.png'.format(s),
+ 'install': 'hicolor' / s / 'apps' / 'qemu.png',
+ }
endforeach
-install_data('qemu_32x32.bmp',
- rename: 'qemu.bmp',
- install_dir: qemu_icondir / 'hicolor' / '32x32' / 'apps')
+foreach icon: icons
+ source = icon.get('source')
+ install = icon.get('install')
+
+ install_data(source,
+ rename: fs.name(install),
+ install_dir: qemu_icondir / fs.parent(install))
-install_data('qemu.svg',
- install_dir: qemu_icondir / 'hicolor' / 'scalable' / 'apps')
+ bundles += { qemu_bundledir / qemu_icondir / install: meson.current_source_dir() / source }
+endforeach
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 8cb77416af2..916815cc8a2 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -910,11 +910,11 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
}
#ifdef CONFIG_SDL_IMAGE
- dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
+ dir = find_bundle(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
icon = IMG_Load(dir);
#else
/* Load a 32x32x4 image. White pixels are transparent. */
- dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
+ dir = find_bundle(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
icon = SDL_LoadBMP(dir);
if (icon) {
uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255);
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v6 7/7] net: Use bundle mechanism
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
` (5 preceding siblings ...)
2022-06-15 15:56 ` [PATCH v6 6/7] ui/icons: " Akihiko Odaki
@ 2022-06-15 15:56 ` Akihiko Odaki
2022-06-15 19:27 ` [PATCH v6 0/7] cutils: Introduce " Paolo Bonzini
7 siblings, 0 replies; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-15 15:56 UTC (permalink / raw)
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé, Paolo Bonzini, Akihiko Odaki
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
meson.build | 2 ++
net/tap.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index ab5ab85bf4e..72e42048cbe 100644
--- a/meson.build
+++ b/meson.build
@@ -3574,6 +3574,8 @@ if have_tools
dependencies: [authz, crypto, io, qom, qemuutil,
libcap_ng, mpathpersist],
install: true)
+
+ bundles += { get_option('libexecdir') / 'qemu-bridge-helper': '../../qemu-bridge-helper' }
endif
if have_ivshmem
diff --git a/net/tap.c b/net/tap.c
index b3ddfd4a74b..5beba85fb22 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -507,7 +507,7 @@ static int net_bridge_run_helper(const char *helper, const char *bridge,
sigprocmask(SIG_BLOCK, &mask, &oldmask);
if (!helper) {
- helper = default_helper = get_relocated_path(DEFAULT_BRIDGE_HELPER);
+ helper = default_helper = find_bundle(DEFAULT_BRIDGE_HELPER);
}
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1) {
--
2.32.1 (Apple Git-133)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v6 1/7] datadir: Simplify firmware directory search
2022-06-15 15:56 ` [PATCH v6 1/7] datadir: Simplify firmware directory search Akihiko Odaki
@ 2022-06-15 16:52 ` Daniel P. Berrangé
0 siblings, 0 replies; 15+ messages in thread
From: Daniel P. Berrangé @ 2022-06-15 16:52 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann, Paolo Bonzini
On Thu, Jun 16, 2022 at 12:56:28AM +0900, Akihiko Odaki wrote:
> The old implementation had some code to accept multiple firmware
> directories, but it is not used.
It is used by distros. In Fedora builds for example:
https://kojipkgs.fedoraproject.org/packages/qemu/7.0.0/1.fc37/data/logs/x86_64/build.log
Passes this to configure:
--firmwarepath=/usr/share/qemu-firmware:/usr/share/ipxe/qemu:/usr/share/seavgabios:/usr/share/seabios:/usr/share/sgabios
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> ---
> softmmu/datadir.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/softmmu/datadir.c b/softmmu/datadir.c
> index 160cac999a6..2a206f2740a 100644
> --- a/softmmu/datadir.c
> +++ b/softmmu/datadir.c
> @@ -105,15 +105,8 @@ static char *find_datadir(void)
>
> void qemu_add_default_firmwarepath(void)
> {
> - char **dirs;
> - size_t i;
> -
> - /* 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(get_relocated_path(dirs[i]));
> - }
> - g_strfreev(dirs);
> + /* add the configured firmware directory */
> + qemu_add_data_dir(get_relocated_path(CONFIG_QEMU_FIRMWAREPATH));
>
> /* try to find datadir relative to the executable path */
> qemu_add_data_dir(find_datadir());
> --
> 2.32.1 (Apple Git-133)
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v6 5/7] datadir: Use bundle mechanism
2022-06-15 15:56 ` [PATCH v6 5/7] datadir: Use " Akihiko Odaki
@ 2022-06-15 19:23 ` Paolo Bonzini
0 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2022-06-15 19:23 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé
On 6/15/22 17:56, Akihiko Odaki wrote:
> diff --git a/tests/vm/fedora b/tests/vm/fedora
> index 92b78d6e2c9..4ccd31bba61 100755
> --- a/tests/vm/fedora
> +++ b/tests/vm/fedora
> @@ -79,7 +79,7 @@ class FedoraVM(basevm.BaseVM):
> self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
> self.print_step("Booting installer")
> self.boot(img_tmp, extra_args = [
> - "-bios", "pc-bios/bios-256k.bin",
> + "-bios", "qemu-bundle/share/qemu/bios-256k.bin",
> "-machine", "graphics=off",
> "-device", "VGA",
> "-cdrom", iso
> diff --git a/tests/vm/freebsd b/tests/vm/freebsd
> index 805db759d67..2095d8c5204 100755
> --- a/tests/vm/freebsd
> +++ b/tests/vm/freebsd
> @@ -95,7 +95,7 @@ class FreeBSDVM(basevm.BaseVM):
>
> self.print_step("Booting installer")
> self.boot(img_tmp, extra_args = [
> - "-bios", "pc-bios/bios-256k.bin",
> + "-bios", "qemu-bundle/share/qemu/bios-256k.bin",
> "-machine", "graphics=off",
> "-device", "VGA",
> "-cdrom", iso
I think -bios can be removed completely here.
Paolo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v6 3/7] Remove prefixes from path configuration macros
2022-06-15 15:56 ` [PATCH v6 3/7] Remove prefixes from path configuration macros Akihiko Odaki
@ 2022-06-15 19:25 ` Paolo Bonzini
0 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2022-06-15 19:25 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé
On 6/15/22 17:56, Akihiko Odaki wrote:
> The path configuration macros are often supplied to
> get_relocated_path(), and the function had some logics to remove the
> prefixes.
>
> With this change, the prefixes are removed from those macros and
> get_relocated_path() is also simplified.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
This doesn't work if somebody configures with --prefix=/usr
--libexecdir=/usr/libexec. Adding the prefixes in meson.build was done
as a canonicalization step so that the C code has less cases to care about.
Paolo
> ---
> include/qemu/cutils.h | 2 +-
> meson.build | 21 ++++++++++-----------
> qemu-options.hx | 11 +++++------
> util/cutils.c | 34 +++++++---------------------------
> 4 files changed, 23 insertions(+), 45 deletions(-)
>
> diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h
> index 40e10e19a7e..57de1da5c95 100644
> --- a/include/qemu/cutils.h
> +++ b/include/qemu/cutils.h
> @@ -207,7 +207,7 @@ const char *qemu_get_exec_dir(void);
> *
> * 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
> + * `share/qemu`, the function will append `../share/qemu` to the
> * directory that contains the running executable and return the result.
> * The returned string should be freed by the caller.
> */
> diff --git a/meson.build b/meson.build
> index 0c2e11ff071..01d5e32615e 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1679,18 +1679,17 @@ config_host_data.set_quoted('CONFIG_TLS_PRIORITY', get_option('tls_priority'))
> if iasl.found()
> config_host_data.set_quoted('CONFIG_IASL', iasl.full_path())
> endif
> -config_host_data.set_quoted('CONFIG_BINDIR', get_option('prefix') / get_option('bindir'))
> +config_host_data.set_quoted('CONFIG_BINDIR', get_option('bindir'))
> config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix'))
> -config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir)
> -config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir)
> -config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
> -config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('prefix') / get_option('qemu_firmwarepath'))
> -config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
> -config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
> -config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
> -config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
> -config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
> -config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('prefix') / get_option('sysconfdir'))
> +config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', qemu_confdir)
> +config_host_data.set_quoted('CONFIG_QEMU_DATADIR', qemu_datadir)
> +config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
> +config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('libexecdir'))
> +config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', qemu_icondir)
> +config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('localedir'))
> +config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('localstatedir'))
> +config_host_data.set_quoted('CONFIG_QEMU_MODDIR', qemu_moddir)
> +config_host_data.set_quoted('CONFIG_SYSCONFDIR', get_option('sysconfdir'))
>
> if config_host.has_key('CONFIG_MODULES')
> config_host_data.set('CONFIG_STAMP', run_command(
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 377d22fbd82..f0ae8f44ff2 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2661,12 +2661,11 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
> " [,poll-us=n]\n"
> " configure a host TAP network backend with ID 'str'\n"
> " connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
> - " use network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n"
> - " to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n"
> - " to deconfigure it\n"
> + " use custom network script 'file' to configure it (optional)\n"
> + " use custom network script 'dfile' to deconfigure it (optional)\n"
> " use '[down]script=no' to disable script execution\n"
> - " use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n"
> - " configure it\n"
> + " use custom network helper 'helper' to\n"
> + " configure it (optional)\n"
> " use 'fd=h' to connect to an already opened TAP interface\n"
> " use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces\n"
> " use 'sndbuf=nbytes' to limit the size of the send buffer (the\n"
> @@ -2684,7 +2683,7 @@ DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
> "-netdev bridge,id=str[,br=bridge][,helper=helper]\n"
> " configure a host TAP network backend with ID 'str' that is\n"
> " connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
> - " using the program 'helper (default=" DEFAULT_BRIDGE_HELPER ")\n"
> + " using the custom program 'helper' (optional)\n"
> #endif
> #ifdef __linux__
> "-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]\n"
> diff --git a/util/cutils.c b/util/cutils.c
> index a58bcfd80e7..983db97b4df 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -917,13 +917,6 @@ 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)
> {
> @@ -967,7 +960,7 @@ void qemu_init_exec_dir(const char *argv0)
> if (access(buf, R_OK) == 0) {
> exec_dir = g_strdup(buf);
> } else {
> - exec_dir = CONFIG_BINDIR;
> + exec_dir = CONFIG_PREFIX G_DIR_SEPARATOR_S CONFIG_BINDIR;
> }
> #else
> char *p = NULL;
> @@ -1038,7 +1031,7 @@ void qemu_init_exec_dir(const char *argv0)
> if (p) {
> exec_dir = g_path_get_dirname(p);
> } else {
> - exec_dir = CONFIG_BINDIR;
> + exec_dir = CONFIG_PREFIX G_DIR_SEPARATOR_S CONFIG_BINDIR;
> }
> #endif
> }
> @@ -1050,39 +1043,26 @@ const char *qemu_get_exec_dir(void)
>
> 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;
> + int 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 g_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_dir == len_bindir && !memcmp(dir, bindir, len_dir));
> -
> /* Ascend from bindir to the common prefix with dir. */
> + len_bindir = 0;
> 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);
> - }
> + g_string_append_c(result, G_DIR_SEPARATOR);
> + g_string_append(result, dir);
> +
> return g_string_free(result, false);
> }
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v6 4/7] cutils: Introduce bundle mechanism
2022-06-15 15:56 ` [PATCH v6 4/7] cutils: Introduce bundle mechanism Akihiko Odaki
@ 2022-06-15 19:26 ` Paolo Bonzini
0 siblings, 0 replies; 15+ messages in thread
From: Paolo Bonzini @ 2022-06-15 19:26 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé
On 6/15/22 17:56, Akihiko Odaki wrote:
> +void list_bundle_candidates(const char *path)
> +{
> + const char *dir = qemu_get_exec_dir();
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(bundle_formats); i++) {
> + printf(bundle_formats[i], dir, path);
> + putc('\n', stdout);
> + }
This is not bisectable, bundle_formats[] doesn't exist here.
Paolo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v6 0/7] cutils: Introduce bundle mechanism
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
` (6 preceding siblings ...)
2022-06-15 15:56 ` [PATCH v6 7/7] net: " Akihiko Odaki
@ 2022-06-15 19:27 ` Paolo Bonzini
2022-06-16 9:18 ` Paolo Bonzini
7 siblings, 1 reply; 15+ messages in thread
From: Paolo Bonzini @ 2022-06-15 19:27 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé
On 6/15/22 17:56, Akihiko Odaki wrote:
> Developers often run QEMU without installing. The bundle mechanism
> allows to look up files which should be present in installation even in
> such a situation.
>
> It is a general mechanism and can find any files located relative
> to the installation tree. The build tree must have a new directory,
> qemu-bundle, to represent what files the installation tree would
> have for reference by the executables.
Thanks for prototyping this, I think this is appealing. I'll take a
look later at using meson introspection info to build the preinstall layout.
Paolo
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v6 0/7] cutils: Introduce bundle mechanism
2022-06-15 19:27 ` [PATCH v6 0/7] cutils: Introduce " Paolo Bonzini
@ 2022-06-16 9:18 ` Paolo Bonzini
2022-06-24 16:33 ` Akihiko Odaki
0 siblings, 1 reply; 15+ messages in thread
From: Paolo Bonzini @ 2022-06-16 9:18 UTC (permalink / raw)
To: Akihiko Odaki
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé
On 6/15/22 21:27, Paolo Bonzini wrote:
>
> Thanks for prototyping this, I think this is appealing. I'll take a
> look later at using meson introspection info to build the preinstall
> layout.
Something like this:
diff --git a/meson.build b/meson.build
index 0458b69cdf..17023d511a 100644
--- a/meson.build
+++ b/meson.build
@@ -3612,6 +3612,21 @@ if host_machine.system() == 'windows'
alias_target('installer', nsis)
endif
+#####################
+# Preinstalled data #
+#####################
+
+qemu_bundle_sources_stamp = configure_file(
+ output: 'qemu-bundle-sources.stamp',
+ command: ['touch', '@OUTPUT'])
+custom_target('tree with preinstalled data files',
+ build_by_default: true,
+ output: 'qemu-bundle.stamp',
+ input: qemu_bundle_sources_stamp,
+ env: {'MESON': config_host['MESON']},
+ command: files('symlink-install-tree.py'),
+ capture: true)
+
#########################
# Configuration summary #
#########################
diff --git a/scripts/symlink-install-tree.py
b/scripts/symlink-install-tree.py
new file mode 100644
index 0000000000..cd66dc06cd
--- /dev/null
+++ b/scripts/symlink-install-tree.py
@@ -0,0 +1,34 @@
+#! /usr/bin/env python3
+
+import json
+import os
+import subprocess
+
+def destdir_join(d1: str, d2: str) -> str:
+ if not d1:
+ return d2
+ if not os.path.isabs(d2):
+ return os.path.join(d1, d2)
+
+ # c:\destdir + c:\prefix must produce c:\destdir\prefix
+ if len(d2) > 1 and d2[1] == ':':
+ return d1 + d2[2:]
+ return d1 + d2
+
+meson = os.environ.get("MESON")
+out = subprocess.run([meson, 'introspect', '--installed'],
+ stdout=subprocess.PIPE, check=True).stdout
+for source, dest in json.loads(out).items():
+ assert os.path.isabs(source)
+ bundle_dest = destdir_join('qemu-bundle', dest)
+ path = os.path.dirname(bundle_dest)
+ try:
+ os.makedirs(path, exist_ok=True)
+ except e:
+ print('error making directory {path}', file=sys.stderr)
+ raise e
+ try:
+ os.symlink(source, bundle_dest)
+ except e:
+ print('error making symbolic link {dest}', file=sys.stderr)
+ raise e
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v6 0/7] cutils: Introduce bundle mechanism
2022-06-16 9:18 ` Paolo Bonzini
@ 2022-06-24 16:33 ` Akihiko Odaki
0 siblings, 0 replies; 15+ messages in thread
From: Akihiko Odaki @ 2022-06-24 16:33 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Peter Maydell, Jason Wang, qemu-devel, Programmingkid,
Philippe Mathieu-Daudé, Gerd Hoffmann,
Daniel P . Berrangé
On 2022/06/16 18:18, Paolo Bonzini wrote:
> +def destdir_join(d1: str, d2: str) -> str:
> + if not d1:
> + return d2
> + if not os.path.isabs(d2):
> + return os.path.join(d1, d2)
> +
> + # c:\destdir + c:\prefix must produce c:\destdir\prefix
> + if len(d2) > 1 and d2[1] == ':':
> + return d1 + d2[2:]
> + return d1 + d2
This is from Meson but buggy so I fixed it and opened a pull request for
Meson:
https://github.com/mesonbuild/meson/pull/10531
The script included in v8 has the fixed version of destdir_join.
Regards,
Akihiko Odaki
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2022-06-24 16:35 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-15 15:56 [PATCH v6 0/7] cutils: Introduce bundle mechanism Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 1/7] datadir: Simplify firmware directory search Akihiko Odaki
2022-06-15 16:52 ` Daniel P. Berrangé
2022-06-15 15:56 ` [PATCH v6 2/7] qga: Relocate a path emitted in the help text Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 3/7] Remove prefixes from path configuration macros Akihiko Odaki
2022-06-15 19:25 ` Paolo Bonzini
2022-06-15 15:56 ` [PATCH v6 4/7] cutils: Introduce bundle mechanism Akihiko Odaki
2022-06-15 19:26 ` Paolo Bonzini
2022-06-15 15:56 ` [PATCH v6 5/7] datadir: Use " Akihiko Odaki
2022-06-15 19:23 ` Paolo Bonzini
2022-06-15 15:56 ` [PATCH v6 6/7] ui/icons: " Akihiko Odaki
2022-06-15 15:56 ` [PATCH v6 7/7] net: " Akihiko Odaki
2022-06-15 19:27 ` [PATCH v6 0/7] cutils: Introduce " Paolo Bonzini
2022-06-16 9:18 ` Paolo Bonzini
2022-06-24 16:33 ` Akihiko Odaki
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).