From: David Edmondson <david.edmondson@oracle.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
Max Reitz <mreitz@redhat.com>,
David Edmondson <david.edmondson@oracle.com>,
Shannon Zhao <shannon.zhaosl@gmail.com>,
qemu-arm@nongnu.org, Igor Mammedov <imammedo@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: [RFC PATCH 1/5] hw/block: blk_check_size_and_read_all should report backend name
Date: Mon, 16 Nov 2020 10:42:12 +0000 [thread overview]
Message-ID: <20201116104216.439650-2-david.edmondson@oracle.com> (raw)
In-Reply-To: <20201116104216.439650-1-david.edmondson@oracle.com>
If there are problems examining or reading data from the block
backend, the error messages should include an appropriate identifier
to assist in diagnoses.
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
hw/block/block.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/block/block.c b/hw/block/block.c
index 1e34573da7..8b284e1f14 100644
--- a/hw/block/block.c
+++ b/hw/block/block.c
@@ -20,9 +20,6 @@
* BDRV_REQUEST_MAX_BYTES.
* On success, return true.
* On failure, store an error through @errp and return false.
- * Note that the error messages do not identify the block backend.
- * TODO Since callers don't either, this can result in confusing
- * errors.
* This function not intended for actual block devices, which read on
* demand. It's for things like memory devices that (ab)use a block
* backend to provide persistence.
@@ -32,17 +29,19 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
{
int64_t blk_len;
int ret;
+ const char *name = blk_name(blk);
blk_len = blk_getlength(blk);
if (blk_len < 0) {
error_setg_errno(errp, -blk_len,
- "can't get size of block backend");
+ "can't get size of block backend %s",
+ name);
return false;
}
if (blk_len != size) {
error_setg(errp, "device requires %" HWADDR_PRIu " bytes, "
- "block backend provides %" PRIu64 " bytes",
- size, blk_len);
+ "block backend %s provides %" PRIu64 " bytes",
+ size, name, blk_len);
return false;
}
@@ -55,7 +54,8 @@ bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
assert(size <= BDRV_REQUEST_MAX_BYTES);
ret = blk_pread(blk, 0, buf, size);
if (ret < 0) {
- error_setg_errno(errp, -ret, "can't read block backend");
+ error_setg_errno(errp, -ret, "can't read block backend %s",
+ name);
return false;
}
return true;
--
2.28.0
next prev parent reply other threads:[~2020-11-16 10:45 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-16 10:42 [RFC PATCH 0/5] ARM: reduce the memory consumed when mapping UEFI flash images David Edmondson
2020-11-16 10:42 ` David Edmondson [this message]
2020-11-16 11:23 ` [RFC PATCH 1/5] hw/block: blk_check_size_and_read_all should report backend name Philippe Mathieu-Daudé
2020-11-16 13:29 ` David Edmondson
2020-11-19 11:56 ` Alex Bennée
2020-11-16 10:42 ` [RFC PATCH 2/5] hw/block: Flash images can be smaller than the device David Edmondson
2020-11-16 10:42 ` [RFC PATCH 3/5] hw/arm: Convert assertions about flash image size to error_report David Edmondson
2020-11-19 11:39 ` Alex Bennée
2020-11-16 10:42 ` [RFC PATCH 4/5] hw/arm: Flash image mapping follows image size David Edmondson
2020-11-16 10:42 ` [RFC PATCH 5/5] hw/arm: Only minimise flash size on older machines David Edmondson
2020-11-16 11:39 ` [RFC PATCH 0/5] ARM: reduce the memory consumed when mapping UEFI flash images Philippe Mathieu-Daudé
2020-11-16 13:43 ` David Edmondson
2020-11-16 13:48 ` Markus Armbruster
2020-11-19 6:09 ` Philippe Mathieu-Daudé
2020-11-19 11:45 ` Alex Bennée
2020-11-19 11:57 ` Philippe Mathieu-Daudé
2020-12-07 12:07 ` David Edmondson
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=20201116104216.439650-2-david.edmondson@oracle.com \
--to=david.edmondson@oracle.com \
--cc=imammedo@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).