From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: [PATCH v2 0/2] hw/block/block.c: improve confusing error
Date: Tue, 23 Jan 2024 17:35:29 +0200 [thread overview]
Message-ID: <cover.1706023972.git.manos.pitsidianakis@linaro.org> (raw)
In cases where a device tries to read more bytes than the block device
contains with the blk_check_size_and_read_all() function, the error is
vague: "device requires X bytes, block backend provides Y bytes".
This patch changes the errors of this function to include the block
backend name, the device id and device type name where appropriate.
Version 2:
- Assert dev is not NULL on qdev_get_human_name
(thanks Phil Mathieu-Daudé <philmd@linaro.org>)
Manos Pitsidianakis (2):
hw/core/qdev.c: add qdev_get_human_name()
hw/block/block.c: improve confusing blk_check_size_and_read_all()
error
hw/block/block.c | 25 +++++++++++++++----------
hw/block/m25p80.c | 3 ++-
hw/block/pflash_cfi01.c | 4 ++--
hw/block/pflash_cfi02.c | 2 +-
hw/core/qdev.c | 8 ++++++++
include/hw/block/block.h | 4 ++--
include/hw/qdev-core.h | 14 ++++++++++++++
7 files changed, 44 insertions(+), 16 deletions(-)
Range-diff against v1:
1: 15b15d6d4f ! 1: 5fb5879708 hw/core/qdev.c: add qdev_get_human_name()
@@ hw/core/qdev.c: Object *qdev_get_machine(void)
+char *qdev_get_human_name(DeviceState *dev)
+{
-+ if (!dev) {
-+ return g_strdup("");
-+ }
++ g_assert(dev != NULL);
+
+ return dev->id ?
+ g_strdup(dev->id) : object_get_canonical_path(OBJECT(dev));
@@ include/hw/qdev-core.h: const char *qdev_fw_name(DeviceState *dev);
+/**
+ * qdev_get_human_name() - Return a human-readable name for a device
-+ * @dev: The device
++ * @dev: The device. Must be a valid and non-NULL pointer.
+ *
+ * .. note::
+ * This function is intended for user friendly error messages.
+ *
+ * Returns: A newly allocated string containing the device id if not null,
-+ * else the object canonical path if not null. If @dev is NULL, it returns an
-+ * allocated empty string.
++ * else the object canonical path.
+ *
+ * Use g_free() to free it.
+ */
2: e3701762ed ! 2: 8e7eb17fbd hw/block/block.c: improve confusing blk_check_size_and_read_all() error
@@ Commit message
This patch changes the errors of this function to include the block
backend name, the device id and device type name where appropriate.
+ Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
## hw/block/block.c ##
base-commit: 09be34717190c1620f0c6e5c8765b8da354aeb4b
--
γαῖα πυρί μιχθήτω
next reply other threads:[~2024-01-23 15:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 15:35 Manos Pitsidianakis [this message]
2024-01-23 15:35 ` [PATCH v2 1/2] hw/core/qdev.c: add qdev_get_human_name() Manos Pitsidianakis
2024-01-30 0:02 ` Stefan Hajnoczi
2024-01-23 15:35 ` [PATCH v2 2/2] hw/block/block.c: improve confusing blk_check_size_and_read_all() error Manos Pitsidianakis
2024-01-29 23:58 ` Stefan Hajnoczi
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=cover.1706023972.git.manos.pitsidianakis@linaro.org \
--to=manos.pitsidianakis@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.