riscv: Fix "-L" not working for bios image search path
cover riscv: Fix "-L" not working for bios image search path
Currently when QEMU is given a bios image with only a file name and its file path passed in "-L", it still reports file not found.
This series fixes the issue. This is especially helpful for creating distro QEMU packages.
Bin Meng (2):
riscv: Add a helper routine for finding firmware
riscv: Resolve full path of the given bios image
hw/riscv/boot.c | 26 +++++++++++++++++--------- include/hw/riscv/boot.h | 1 + 2 files changed, 18 insertions(+), 9 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/2 riscv: Add a helper routine for finding firmware
This adds a helper routine for finding firmware. It is currently used only for "-bios default" case.
---
hw/riscv/boot.c | 22 +++++++++++++++------- include/hw/riscv/boot.h | 1 + 2 files changed, 16 insertions(+), 7 deletions(-)
hw/riscv/boot.c +15 -7
@@ -69,13 +69,7 @@ void riscv_find_and_load_firmware(MachineState *machine,* so then in the future we can make "-bios default" the default option * if no -bios option is set without breaking anything. */ - firmware_filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , - default_machine_firmware); -if (firmware_filename ==NULL ) { -error_report ("Unable to load the default RISC-V firmware \"%s\"" , - default_machine_firmware); -exit (1 ); - } + firmware_filename =riscv_find_firmware (default_machine_firmware); }else { firmware_filename = machine->firmware; }
@@ -90,6 +84,20 @@ void riscv_find_and_load_firmware(MachineState *machine, } } +char *riscv_find_firmware (const char *firmware_filename) +{ +char *filename; + + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , firmware_filename); +if (filename ==NULL ) { +error_report ("Unable to load the RISC-V firmware \"%s\"" , + firmware_filename); +exit (1 ); + } + +return filename; +} +target_ulong riscv_load_firmware (const char *firmware_filename,hwaddr firmware_load_addr) {
include/hw/riscv/boot.h +1 -0
@@ -23,6 +23,7 @@void riscv_find_and_load_firmware (MachineState *machine,const char *default_machine_firmware,hwaddr firmware_load_addr); +char *riscv_find_firmware (const char *firmware_filename);target_ulong riscv_load_firmware (const char *firmware_filename,hwaddr firmware_load_addr);target_ulong riscv_load_kernel (const char *kernel_filename);
Signature · 1 line
2.7.4
PATCH 2/2 riscv: Resolve full path of the given bios image
In reply to Bin MengAt present when "-bios image" is supplied, we just use the straight path without searching for the configured data directories. Like "-bios default", we add the same logic so that "-L" actually works.
---
hw/riscv/boot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/riscv/boot.c +3 -3
@@ -72,14 +72,14 @@ void riscv_find_and_load_firmware(MachineState *machine, firmware_filename =riscv_find_firmware (default_machine_firmware); }else { firmware_filename = machine->firmware; +if (strcmp (firmware_filename,"none" )) { + firmware_filename =riscv_find_firmware (firmware_filename); + } }if (strcmp (firmware_filename,"none" )) {/* If not "none" load the firmware */ riscv_load_firmware (firmware_filename, firmware_load_addr); - } - -if (!strcmp (machine->firmware,"default" )) {g_free (firmware_filename); } }
Signature · 1 line
2.7.4
Re: [Qemu-devel] [PATCH 2/2] riscv: Resolve full path of the given bios image
Quoted 6 lines · Bin Meng
At present when "-bios image" is supplied, we just use the straight path without searching for the configured data directories. Like "-bios default", we add the same logic so that "-L" actually works.
Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 32 lines
---
hw/riscv/boot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/riscv/boot.c +3
-4@@ -72,14 +72,14 @@ void riscv_find_and_load_firmware(MachineState *machine, firmware_filename =riscv_find_firmware (default_machine_firmware); }else { firmware_filename = machine->firmware; +if (strcmp (firmware_filename,"none" )) { + firmware_filename =riscv_find_firmware (firmware_filename); + } }if (strcmp (firmware_filename,"none" )) {/* If not "none" load the firmware */ riscv_load_firmware (firmware_filename, firmware_load_addr); - } - -if (!strcmp (machine->firmware,"default" )) {g_free (firmware_filename); } } --2.7.4
Quoted 7 lines · On Fri, 16 Aug 2019 06:09:34 PDT (-0700), [email protected] wrote:
Currently when QEMU is given a bios image with only a file name and its file path passed in "-L", it still reports file not found.
This series fixes the issue. This is especially helpful for creating distro QEMU packages.
Quoted 7 lines
Bin Meng (2):
riscv: Add a helper routine for finding firmware
riscv: Resolve full path of the given bios imagehw/riscv/boot.c | 26 +++++++++++++++++--------- include/hw/riscv/boot.h | 1 + 2 files changed, 18 insertions(+), 9 deletions(-)
Thanks, I've put these two in the patch queue with Alistair's review.