[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 13/14] Add a fallback bios file search, if -L fai
From: |
Jason Baron |
Subject: |
[Qemu-devel] [PATCH v4 13/14] Add a fallback bios file search, if -L fails. |
Date: |
Wed, 14 Nov 2012 15:54:09 -0500 |
From: Jason Baron <address@hidden>
If -L <dir> is specified, and qemu does not find the bios file in <dir>, then
the search fails. Add infrastructure such that the search will continue in
the default paths, if not found in the -L path.
Reviewed-by: Paolo Bonzini <address@hidden>
Signed-off-by: Jason Baron <address@hidden>
---
vl.c | 36 +++++++++++++++++++++++++-----------
1 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/vl.c b/vl.c
index 4f03a72..56e0492 100644
--- a/vl.c
+++ b/vl.c
@@ -177,6 +177,7 @@ int main(int argc, char **argv)
#define MAX_VIRTIO_CONSOLES 1
static const char *data_dir;
+static const char *data_dir_fallback;
const char *bios_name = NULL;
enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
DisplayType display_type = DT_DEFAULT;
@@ -2009,16 +2010,16 @@ static int balloon_parse(const char *arg)
return -1;
}
-char *qemu_find_file(int type, const char *name)
+static char *qemu_find_file_in_dir(int type, const char *name, const char *dir)
{
int len;
const char *subdir;
char *buf;
- /* Try the name as a straight path first */
- if (access(name, R_OK) == 0) {
- return g_strdup(name);
+ if (!dir) {
+ return NULL;
}
+
switch (type) {
case QEMU_FILE_TYPE_BIOS:
subdir = "";
@@ -2029,9 +2030,9 @@ char *qemu_find_file(int type, const char *name)
default:
abort();
}
- len = strlen(data_dir) + strlen(name) + strlen(subdir) + 2;
+ len = strlen(dir) + strlen(name) + strlen(subdir) + 2;
buf = g_malloc0(len);
- snprintf(buf, len, "%s/%s%s", data_dir, subdir, name);
+ snprintf(buf, len, "%s/%s%s", dir, subdir, name);
if (access(buf, R_OK)) {
g_free(buf);
return NULL;
@@ -2039,6 +2040,21 @@ char *qemu_find_file(int type, const char *name)
return buf;
}
+char *qemu_find_file(int type, const char *name)
+{
+ char *filename;
+
+ /* Try the name as a straight path first */
+ if (access(name, R_OK) == 0) {
+ return g_strdup(name);
+ }
+ filename = qemu_find_file_in_dir(type, name, data_dir);
+ if (!filename) {
+ filename = qemu_find_file_in_dir(type, name, data_dir_fallback);
+ }
+ return filename;
+}
+
static int device_help_func(QemuOpts *opts, void *opaque)
{
return qdev_device_help(opts);
@@ -3538,12 +3554,10 @@ int main(int argc, char **argv, char **envp)
/* If no data_dir is specified then try to find it relative to the
executable path. */
- if (!data_dir) {
- data_dir = os_find_datadir(argv[0]);
- }
+ data_dir_fallback = os_find_datadir(argv[0]);
/* If all else fails use the install path specified when building. */
- if (!data_dir) {
- data_dir = CONFIG_QEMU_DATADIR;
+ if (!data_dir_fallback) {
+ data_dir_fallback = CONFIG_QEMU_DATADIR;
}
/*
--
1.7.1
- [Qemu-devel] [PATCH v4 05/14] ich9: Add acpi support and definitions, (continued)
- [Qemu-devel] [PATCH v4 05/14] ich9: Add acpi support and definitions, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 06/14] ich9: Add the lpc chip, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 07/14] ich9: Add smbus, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 08/14] q35: Introduce q35 pc based chipset emulator, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 09/14] ich9: Add i82801b11 dmi-to-pci bridge, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 10/14] q35: Suppress SMM BIOS initialization under KVM, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 11/14] q35: Fix non-PCI IRQ processing in ich9_lpc_update_apic, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 12/14] q35: Add kvmclock support, Jason Baron, 2012/11/14
- [Qemu-devel] [PATCH v4 13/14] Add a fallback bios file search, if -L fails.,
Jason Baron <=
- [Qemu-devel] [PATCH v4 14/14] q35: automatically load the q35 dsdt table, Jason Baron, 2012/11/14
- Re: [Qemu-devel] [PATCH v4 00/14] Add Q35 base support, Gerd Hoffmann, 2012/11/22
- Re: [Qemu-devel] [PATCH v4 00/14] Add Q35 base support, Gerd Hoffmann, 2012/11/22