@@ -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);
@@ -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' }
@@ -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')
@@ -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)"
@@ -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);
}
@@ -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];
@@ -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
@@ -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
@@ -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
])
@@ -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
@@ -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);
}
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(-)