hw/core/loader: allow loading larger ROMs
authorGregor Haas <gregorhaas1997@gmail.com>
Fri, 28 Jun 2024 18:27:06 +0000 (11:27 -0700)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Tue, 16 Jul 2024 17:49:55 +0000 (19:49 +0200)
commitc88d07488c7d9cfdb755d460c63ca80aba323465
tree9b85b8fe92932554a91c310d45f27383219e2d15
parent959269e910944c03bc13f300d65bf08b060d5d0f
hw/core/loader: allow loading larger ROMs

The read() syscall is not guaranteed to return all data from a file. The
default ROM loader implementation currently does not take this into account,
instead failing if all bytes are not read at once. This change loads the ROM
using g_file_get_contents() instead, which correctly reads all data using
multiple calls to read() while also returning the loaded ROM size.

Signed-off-by: Gregor Haas <gregorhaas1997@gmail.com>
Reviewed-by: Xingtao Yao <yaoxt.fnst@fujitsu.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240628182706.99525-1-gregorhaas1997@gmail.com>
[PMD: Use gsize with g_file_get_contents()]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/core/loader.c