From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PULL 5/5] block: Add blklogwrites
Date: Tue, 3 Jul 2018 17:07:58 +0200 [thread overview]
Message-ID: <20180703150758.GB28229@localhost.localdomain> (raw)
In-Reply-To: <20180703145915.32607-6-kwolf@redhat.com>
Am 03.07.2018 um 16:59 hat Kevin Wolf geschrieben:
> From: Aapo Vienamo <aapo@tuxera.com>
>
> Implements a block device write logging system, similar to Linux kernel
> device mapper dm-log-writes. The write operations that are performed
> on a block device are logged to a file or another block device. The
> write log format is identical to the dm-log-writes format. Currently,
> log markers are not supported.
>
> This functionality can be used for crash consistency and fs consistency
> testing. By implementing it in qemu, tests utilizing write logs can be
> be used to test non-Linux drivers and older kernels.
>
> The driver accepts an optional parameter to set the sector size used
> for logging. This makes the driver require all requests to be aligned
> to this sector size and also makes offsets and sizes of writes in the
> log metadata to be expressed in terms of this value (the log format has
> a granularity of one sector for offsets and sizes). This allows
> accurate logging of writes to guest block devices that have unusual
> sector sizes.
>
> The implementation is based on the blkverify and blkdebug block
> drivers.
>
> Signed-off-by: Aapo Vienamo <aapo@tuxera.com>
> Signed-off-by: Ari Sundholm <ari@tuxera.com>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Note that I saw Ari's v7 right after sending the pull request. It
contains only a few simple bugfixes compared to the version I had
queued, so I quickly squashed the following in and updated the tag.
Kevin
diff --git a/block/blklogwrites.c b/block/blklogwrites.c
index 0748b56d72..47093fadd6 100644
--- a/block/blklogwrites.c
+++ b/block/blklogwrites.c
@@ -53,6 +53,19 @@ typedef struct {
uint64_t nr_entries;
} BDRVBlkLogWritesState;
+static QemuOptsList runtime_opts = {
+ .name = "blklogwrites",
+ .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
+ .desc = {
+ {
+ .name = "log-sector-size",
+ .type = QEMU_OPT_SIZE,
+ .help = "Log sector size",
+ },
+ { /* end of list */ }
+ },
+};
+
static inline uint32_t blk_log_writes_log2(uint32_t value)
{
assert(value > 0);
@@ -63,9 +76,18 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVBlkLogWritesState *s = bs->opaque;
+ QemuOpts *opts;
Error *local_err = NULL;
int ret;
- int64_t log_sector_size = BDRV_SECTOR_SIZE;
+ int64_t log_sector_size;
+
+ opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);
+ qemu_opts_absorb_qdict(opts, options, &local_err);
+ if (local_err) {
+ ret = -EINVAL;
+ error_propagate(errp, local_err);
+ goto fail;
+ }
/* Open the file */
bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false,
@@ -76,12 +98,10 @@ static int blk_log_writes_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
- if (qdict_haskey(options, "log-sector-size")) {
- log_sector_size = qdict_get_int(options, "log-sector-size");
- qdict_del(options, "log-sector-size");
- }
+ log_sector_size = qemu_opt_get_size(opts, "log-sector-size",
+ BDRV_SECTOR_SIZE);
- if (log_sector_size < 0 || log_sector_size >= (1ull << 32) ||
+ if (log_sector_size < 0 || log_sector_size > (1ull << 23) ||
!is_power_of_2(log_sector_size))
{
ret = -EINVAL;
@@ -109,6 +129,7 @@ fail:
bdrv_unref_child(bs, bs->file);
bs->file = NULL;
}
+ qemu_opts_del(opts);
return ret;
}
@@ -144,6 +165,7 @@ static void blk_log_writes_refresh_filename(BlockDriverState *bs,
qobject_ref(s->log_file->bs->full_open_options);
qdict_put_obj(opts, "log",
QOBJECT(s->log_file->bs->full_open_options));
+ qdict_put_int(opts, "log-sector-size", s->sectorsize);
bs->full_open_options = opts;
}
next prev parent reply other threads:[~2018-07-03 15:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-03 14:59 [Qemu-devel] [PULL 0/5] Block layer patches Kevin Wolf
2018-07-03 14:59 ` [Qemu-devel] [PULL 1/5] qemu-img: allow compressed not-in-order writes Kevin Wolf
2018-07-03 14:59 ` [Qemu-devel] [PULL 2/5] qcow2: refactor data compression Kevin Wolf
2018-07-03 14:59 ` [Qemu-devel] [PULL 3/5] qcow2: add compress threads Kevin Wolf
2018-07-03 14:59 ` [Qemu-devel] [PULL 4/5] block: Move two block permission constants to the relevant enum Kevin Wolf
2018-07-03 14:59 ` [Qemu-devel] [PULL 5/5] block: Add blklogwrites Kevin Wolf
2018-07-03 15:07 ` Kevin Wolf [this message]
2018-07-04 18:30 ` [Qemu-devel] [PULL 0/5] Block layer patches Peter Maydell
2018-07-05 8:28 ` Kevin Wolf
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=20180703150758.GB28229@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=peter.maydell@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 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).