* [Qemu-devel] [PATCH] Introduce get_datafile_dir() to replace bios_dir
@ 2009-02-10 7:56 Amit Shah
2009-02-11 20:00 ` [Qemu-devel] " Anthony Liguori
0 siblings, 1 reply; 2+ messages in thread
From: Amit Shah @ 2009-02-10 7:56 UTC (permalink / raw)
To: aliguori; +Cc: Amit Shah, qemu-devel
bios_dir really is $(PREFIX)/share/qemu/ (or the dir. specified by
-L). It currently stores some firmware images and keymaps, so the
name bios_dir is really a misnomer.
Replace it with a helper, get_datafile_dir().
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
qemu/hw/mips_jazz.c | 2 +-
qemu/hw/mips_malta.c | 2 +-
qemu/hw/mips_mipssim.c | 2 +-
qemu/hw/mips_r4k.c | 2 +-
qemu/hw/pc.c | 8 +++++---
qemu/hw/ppc405_boards.c | 4 ++--
qemu/hw/ppc440_bamboo.c | 6 ++++--
qemu/hw/ppc_chrp.c | 4 ++--
qemu/hw/ppc_oldworld.c | 4 ++--
qemu/hw/ppc_prep.c | 2 +-
qemu/hw/sun4m.c | 6 +++---
qemu/hw/sun4u.c | 2 +-
qemu/keymaps.c | 2 +-
qemu/sysemu.h | 2 +-
qemu/vl.c | 19 ++++++++++++++++---
16 files changed, 42 insertions(+), 25 deletions(-)
diff --git a/qemu/hw/mips_jazz.c b/qemu/hw/mips_jazz.c
index 9bdb903..a7e0473 100644
--- a/qemu/hw/mips_jazz.c
+++ b/qemu/hw/mips_jazz.c
@@ -165,7 +165,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size,
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) {
fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n",
diff --git a/qemu/hw/mips_malta.c b/qemu/hw/mips_malta.c
index b7afb2d..554e55f 100644
--- a/qemu/hw/mips_malta.c
+++ b/qemu/hw/mips_malta.c
@@ -850,7 +850,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,
/* Load a BIOS image. */
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
fprintf(stderr,
diff --git a/qemu/hw/mips_mipssim.c b/qemu/hw/mips_mipssim.c
index 3f54900..b1f47cb 100644
--- a/qemu/hw/mips_mipssim.c
+++ b/qemu/hw/mips_mipssim.c
@@ -139,7 +139,7 @@ mips_mipssim_init (ram_addr_t ram_size, int vga_ram_size,
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
/* Bail out if we have neither a kernel image nor boot vector code. */
diff --git a/qemu/hw/mips_r4k.c b/qemu/hw/mips_r4k.c
index ab0c110..80b068b 100644
--- a/qemu/hw/mips_r4k.c
+++ b/qemu/hw/mips_r4k.c
@@ -199,7 +199,7 @@ void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size,
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
cpu_register_physical_memory(0x1fc00000,
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 176730e..00ccc0c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -838,7 +838,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
/* BIOS load */
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = get_image_size(buf);
if (bios_size <= 0 ||
(bios_size % 65536) != 0) {
@@ -855,9 +855,11 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
/* VGA BIOS load */
if (cirrus_vga_enabled) {
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(),
+ VGABIOS_CIRRUS_FILENAME);
} else {
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(),
+ VGABIOS_FILENAME);
}
vga_bios_size = get_image_size(buf);
if (vga_bios_size <= 0 || vga_bios_size > 65536)
diff --git a/qemu/hw/ppc405_boards.c b/qemu/hw/ppc405_boards.c
index 945f095..06e0451 100644
--- a/qemu/hw/ppc405_boards.c
+++ b/qemu/hw/ppc405_boards.c
@@ -238,7 +238,7 @@ static void ref405ep_init (ram_addr_t ram_size, int vga_ram_size,
#endif
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
@@ -550,7 +550,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, int vga_ram_size,
#endif
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
index fbd447c..1c47b20 100644
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -40,10 +40,12 @@ static void *bamboo_load_device_tree(void *addr,
int pathlen;
int ret;
- pathlen = snprintf(NULL, 0, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE) + 1;
+ pathlen = snprintf(NULL, 0, "%s/%s", get_datafile_dir(),
+ BINARY_DEVICE_TREE_FILE) + 1;
path = qemu_malloc(pathlen);
- snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE);
+ snprintf(path, pathlen, "%s/%s", get_datafile_dir(),
+ BINARY_DEVICE_TREE_FILE);
fdt = load_device_tree(path, addr);
free(path);
diff --git a/qemu/hw/ppc_chrp.c b/qemu/hw/ppc_chrp.c
index 1379847..364553b 100644
--- a/qemu/hw/ppc_chrp.c
+++ b/qemu/hw/ppc_chrp.c
@@ -144,7 +144,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
bios_offset = qemu_ram_alloc(BIOS_SIZE);
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
@@ -160,7 +160,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
/* allocate and load VGA BIOS */
vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), VGABIOS_FILENAME);
vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
if (vga_bios_size < 0) {
/* if no bios is present, we can still work */
diff --git a/qemu/hw/ppc_oldworld.c b/qemu/hw/ppc_oldworld.c
index a6dfc35..51d7753 100644
--- a/qemu/hw/ppc_oldworld.c
+++ b/qemu/hw/ppc_oldworld.c
@@ -178,7 +178,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
bios_offset = qemu_ram_alloc(BIOS_SIZE);
if (bios_name == NULL)
bios_name = PROM_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM);
/* Load OpenBIOS (ELF) */
@@ -190,7 +190,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
/* allocate and load VGA BIOS */
vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), VGABIOS_FILENAME);
vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
if (vga_bios_size < 0) {
/* if no bios is present, we can still work */
diff --git a/qemu/hw/ppc_prep.c b/qemu/hw/ppc_prep.c
index b104fc3..2dbc7f0 100644
--- a/qemu/hw/ppc_prep.c
+++ b/qemu/hw/ppc_prep.c
@@ -583,7 +583,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
bios_offset = ram_size + vga_ram_size;
if (bios_name == NULL)
bios_name = BIOS_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
bios_size = load_image(buf, phys_ram_base + bios_offset);
if (bios_size < 0 || bios_size > BIOS_SIZE) {
cpu_abort(env, "qemu: could not load PPC PREP bios '%s'\n", buf);
diff --git a/qemu/hw/sun4m.c b/qemu/hw/sun4m.c
index bae8803..1ca0ea6 100644
--- a/qemu/hw/sun4m.c
+++ b/qemu/hw/sun4m.c
@@ -490,7 +490,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
if (bios_name == NULL)
bios_name = PROM_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
@@ -1286,7 +1286,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
if (bios_name == NULL)
bios_name = PROM_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
@@ -1493,7 +1493,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
if (bios_name == NULL)
bios_name = PROM_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0 || ret > PROM_SIZE_MAX)
ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
diff --git a/qemu/hw/sun4u.c b/qemu/hw/sun4u.c
index 234df7a..e24b912 100644
--- a/qemu/hw/sun4u.c
+++ b/qemu/hw/sun4u.c
@@ -449,7 +449,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
if (bios_name == NULL)
bios_name = PROM_FILENAME;
- snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
+ snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
ret = load_elf(buf, hwdef->prom_addr - PROM_VADDR, NULL, NULL, NULL);
if (ret < 0) {
ret = load_image_targphys(buf, hwdef->prom_addr,
diff --git a/qemu/keymaps.c b/qemu/keymaps.c
index 216e378..a1645ab 100644
--- a/qemu/keymaps.c
+++ b/qemu/keymaps.c
@@ -82,7 +82,7 @@ static kbd_layout_t *parse_keyboard_layout(const char *language,
int len;
snprintf(file_name, sizeof(file_name),
- "%s/keymaps/%s", bios_dir, language);
+ "%s/keymaps/%s", get_datafile_dir(), language);
if (!k)
k = qemu_mallocz(sizeof(kbd_layout_t));
diff --git a/qemu/sysemu.h b/qemu/sysemu.h
index bc6d5af..7661fb2 100644
--- a/qemu/sysemu.h
+++ b/qemu/sysemu.h
@@ -4,7 +4,7 @@
/* vl.c */
extern const char *bios_name;
-extern const char *bios_dir;
+extern char *get_datafile_dir(void);
extern int vm_running;
extern const char *qemu_name;
diff --git a/qemu/vl.c b/qemu/vl.c
index aff2b2c..6d41014 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -172,7 +172,7 @@
/* XXX: use a two level table to limit memory usage */
#define MAX_IOPORTS 65536
-const char *bios_dir = CONFIG_QEMU_SHAREDIR;
+static char datafile_dir[512];
const char *bios_name = NULL;
static void *ioport_opaque[MAX_IOPORTS];
static IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
@@ -4529,6 +4529,17 @@ static void termsig_setup(void)
#endif
+static void set_datafile_dir(const char *dir)
+{
+ strncpy(datafile_dir, dir, sizeof(datafile_dir) - 1);
+ datafile_dir[sizeof(datafile_dir) - 1] = 0;
+}
+
+char *get_datafile_dir(void)
+{
+ return datafile_dir;
+}
+
int main(int argc, char **argv, char **envp)
{
#ifdef CONFIG_GDBSTUB
@@ -4603,6 +4614,7 @@ int main(int argc, char **argv, char **envp)
}
#endif
+ set_datafile_dir(CONFIG_QEMU_SHAREDIR);
register_machines();
machine = first_machine;
cpu_model = NULL;
@@ -4953,7 +4965,7 @@ int main(int argc, char **argv, char **envp)
break;
#endif
case QEMU_OPTION_L:
- bios_dir = optarg;
+ set_datafile_dir(optarg);
break;
case QEMU_OPTION_bios:
bios_name = optarg;
@@ -5373,7 +5385,8 @@ int main(int argc, char **argv, char **envp)
if (net_boot & (1 << i)) {
if (model == NULL)
model = "ne2k_pci";
- snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", bios_dir, model);
+ snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", get_datafile_dir(),
+ model);
if (get_image_size(buf) > 0) {
if (nb_option_roms >= MAX_OPTION_ROMS) {
fprintf(stderr, "Too many option ROMs\n");
--
1.6.0.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Qemu-devel] Re: [PATCH] Introduce get_datafile_dir() to replace bios_dir
2009-02-10 7:56 [Qemu-devel] [PATCH] Introduce get_datafile_dir() to replace bios_dir Amit Shah
@ 2009-02-11 20:00 ` Anthony Liguori
0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2009-02-11 20:00 UTC (permalink / raw)
To: Amit Shah; +Cc: qemu-devel
Amit Shah wrote:
> bios_dir really is $(PREFIX)/share/qemu/ (or the dir. specified by
> -L). It currently stores some firmware images and keymaps, so the
> name bios_dir is really a misnomer.
>
> Replace it with a helper, get_datafile_dir().
>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>
> ---
> qemu/hw/mips_jazz.c | 2 +-
> qemu/hw/mips_malta.c | 2 +-
> qemu/hw/mips_mipssim.c | 2 +-
> qemu/hw/mips_r4k.c | 2 +-
> qemu/hw/pc.c | 8 +++++---
> qemu/hw/ppc405_boards.c | 4 ++--
> qemu/hw/ppc440_bamboo.c | 6 ++++--
> qemu/hw/ppc_chrp.c | 4 ++--
> qemu/hw/ppc_oldworld.c | 4 ++--
> qemu/hw/ppc_prep.c | 2 +-
> qemu/hw/sun4m.c | 6 +++---
> qemu/hw/sun4u.c | 2 +-
> qemu/keymaps.c | 2 +-
> qemu/sysemu.h | 2 +-
> qemu/vl.c | 19 ++++++++++++++++---
> 16 files changed, 42 insertions(+), 25 deletions(-)
>
> diff --git a/qemu/hw/mips_jazz.c b/qemu/hw/mips_jazz.c
>
Please submit patches against QEMU SVN, not kvm-userspace.
Regards,
Anthony Liguori
> index 9bdb903..a7e0473 100644
> --- a/qemu/hw/mips_jazz.c
> +++ b/qemu/hw/mips_jazz.c
> @@ -165,7 +165,7 @@ void mips_jazz_init (ram_addr_t ram_size, int vga_ram_size,
> bios_offset = ram_size + vga_ram_size;
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if (bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) {
> fprintf(stderr, "qemu: Could not load MIPS bios '%s'\n",
> diff --git a/qemu/hw/mips_malta.c b/qemu/hw/mips_malta.c
> index b7afb2d..554e55f 100644
> --- a/qemu/hw/mips_malta.c
> +++ b/qemu/hw/mips_malta.c
> @@ -850,7 +850,7 @@ void mips_malta_init (ram_addr_t ram_size, int vga_ram_size,
> /* Load a BIOS image. */
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
> fprintf(stderr,
> diff --git a/qemu/hw/mips_mipssim.c b/qemu/hw/mips_mipssim.c
> index 3f54900..b1f47cb 100644
> --- a/qemu/hw/mips_mipssim.c
> +++ b/qemu/hw/mips_mipssim.c
> @@ -139,7 +139,7 @@ mips_mipssim_init (ram_addr_t ram_size, int vga_ram_size,
> bios_offset = ram_size + vga_ram_size;
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if ((bios_size < 0 || bios_size > BIOS_SIZE) && !kernel_filename) {
> /* Bail out if we have neither a kernel image nor boot vector code. */
> diff --git a/qemu/hw/mips_r4k.c b/qemu/hw/mips_r4k.c
> index ab0c110..80b068b 100644
> --- a/qemu/hw/mips_r4k.c
> +++ b/qemu/hw/mips_r4k.c
> @@ -199,7 +199,7 @@ void mips_r4k_init (ram_addr_t ram_size, int vga_ram_size,
> bios_offset = ram_size + vga_ram_size;
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
> cpu_register_physical_memory(0x1fc00000,
> diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
> index 176730e..00ccc0c 100644
> --- a/qemu/hw/pc.c
> +++ b/qemu/hw/pc.c
> @@ -838,7 +838,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
> /* BIOS load */
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = get_image_size(buf);
> if (bios_size <= 0 ||
> (bios_size % 65536) != 0) {
> @@ -855,9 +855,11 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
> if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
> /* VGA BIOS load */
> if (cirrus_vga_enabled) {
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(),
> + VGABIOS_CIRRUS_FILENAME);
> } else {
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(),
> + VGABIOS_FILENAME);
> }
> vga_bios_size = get_image_size(buf);
> if (vga_bios_size <= 0 || vga_bios_size > 65536)
> diff --git a/qemu/hw/ppc405_boards.c b/qemu/hw/ppc405_boards.c
> index 945f095..06e0451 100644
> --- a/qemu/hw/ppc405_boards.c
> +++ b/qemu/hw/ppc405_boards.c
> @@ -238,7 +238,7 @@ static void ref405ep_init (ram_addr_t ram_size, int vga_ram_size,
> #endif
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if (bios_size < 0 || bios_size > BIOS_SIZE) {
> fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
> @@ -550,7 +550,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, int vga_ram_size,
> #endif
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if (bios_size < 0 || bios_size > BIOS_SIZE) {
> fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
> diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
> index fbd447c..1c47b20 100644
> --- a/qemu/hw/ppc440_bamboo.c
> +++ b/qemu/hw/ppc440_bamboo.c
> @@ -40,10 +40,12 @@ static void *bamboo_load_device_tree(void *addr,
> int pathlen;
> int ret;
>
> - pathlen = snprintf(NULL, 0, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE) + 1;
> + pathlen = snprintf(NULL, 0, "%s/%s", get_datafile_dir(),
> + BINARY_DEVICE_TREE_FILE) + 1;
> path = qemu_malloc(pathlen);
>
> - snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE);
> + snprintf(path, pathlen, "%s/%s", get_datafile_dir(),
> + BINARY_DEVICE_TREE_FILE);
>
> fdt = load_device_tree(path, addr);
> free(path);
> diff --git a/qemu/hw/ppc_chrp.c b/qemu/hw/ppc_chrp.c
> index 1379847..364553b 100644
> --- a/qemu/hw/ppc_chrp.c
> +++ b/qemu/hw/ppc_chrp.c
> @@ -144,7 +144,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
> bios_offset = qemu_ram_alloc(BIOS_SIZE);
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if (bios_size < 0 || bios_size > BIOS_SIZE) {
> cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
> @@ -160,7 +160,7 @@ static void ppc_core99_init (ram_addr_t ram_size, int vga_ram_size,
>
> /* allocate and load VGA BIOS */
> vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), VGABIOS_FILENAME);
> vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
> if (vga_bios_size < 0) {
> /* if no bios is present, we can still work */
> diff --git a/qemu/hw/ppc_oldworld.c b/qemu/hw/ppc_oldworld.c
> index a6dfc35..51d7753 100644
> --- a/qemu/hw/ppc_oldworld.c
> +++ b/qemu/hw/ppc_oldworld.c
> @@ -178,7 +178,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
> bios_offset = qemu_ram_alloc(BIOS_SIZE);
> if (bios_name == NULL)
> bios_name = PROM_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> cpu_register_physical_memory(PROM_ADDR, BIOS_SIZE, bios_offset | IO_MEM_ROM);
>
> /* Load OpenBIOS (ELF) */
> @@ -190,7 +190,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, int vga_ram_size,
>
> /* allocate and load VGA BIOS */
> vga_bios_offset = qemu_ram_alloc(VGA_BIOS_SIZE);
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), VGABIOS_FILENAME);
> vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8);
> if (vga_bios_size < 0) {
> /* if no bios is present, we can still work */
> diff --git a/qemu/hw/ppc_prep.c b/qemu/hw/ppc_prep.c
> index b104fc3..2dbc7f0 100644
> --- a/qemu/hw/ppc_prep.c
> +++ b/qemu/hw/ppc_prep.c
> @@ -583,7 +583,7 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,
> bios_offset = ram_size + vga_ram_size;
> if (bios_name == NULL)
> bios_name = BIOS_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> bios_size = load_image(buf, phys_ram_base + bios_offset);
> if (bios_size < 0 || bios_size > BIOS_SIZE) {
> cpu_abort(env, "qemu: could not load PPC PREP bios '%s'\n", buf);
> diff --git a/qemu/hw/sun4m.c b/qemu/hw/sun4m.c
> index bae8803..1ca0ea6 100644
> --- a/qemu/hw/sun4m.c
> +++ b/qemu/hw/sun4m.c
> @@ -490,7 +490,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, ram_addr_t RAM_size,
>
> if (bios_name == NULL)
> bios_name = PROM_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
> if (ret < 0 || ret > PROM_SIZE_MAX)
> ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
> @@ -1286,7 +1286,7 @@ static void sun4d_hw_init(const struct sun4d_hwdef *hwdef, ram_addr_t RAM_size,
>
> if (bios_name == NULL)
> bios_name = PROM_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
> if (ret < 0 || ret > PROM_SIZE_MAX)
> ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
> @@ -1493,7 +1493,7 @@ static void sun4c_hw_init(const struct sun4c_hwdef *hwdef, ram_addr_t RAM_size,
>
> if (bios_name == NULL)
> bios_name = PROM_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> ret = load_elf(buf, hwdef->slavio_base - PROM_VADDR, NULL, NULL, NULL);
> if (ret < 0 || ret > PROM_SIZE_MAX)
> ret = load_image_targphys(buf, hwdef->slavio_base, PROM_SIZE_MAX);
> diff --git a/qemu/hw/sun4u.c b/qemu/hw/sun4u.c
> index 234df7a..e24b912 100644
> --- a/qemu/hw/sun4u.c
> +++ b/qemu/hw/sun4u.c
> @@ -449,7 +449,7 @@ static void sun4uv_init(ram_addr_t RAM_size, int vga_ram_size,
>
> if (bios_name == NULL)
> bios_name = PROM_FILENAME;
> - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
> + snprintf(buf, sizeof(buf), "%s/%s", get_datafile_dir(), bios_name);
> ret = load_elf(buf, hwdef->prom_addr - PROM_VADDR, NULL, NULL, NULL);
> if (ret < 0) {
> ret = load_image_targphys(buf, hwdef->prom_addr,
> diff --git a/qemu/keymaps.c b/qemu/keymaps.c
> index 216e378..a1645ab 100644
> --- a/qemu/keymaps.c
> +++ b/qemu/keymaps.c
> @@ -82,7 +82,7 @@ static kbd_layout_t *parse_keyboard_layout(const char *language,
> int len;
>
> snprintf(file_name, sizeof(file_name),
> - "%s/keymaps/%s", bios_dir, language);
> + "%s/keymaps/%s", get_datafile_dir(), language);
>
> if (!k)
> k = qemu_mallocz(sizeof(kbd_layout_t));
> diff --git a/qemu/sysemu.h b/qemu/sysemu.h
> index bc6d5af..7661fb2 100644
> --- a/qemu/sysemu.h
> +++ b/qemu/sysemu.h
> @@ -4,7 +4,7 @@
>
> /* vl.c */
> extern const char *bios_name;
> -extern const char *bios_dir;
> +extern char *get_datafile_dir(void);
>
> extern int vm_running;
> extern const char *qemu_name;
> diff --git a/qemu/vl.c b/qemu/vl.c
> index aff2b2c..6d41014 100644
> --- a/qemu/vl.c
> +++ b/qemu/vl.c
> @@ -172,7 +172,7 @@
> /* XXX: use a two level table to limit memory usage */
> #define MAX_IOPORTS 65536
>
> -const char *bios_dir = CONFIG_QEMU_SHAREDIR;
> +static char datafile_dir[512];
> const char *bios_name = NULL;
> static void *ioport_opaque[MAX_IOPORTS];
> static IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
> @@ -4529,6 +4529,17 @@ static void termsig_setup(void)
>
> #endif
>
> +static void set_datafile_dir(const char *dir)
> +{
> + strncpy(datafile_dir, dir, sizeof(datafile_dir) - 1);
> + datafile_dir[sizeof(datafile_dir) - 1] = 0;
> +}
> +
> +char *get_datafile_dir(void)
> +{
> + return datafile_dir;
> +}
> +
> int main(int argc, char **argv, char **envp)
> {
> #ifdef CONFIG_GDBSTUB
> @@ -4603,6 +4614,7 @@ int main(int argc, char **argv, char **envp)
> }
> #endif
>
> + set_datafile_dir(CONFIG_QEMU_SHAREDIR);
> register_machines();
> machine = first_machine;
> cpu_model = NULL;
> @@ -4953,7 +4965,7 @@ int main(int argc, char **argv, char **envp)
> break;
> #endif
> case QEMU_OPTION_L:
> - bios_dir = optarg;
> + set_datafile_dir(optarg);
> break;
> case QEMU_OPTION_bios:
> bios_name = optarg;
> @@ -5373,7 +5385,8 @@ int main(int argc, char **argv, char **envp)
> if (net_boot & (1 << i)) {
> if (model == NULL)
> model = "ne2k_pci";
> - snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", bios_dir, model);
> + snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", get_datafile_dir(),
> + model);
> if (get_image_size(buf) > 0) {
> if (nb_option_roms >= MAX_OPTION_ROMS) {
> fprintf(stderr, "Too many option ROMs\n");
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-11 20:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-10 7:56 [Qemu-devel] [PATCH] Introduce get_datafile_dir() to replace bios_dir Amit Shah
2009-02-11 20:00 ` [Qemu-devel] " Anthony Liguori
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).