|
@@ -2005,7 +2005,7 @@ char *qemu_find_file(int type, const char *name)
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
-void qemu_add_data_dir(const char *path)
|
|
|
|
|
|
+void qemu_add_data_dir(char *path)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
|
|
|
|
@@ -2017,10 +2017,11 @@ void qemu_add_data_dir(const char *path)
|
|
}
|
|
}
|
|
for (i = 0; i < data_dir_idx; i++) {
|
|
for (i = 0; i < data_dir_idx; i++) {
|
|
if (strcmp(data_dir[i], path) == 0) {
|
|
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)
|
|
static inline bool nonempty_str(const char *str)
|
|
@@ -2829,6 +2830,26 @@ static void create_default_memdev(MachineState *ms, const char *path)
|
|
&error_fatal);
|
|
&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)
|
|
void qemu_init(int argc, char **argv, char **envp)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
@@ -2862,7 +2883,7 @@ void qemu_init(int argc, char **argv, char **envp)
|
|
Error *main_loop_err = NULL;
|
|
Error *main_loop_err = NULL;
|
|
Error *err = NULL;
|
|
Error *err = NULL;
|
|
bool list_data_dirs = false;
|
|
bool list_data_dirs = false;
|
|
- char *dir, **dirs;
|
|
|
|
|
|
+ char **dirs;
|
|
const char *mem_path = NULL;
|
|
const char *mem_path = NULL;
|
|
bool have_custom_ram_size;
|
|
bool have_custom_ram_size;
|
|
BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
|
|
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)) {
|
|
if (is_help_option(optarg)) {
|
|
list_data_dirs = true;
|
|
list_data_dirs = true;
|
|
} else {
|
|
} else {
|
|
- qemu_add_data_dir(optarg);
|
|
|
|
|
|
+ qemu_add_data_dir(g_strdup(optarg));
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case QEMU_OPTION_bios:
|
|
case QEMU_OPTION_bios:
|
|
@@ -3927,17 +3948,12 @@ void qemu_init(int argc, char **argv, char **envp)
|
|
/* add configured firmware directories */
|
|
/* add configured firmware directories */
|
|
dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
|
|
dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0);
|
|
for (i = 0; dirs[i] != NULL; i++) {
|
|
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);
|
|
g_strfreev(dirs);
|
|
|
|
|
|
/* try to find datadir relative to the executable path */
|
|
/* 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. */
|
|
/* -L help lists the data directories and exits. */
|
|
if (list_data_dirs) {
|
|
if (list_data_dirs) {
|