From: Kit Westneat <kit.westneat@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, Kit Westneat <kit.westneat@gmail.com>
Subject: [PATCH 3/3] block/blkdebug: add log-blocksize and phys-blocksize parameters
Date: Tue, 25 May 2021 12:47:53 +0000 [thread overview]
Message-ID: <20210525124753.528516-4-kit.westneat@gmail.com> (raw)
In-Reply-To: <20210525124753.528516-1-kit.westneat@gmail.com>
Allow users to specify the logical and physical block sizes of the
qdev for testing purposes.
Signed-off-by: Kit Westneat <kit.westneat@gmail.com>
---
block/blkdebug.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/block/blkdebug.c b/block/blkdebug.c
index c7500746a8..e5cfdab32b 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -48,6 +48,8 @@ typedef struct BDRVBlkdebugState {
uint64_t opt_discard;
uint64_t max_discard;
uint64_t blocksize;
+ uint64_t phys_blocksize;
+ uint64_t log_blocksize;
uint64_t take_child_perms;
uint64_t unshare_child_perms;
@@ -459,7 +461,17 @@ static QemuOptsList runtime_opts = {
{
.name = "blocksize",
.type = QEMU_OPT_SIZE,
- .help = "Blocksize of device",
+ .help = "Blocksize of device (512 default)",
+ },
+ {
+ .name = "phys-blocksize",
+ .type = QEMU_OPT_SIZE,
+ .help = "Physical blocksize of device (Defaults to 'blocksize')",
+ },
+ {
+ .name = "log-blocksize",
+ .type = QEMU_OPT_SIZE,
+ .help = "Logical blocksize of device (Defaults to 'blocksize')",
},
{ /* end of list */ }
},
@@ -575,6 +587,20 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
goto out;
}
+ s->phys_blocksize = qemu_opt_get_size(opts, "phys-blocksize", 0);
+ if (s->phys_blocksize && (s->phys_blocksize >= INT_MAX || !is_power_of_2(s->phys_blocksize))) {
+ error_setg(errp, "Cannot meet constraints with phys-blocksize %" PRIu64,
+ s->phys_blocksize);
+ goto out;
+ }
+
+ s->log_blocksize = qemu_opt_get_size(opts, "log-blocksize", 0);
+ if (s->log_blocksize && (s->log_blocksize >= INT_MAX || !is_power_of_2(s->log_blocksize))) {
+ error_setg(errp, "Cannot meet constraints with log-blocksize %" PRIu64,
+ s->log_blocksize);
+ goto out;
+ }
+
bdrv_debug_event(bs, BLKDBG_NONE);
ret = 0;
@@ -1001,11 +1027,9 @@ static int blkdebug_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz)
{
BDRVBlkdebugState *s = bs->opaque;
- if (!s->blocksize)
- return 0;
+ bsz->phys = s->phys_blocksize ? s->phys_blocksize : s->blocksize;
+ bsz->log = s->log_blocksize ? s->log_blocksize : s->blocksize;
- bsz->phys = s->blocksize;
- bsz->log = s->blocksize;
return 0;
}
@@ -1036,6 +1060,8 @@ static const char *const blkdebug_strong_runtime_opts[] = {
"set-state.",
"align",
"blocksize",
+ "phys-blocksize",
+ "log-blocksize",
"max-transfer",
"opt-write-zero",
"max-write-zero",
--
2.26.3
next prev parent reply other threads:[~2021-05-25 12:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 12:47 [PATCH 0/3] testing block device blocksizes Kit Westneat
2021-05-25 12:47 ` [PATCH 1/3] block/blkdebug: add blocksize parameter Kit Westneat
2021-05-25 14:46 ` Eric Blake
2021-05-25 17:59 ` Kit Westneat
2021-05-25 12:47 ` [PATCH 2/3] tests/qtest/virtio-scsi-test: add unmap large LBA with 4k blocks test Kit Westneat
2021-05-25 12:47 ` Kit Westneat [this message]
2021-05-25 12:54 ` [PATCH 0/3] testing block device blocksizes no-reply
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=20210525124753.528516-4-kit.westneat@gmail.com \
--to=kit.westneat@gmail.com \
--cc=pbonzini@redhat.com \
--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 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).