From: Markus Armbruster <armbru@redhat.com>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: "Alistair Francis" <alistair@alistair23.me>,
"Francisco Iglesias" <frasse.iglesias@gmail.com>,
"Kevin Wolf" <kwolf@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Peter Delevoryas" <peter@pjd.dev>,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] m25p80: Improve error when the backend file size does not match the device
Date: Wed, 16 Nov 2022 07:56:07 +0100 [thread overview]
Message-ID: <87edu3o0ag.fsf@pond.sub.org> (raw)
In-Reply-To: <20221115151000.2080833-1-clg@kaod.org> ("Cédric Le Goater"'s message of "Tue, 15 Nov 2022 16:10:00 +0100")
Cédric Le Goater <clg@kaod.org> writes:
> Currently, when a block backend is attached to a m25p80 device and the
> associated file size does not match the flash model, QEMU complains
> with the error message "failed to read the initial flash content".
> This is confusing for the user.
>
> Use blk_check_size_and_read_all() instead of blk_pread() to improve
> the reported error.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/block/m25p80.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
> index 02adc87527..68a757abf3 100644
> --- a/hw/block/m25p80.c
> +++ b/hw/block/m25p80.c
> @@ -24,6 +24,7 @@
> #include "qemu/osdep.h"
> #include "qemu/units.h"
> #include "sysemu/block-backend.h"
> +#include "hw/block/block.h"
> #include "hw/qdev-properties.h"
> #include "hw/qdev-properties-system.h"
> #include "hw/ssi/ssi.h"
> @@ -1614,8 +1615,7 @@ static void m25p80_realize(SSIPeripheral *ss, Error **errp)
> trace_m25p80_binding(s);
> s->storage = blk_blockalign(s->blk, s->size);
>
> - if (blk_pread(s->blk, 0, s->size, s->storage, 0) < 0) {
> - error_setg(errp, "failed to read the initial flash content");
> + if (!blk_check_size_and_read_all(s->blk, s->storage, s->size, errp)) {
> return;
> }
> } else {
Ignorant question: what does blk_pread() on short read? Does it fail?
Or does it succeed, returning how much it read? I tried to find an
answer in function comments, no luck.
Are there more instances of "we fill some fixed-size memory (such as a
ROM or flash) from a block backend?"
next prev parent reply other threads:[~2022-11-16 6:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 15:10 [PATCH v2] m25p80: Improve error when the backend file size does not match the device Cédric Le Goater
2022-11-15 15:30 ` Peter Maydell
2022-11-15 15:50 ` Philippe Mathieu-Daudé
2022-11-15 20:08 ` Peter Delevoryas
2022-11-16 1:58 ` Alistair Francis
2022-11-16 6:56 ` Markus Armbruster [this message]
2022-11-16 7:12 ` Cédric Le Goater
2022-11-16 8:28 ` Markus Armbruster
2022-11-16 8:38 ` Cédric Le Goater
2022-11-16 11:16 ` Francisco Iglesias
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87edu3o0ag.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=alistair@alistair23.me \
--cc=clg@kaod.org \
--cc=frasse.iglesias@gmail.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peter@pjd.dev \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.