[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 5/5] block: Add blklogwrites
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PULL 5/5] block: Add blklogwrites |
Date: |
Tue, 3 Jul 2018 17:07:58 +0200 |
User-agent: |
Mutt/1.9.1 (2017-09-22) |
Am 03.07.2018 um 16:59 hat Kevin Wolf geschrieben:
> From: Aapo Vienamo <address@hidden>
>
> 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 <address@hidden>
> Signed-off-by: Ari Sundholm <address@hidden>
> Signed-off-by: Kevin Wolf <address@hidden>
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;
}
- [Qemu-devel] [PULL 0/5] Block layer patches, Kevin Wolf, 2018/07/03
- [Qemu-devel] [PULL 1/5] qemu-img: allow compressed not-in-order writes, Kevin Wolf, 2018/07/03
- [Qemu-devel] [PULL 4/5] block: Move two block permission constants to the relevant enum, Kevin Wolf, 2018/07/03
- [Qemu-devel] [PULL 3/5] qcow2: add compress threads, Kevin Wolf, 2018/07/03
- [Qemu-devel] [PULL 5/5] block: Add blklogwrites, Kevin Wolf, 2018/07/03
- Re: [Qemu-devel] [PULL 5/5] block: Add blklogwrites,
Kevin Wolf <=
- [Qemu-devel] [PULL 2/5] qcow2: refactor data compression, Kevin Wolf, 2018/07/03
- Re: [Qemu-devel] [PULL 0/5] Block layer patches, Peter Maydell, 2018/07/04