Re: [PATCH 1/2] pc_sysfw: Check for qemu_find_file() failure
Jordan Justen <jljusten <at> gmail.com>
2012-08-16 17:10:14 GMT
Reviewed-by: Jordan Justen <jordan.l.justen <at> intel.com>
On Thu, Aug 16, 2012 at 4:41 AM, Markus Armbruster <armbru <at> redhat.com> wrote:
> pc_fw_add_pflash_drv() ignores qemu_find_file() failure, and happily
> creates a drive without a medium.
>
> When pc_system_flash_init() asks for its size, bdrv_getlength() fails
> with -ENOMEDIUM, which isn't checked either. It fails relatively
> cleanly only because -ENOMEDIUM isn't a multiple of 4096:
>
> $ qemu-system-x86_64 -S -vnc :0 -bios nonexistant
> qemu: PC system firmware (pflash) must be a multiple of 0x1000
> [Exit 1 ]
>
> Fix by handling the qemu_find_file() failure.
>
> Signed-off-by: Markus Armbruster <armbru <at> redhat.com>
> ---
> hw/pc_sysfw.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
> index b45f0ac..fd22154 100644
> --- a/hw/pc_sysfw.c
> +++ b/hw/pc_sysfw.c
> <at> <at> -84,6 +84,11 <at> <at> static void pc_fw_add_pflash_drv(void)
> bios_name = BIOS_FILENAME;
> }
> filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
> + if (!filename) {
(Continue reading)