From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: xieyongji@bytedance.com, kwolf@redhat.com, hreitz@redhat.com,
Coiby.Xu@gmail.com, pbonzini@redhat.com, berrange@redhat.com,
eduardo@habkost.net, mark.cave-ayland@ilande.co.uk,
michael.roth@amd.com, kkostiuk@redhat.com, qemu-block@nongnu.org,
philmd@linaro.org
Subject: [PATCH v2 2/7] block: Improve errors about block sizes
Date: Thu, 10 Oct 2024 17:01:39 +0200 [thread overview]
Message-ID: <20241010150144.986655-3-armbru@redhat.com> (raw)
In-Reply-To: <20241010150144.986655-1-armbru@redhat.com>
Block sizes need to be a power of two between 512 and an arbitrary
limit, currently 2MiB.
Commit 5937835ac4c factored block size checking out of set_blocksize()
into new check_block_size(), for reuse in block/export/.
Its two error messages are okay for the original purpose:
$ qemu-system-x86_64 -device ide-hd,physical_block_size=1
qemu-system-x86_64: -device ide-hd,physical_block_size=1: Property .physical_block_size doesn't take value 1 (minimum: 512, maximum: 2097152)
$ qemu-system-x86_64 -device ide-hd,physical_block_size=513
qemu-system-x86_64: -device ide-hd,physical_block_size=513: Property .physical_block_size doesn't take value '513', it's not a power of 2
They're mildly off for block exports:
$ qemu-storage-daemon --blockdev node-name=nod0,driver=file,filename=foo.img --export type=vduse-blk,id=exp0,node-name=nod0,name=foo,logical-block-size=1
qemu-storage-daemon: --export type=vduse-blk,id=exp0,node-name=nod0,name=foo,logical-block-size=1: Property exp0.logical-block-size doesn't take value 1 (minimum: 512, maximum: 2097152)
The error message talks about a property. CLI options like --export
don't have properties, they have parameters.
Replace the two error messages by a single one that's okay for both
purposes. Looks like this:
qemu-storage-daemon: --export type=vduse-blk,id=exp0,node-name=nod0,name=foo,logical-block-size=1: parameter logical-block-size must be a power of 2 between 512 and 2097152
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
util/block-helpers.c | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/util/block-helpers.c b/util/block-helpers.c
index c4851432f5..fb5de348e2 100644
--- a/util/block-helpers.c
+++ b/util/block-helpers.c
@@ -10,7 +10,6 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
-#include "qapi/qmp/qerror.h"
#include "block-helpers.h"
/**
@@ -28,19 +27,16 @@
void check_block_size(const char *id, const char *name, int64_t value,
Error **errp)
{
- /* value of 0 means "unset" */
- if (value && (value < MIN_BLOCK_SIZE || value > MAX_BLOCK_SIZE)) {
- error_setg(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
- id, name, value, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE);
+ if (!value) {
+ /* unset */
return;
}
- /* We rely on power-of-2 blocksizes for bitmasks */
- if ((value & (value - 1)) != 0) {
+ if (value < MIN_BLOCK_SIZE || value > MAX_BLOCK_SIZE
+ || (value & (value - 1))) {
error_setg(errp,
- "Property %s.%s doesn't take value '%" PRId64
- "', it's not a power of 2",
- id, name, value);
- return;
+ "parameter %s must be a power of 2 between %" PRId64
+ " and %" PRId64,
+ name, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE);
}
}
--
2.46.0
next prev parent reply other threads:[~2024-10-10 15:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 15:01 [PATCH v2 0/7] error: Eliminate QERR_PROPERTY_VALUE_OUT_OF_RANGE Markus Armbruster
2024-10-10 15:01 ` [PATCH v2 1/7] error: Drop superfluous #include "qapi/qmp/qerror.h" Markus Armbruster
2024-10-10 15:01 ` Markus Armbruster [this message]
2024-10-10 15:01 ` [PATCH v2 3/7] block: Adjust check_block_size() signature Markus Armbruster
2024-10-10 16:38 ` Philippe Mathieu-Daudé
2024-10-10 15:01 ` [PATCH v2 4/7] target/i386/cpu: Avoid mixing signed and unsigned in property setters Markus Armbruster
2024-10-11 12:23 ` Igor Mammedov
2024-10-10 15:01 ` [PATCH v2 5/7] target/i386/cpu: Improve errors for out of bounds property values Markus Armbruster
2024-10-10 17:38 ` Philippe Mathieu-Daudé
2024-10-10 19:25 ` Markus Armbruster
2024-10-11 15:11 ` Philippe Mathieu-Daudé
2024-10-15 4:45 ` Markus Armbruster
2024-10-11 12:24 ` Igor Mammedov
2024-10-10 15:01 ` [PATCH v2 6/7] hw/intc/openpic: " Markus Armbruster
2024-10-10 17:40 ` Philippe Mathieu-Daudé
2024-10-17 6:21 ` Markus Armbruster
2024-10-10 15:01 ` [PATCH v2 7/7] qerror: QERR_PROPERTY_VALUE_OUT_OF_RANGE is no longer used, drop Markus Armbruster
2024-10-10 17:41 ` Philippe Mathieu-Daudé
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=20241010150144.986655-3-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=Coiby.Xu@gmail.com \
--cc=berrange@redhat.com \
--cc=eduardo@habkost.net \
--cc=hreitz@redhat.com \
--cc=kkostiuk@redhat.com \
--cc=kwolf@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=xieyongji@bytedance.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).