qemu-e2k/hw/block
Markus Armbruster 06f1521795 pflash: Require backend size to match device, improve errors
We reject undersized backends with a rather enigmatic "failed to read
the initial flash content" error.  For instance:

    $ qemu-system-ppc64 -S -display none -M sam460ex -drive if=pflash,format=raw,file=eins.img
    qemu-system-ppc64: Initialization of device cfi.pflash02 failed: failed to read the initial flash content

We happily accept oversized images, ignoring their tail.  Throwing
away parts of firmware that way is pretty much certain to end in an
even more enigmatic failure to boot.

Require the backend's size to match the device's size exactly.  Report
mismatch like this:

    qemu-system-ppc64: Initialization of device cfi.pflash01 failed: device requires 1048576 bytes, block backend provides 512 bytes

Improve the error for actual read failures to "can't read block
backend".

To avoid duplicating even more code between the two pflash device
models, do all that in new helper blk_check_size_and_read_all().

The error reporting can still be confusing.  For instance:

    qemu-system-ppc64 -S -display none -M taihu -drive if=pflash,format=raw,file=eins.img  -drive if=pflash,unit=1,format=raw,file=zwei.img
    qemu-system-ppc64: Initialization of device cfi.pflash02 failed: device requires 2097152 bytes, block backend provides 512 bytes

Leaves the user guessing which of the two -drive is wrong.  Mention
the issue in a TODO comment.

Suggested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190319163551.32499-2-armbru@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-03-26 08:16:24 +01:00
..
dataplane trace-events: Shorten file names in comments 2019-03-22 16:18:07 +00:00
block.c pflash: Require backend size to match device, improve errors 2019-03-26 08:16:24 +01:00
cdrom.c
ecc.c
fdc.c fdc: fix segfault in fdctrl_stop_transfer() when DMA is disabled 2018-11-19 12:51:22 +01:00
hd-geometry.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
Kconfig isa: express SuperIO dependencies with Kconfig 2019-03-07 21:45:53 +01:00
m25p80.c hw/block: Use the IEC binary prefix definitions 2018-07-02 15:41:13 +02:00
Makefile.objs block: fix recursion in hw/block/dataplane 2019-03-07 21:45:53 +01:00
nand.c
nvme.c nvme: fix write zeroes offset and count 2019-03-12 20:30:14 +01:00
nvme.h qemu/queue.h: leave head structs anonymous unless necessary 2019-01-11 15:46:55 +01:00
onenand.c block/noenand: Convert sysbus init function to realize function 2018-12-13 13:47:57 +00:00
pflash_cfi01.c pflash: Require backend size to match device, improve errors 2019-03-26 08:16:24 +01:00
pflash_cfi02.c pflash: Require backend size to match device, improve errors 2019-03-26 08:16:24 +01:00
tc58128.c hw/block/tc58128.c: Don't use load_image() 2018-12-14 13:30:52 +00:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
vhost-user-blk.c vhost-user-blk: Add support to get/set inflight buffer 2019-03-12 22:31:21 -04:00
virtio-blk.c hw/block/virtio-blk: Clean req->dev repetitions 2019-03-07 17:38:57 +00:00
xen_blkif.h
xen-block.c xen-block: stop leaking memory in xen_block_drive_create() 2019-02-28 17:21:12 +00:00