From nobody Mon Nov 25 09:50:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347145696418.9844354781492; Fri, 10 May 2024 06:19:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q7j-0005YF-0x; Fri, 10 May 2024 09:17:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7b-0005VR-J0; Fri, 10 May 2024 09:17:12 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7T-0002AS-Qf; Fri, 10 May 2024 09:17:08 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 06318473DB; Fri, 10 May 2024 15:16:53 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, f.gruenbichler@proxmox.com, t.lamprecht@proxmox.com, mahaocong@didichuxing.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com Subject: [PATCH v3 1/5] qapi/block-core: avoid the re-use of MirrorSyncMode for backup Date: Fri, 10 May 2024 15:16:43 +0200 Message-Id: <20240510131647.1256467-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240510131647.1256467-1-f.ebner@proxmox.com> References: <20240510131647.1256467-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1715347146006100001 Content-Type: text/plain; charset="utf-8" Backup supports all modes listed in MirrorSyncMode, while mirror does not. Introduce BackupSyncMode by copying the current MirrorSyncMode and drop the variants mirror does not support from MirrorSyncMode as well as the corresponding manual check in mirror_start(). A consequence is also tighter introspection: query-qmp-schema no longer reports drive-mirror and blockdev-mirror accepting @sync values they actually reject. Suggested-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Fiona Ebner Acked-by: Markus Armbruster Reviewed-by: Vladimir Sementsov-Ogievskiy --- Changes in v3: * add comment about introspection to commit message as suggested by Markus block/backup.c | 18 ++++++++--------- block/mirror.c | 7 ------- block/monitor/block-hmp-cmds.c | 2 +- block/replication.c | 2 +- blockdev.c | 26 ++++++++++++------------- include/block/block_int-global-state.h | 2 +- qapi/block-core.json | 27 +++++++++++++++++++++----- 7 files changed, 47 insertions(+), 37 deletions(-) diff --git a/block/backup.c b/block/backup.c index ec29d6b810..1cc4e055c6 100644 --- a/block/backup.c +++ b/block/backup.c @@ -37,7 +37,7 @@ typedef struct BackupBlockJob { =20 BdrvDirtyBitmap *sync_bitmap; =20 - MirrorSyncMode sync_mode; + BackupSyncMode sync_mode; BitmapSyncMode bitmap_mode; BlockdevOnError on_source_error; BlockdevOnError on_target_error; @@ -111,7 +111,7 @@ void backup_do_checkpoint(BlockJob *job, Error **errp) =20 assert(block_job_driver(job) =3D=3D &backup_job_driver); =20 - if (backup_job->sync_mode !=3D MIRROR_SYNC_MODE_NONE) { + if (backup_job->sync_mode !=3D BACKUP_SYNC_MODE_NONE) { error_setg(errp, "The backup job only supports block checkpoint in" " sync=3Dnone mode"); return; @@ -231,11 +231,11 @@ static void backup_init_bcs_bitmap(BackupBlockJob *jo= b) uint64_t estimate; BdrvDirtyBitmap *bcs_bitmap =3D block_copy_dirty_bitmap(job->bcs); =20 - if (job->sync_mode =3D=3D MIRROR_SYNC_MODE_BITMAP) { + if (job->sync_mode =3D=3D BACKUP_SYNC_MODE_BITMAP) { bdrv_clear_dirty_bitmap(bcs_bitmap, NULL); bdrv_dirty_bitmap_merge_internal(bcs_bitmap, job->sync_bitmap, NUL= L, true); - } else if (job->sync_mode =3D=3D MIRROR_SYNC_MODE_TOP) { + } else if (job->sync_mode =3D=3D BACKUP_SYNC_MODE_TOP) { /* * We can't hog the coroutine to initialize this thoroughly. * Set a flag and resume work when we are able to yield safely. @@ -254,7 +254,7 @@ static int coroutine_fn backup_run(Job *job, Error **er= rp) =20 backup_init_bcs_bitmap(s); =20 - if (s->sync_mode =3D=3D MIRROR_SYNC_MODE_TOP) { + if (s->sync_mode =3D=3D BACKUP_SYNC_MODE_TOP) { int64_t offset =3D 0; int64_t count; =20 @@ -282,7 +282,7 @@ static int coroutine_fn backup_run(Job *job, Error **er= rp) block_copy_set_skip_unallocated(s->bcs, false); } =20 - if (s->sync_mode =3D=3D MIRROR_SYNC_MODE_NONE) { + if (s->sync_mode =3D=3D BACKUP_SYNC_MODE_NONE) { /* * All bits are set in bcs bitmap to allow any cluster to be copie= d. * This does not actually require them to be copied. @@ -354,7 +354,7 @@ static const BlockJobDriver backup_job_driver =3D { =20 BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BlockDriverState *target, int64_t speed, - MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, + BackupSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, BitmapSyncMode bitmap_mode, bool compress, const char *filter_node_name, @@ -376,8 +376,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, GLOBAL_STATE_CODE(); =20 /* QMP interface protects us from these cases */ - assert(sync_mode !=3D MIRROR_SYNC_MODE_INCREMENTAL); - assert(sync_bitmap || sync_mode !=3D MIRROR_SYNC_MODE_BITMAP); + assert(sync_mode !=3D BACKUP_SYNC_MODE_INCREMENTAL); + assert(sync_bitmap || sync_mode !=3D BACKUP_SYNC_MODE_BITMAP); =20 if (bs =3D=3D target) { error_setg(errp, "Source and target cannot be the same"); diff --git a/block/mirror.c b/block/mirror.c index 1bdce3b657..c0597039a5 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -2013,13 +2013,6 @@ void mirror_start(const char *job_id, BlockDriverSta= te *bs, =20 GLOBAL_STATE_CODE(); =20 - if ((mode =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) || - (mode =3D=3D MIRROR_SYNC_MODE_BITMAP)) { - error_setg(errp, "Sync mode '%s' not supported", - MirrorSyncMode_str(mode)); - return; - } - bdrv_graph_rdlock_main_loop(); is_none_mode =3D mode =3D=3D MIRROR_SYNC_MODE_NONE; base =3D mode =3D=3D MIRROR_SYNC_MODE_TOP ? bdrv_backing_chain_next(bs= ) : NULL; diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index d954bec6f1..9633d000c0 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -266,7 +266,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict) .device =3D (char *)device, .target =3D (char *)filename, .format =3D (char *)format, - .sync =3D full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP, + .sync =3D full ? BACKUP_SYNC_MODE_FULL : BACKUP_SYNC_MODE_TOP, .has_mode =3D true, .mode =3D reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUT= E_PATHS, .has_compress =3D !!compress, diff --git a/block/replication.c b/block/replication.c index ca6bd0a720..1355e686f4 100644 --- a/block/replication.c +++ b/block/replication.c @@ -582,7 +582,7 @@ static void replication_start(ReplicationState *rs, Rep= licationMode mode, =20 s->backup_job =3D backup_job_create( NULL, s->secondary_disk->bs, s->hidden_dis= k->bs, - 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, = NULL, + 0, BACKUP_SYNC_MODE_NONE, NULL, 0, false, = NULL, &perf, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL, diff --git a/blockdev.c b/blockdev.c index 08eccc9052..32c93869ae 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1643,7 +1643,7 @@ static void drive_backup_action(DriveBackup *backup, * See if we have a backing HD we can use to create our new image * on top of. */ - if (backup->sync =3D=3D MIRROR_SYNC_MODE_TOP) { + if (backup->sync =3D=3D BACKUP_SYNC_MODE_TOP) { /* * Backup will not replace the source by the target, so none * of the filters skipped here will be removed (in contrast to @@ -1652,10 +1652,10 @@ static void drive_backup_action(DriveBackup *backup, */ source =3D bdrv_cow_bs(bdrv_skip_filters(bs)); if (!source) { - backup->sync =3D MIRROR_SYNC_MODE_FULL; + backup->sync =3D BACKUP_SYNC_MODE_FULL; } } - if (backup->sync =3D=3D MIRROR_SYNC_MODE_NONE) { + if (backup->sync =3D=3D BACKUP_SYNC_MODE_NONE) { source =3D bs; flags |=3D BDRV_O_NO_BACKING; set_backing_hd =3D true; @@ -2655,27 +2655,27 @@ static BlockJob *do_backup_common(BackupCommon *bac= kup, } } =20 - if ((backup->sync =3D=3D MIRROR_SYNC_MODE_BITMAP) || - (backup->sync =3D=3D MIRROR_SYNC_MODE_INCREMENTAL)) { + if ((backup->sync =3D=3D BACKUP_SYNC_MODE_BITMAP) || + (backup->sync =3D=3D BACKUP_SYNC_MODE_INCREMENTAL)) { /* done before desugaring 'incremental' to print the right message= */ if (!backup->bitmap) { error_setg(errp, "must provide a valid bitmap name for " - "'%s' sync mode", MirrorSyncMode_str(backup->sync)); + "'%s' sync mode", BackupSyncMode_str(backup->sync)); return NULL; } } =20 - if (backup->sync =3D=3D MIRROR_SYNC_MODE_INCREMENTAL) { + if (backup->sync =3D=3D BACKUP_SYNC_MODE_INCREMENTAL) { if (backup->has_bitmap_mode && backup->bitmap_mode !=3D BITMAP_SYNC_MODE_ON_SUCCESS) { error_setg(errp, "Bitmap sync mode must be '%s' " "when using sync mode '%s'", BitmapSyncMode_str(BITMAP_SYNC_MODE_ON_SUCCESS), - MirrorSyncMode_str(backup->sync)); + BackupSyncMode_str(backup->sync)); return NULL; } backup->has_bitmap_mode =3D true; - backup->sync =3D MIRROR_SYNC_MODE_BITMAP; + backup->sync =3D BACKUP_SYNC_MODE_BITMAP; backup->bitmap_mode =3D BITMAP_SYNC_MODE_ON_SUCCESS; } =20 @@ -2695,19 +2695,19 @@ static BlockJob *do_backup_common(BackupCommon *bac= kup, } =20 /* This does not produce a useful bitmap artifact: */ - if (backup->sync =3D=3D MIRROR_SYNC_MODE_NONE) { + if (backup->sync =3D=3D BACKUP_SYNC_MODE_NONE) { error_setg(errp, "sync mode '%s' does not produce meaningful b= itmap" - " outputs", MirrorSyncMode_str(backup->sync)); + " outputs", BackupSyncMode_str(backup->sync)); return NULL; } =20 /* If the bitmap isn't used for input or output, this is useless: = */ if (backup->bitmap_mode =3D=3D BITMAP_SYNC_MODE_NEVER && - backup->sync !=3D MIRROR_SYNC_MODE_BITMAP) { + backup->sync !=3D BACKUP_SYNC_MODE_BITMAP) { error_setg(errp, "Bitmap sync mode '%s' has no meaningful effe= ct" " when combined with sync mode '%s'", BitmapSyncMode_str(backup->bitmap_mode), - MirrorSyncMode_str(backup->sync)); + BackupSyncMode_str(backup->sync)); return NULL; } } diff --git a/include/block/block_int-global-state.h b/include/block/block_i= nt-global-state.h index d2201e27f4..54f8c8cbcb 100644 --- a/include/block/block_int-global-state.h +++ b/include/block/block_int-global-state.h @@ -190,7 +190,7 @@ void mirror_start(const char *job_id, BlockDriverState = *bs, */ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BlockDriverState *target, int64_t speed, - MirrorSyncMode sync_mode, + BackupSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, BitmapSyncMode bitmap_mode, bool compress, diff --git a/qapi/block-core.json b/qapi/block-core.json index 746d1694c2..9d94129ea2 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1304,10 +1304,10 @@ 'data': ['report', 'ignore', 'enospc', 'stop', 'auto'] } =20 ## -# @MirrorSyncMode: +# @BackupSyncMode: # -# An enumeration of possible behaviors for the initial synchronization -# phase of storage mirroring. +# An enumeration of possible behaviors for image synchronization used +# by backup jobs. # # @top: copies data in the topmost image to the destination # @@ -1323,7 +1323,7 @@ # # Since: 1.3 ## -{ 'enum': 'MirrorSyncMode', +{ 'enum': 'BackupSyncMode', 'data': ['top', 'full', 'none', 'incremental', 'bitmap'] } =20 ## @@ -1347,6 +1347,23 @@ { 'enum': 'BitmapSyncMode', 'data': ['on-success', 'never', 'always'] } =20 +## +# @MirrorSyncMode: +# +# An enumeration of possible behaviors for the initial synchronization +# phase of storage mirroring. +# +# @top: copies data in the topmost image to the destination +# +# @full: copies data from all images to the destination +# +# @none: only copy data written from now on +# +# Since: 1.3 +## +{ 'enum': 'MirrorSyncMode', + 'data': ['top', 'full', 'none'] } + ## # @MirrorCopyMode: # @@ -1624,7 +1641,7 @@ ## { 'struct': 'BackupCommon', 'data': { '*job-id': 'str', 'device': 'str', - 'sync': 'MirrorSyncMode', '*speed': 'int', + 'sync': 'BackupSyncMode', '*speed': 'int', '*bitmap': 'str', '*bitmap-mode': 'BitmapSyncMode', '*compress': 'bool', '*on-source-error': 'BlockdevOnError', --=20 2.39.2 From nobody Mon Nov 25 09:50:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347073282265.24211027447416; Fri, 10 May 2024 06:17:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q7k-0005a4-0y; Fri, 10 May 2024 09:17:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7a-0005VP-Fc; Fri, 10 May 2024 09:17:12 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7T-0002AP-PO; Fri, 10 May 2024 09:17:08 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 574FB473F9; Fri, 10 May 2024 15:16:52 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, f.gruenbichler@proxmox.com, t.lamprecht@proxmox.com, mahaocong@didichuxing.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com Subject: [PATCH v3 2/5] block/mirror: replace is_none_mode with sync_mode in MirrorBlockJob struct Date: Fri, 10 May 2024 15:16:44 +0200 Message-Id: <20240510131647.1256467-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240510131647.1256467-1-f.ebner@proxmox.com> References: <20240510131647.1256467-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1715347074705100005 Content-Type: text/plain; charset="utf-8" It is more flexible and is done in preparation to support specifying a working bitmap for mirror jobs. In particular, this makes it possible to assert that @sync_mode=3Dfull when a bitmap is used. That assertion is just to be sure, of course the mirror QMP commands will be made to fail earlier with a clean error. Signed-off-by: Fiona Ebner --- New in v3. block/mirror.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index c0597039a5..ca23d6ef65 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -51,7 +51,7 @@ typedef struct MirrorBlockJob { BlockDriverState *to_replace; /* Used to block operations on the drive-mirror-replace target */ Error *replace_blocker; - bool is_none_mode; + MirrorSyncMode sync_mode; BlockMirrorBackingMode backing_mode; /* Whether the target image requires explicit zero-initialization */ bool zero_target; @@ -722,7 +722,8 @@ static int mirror_exit_common(Job *job) &error_abort); =20 if (!abort && s->backing_mode =3D=3D MIRROR_SOURCE_BACKING_CHAIN) { - BlockDriverState *backing =3D s->is_none_mode ? src : s->base; + BlockDriverState *backing; + backing =3D s->sync_mode =3D=3D MIRROR_SYNC_MODE_NONE ? src : s->b= ase; BlockDriverState *unfiltered_target =3D bdrv_skip_filters(target_b= s); =20 if (bdrv_cow_bs(unfiltered_target) !=3D backing) { @@ -1015,7 +1016,7 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) mirror_free_init(s); =20 s->last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - if (!s->is_none_mode) { + if (s->sync_mode !=3D MIRROR_SYNC_MODE_NONE) { ret =3D mirror_dirty_init(s); if (ret < 0 || job_is_cancelled(&s->common.job)) { goto immediate_exit; @@ -1714,7 +1715,8 @@ static BlockJob *mirror_start_job( BlockCompletionFunc *cb, void *opaque, const BlockJobDriver *driver, - bool is_none_mode, BlockDriverState *base, + MirrorSyncMode sync_mode, + BlockDriverState *base, bool auto_complete, const char *filter_node_n= ame, bool is_mirror, MirrorCopyMode copy_mode, Error **errp) @@ -1871,7 +1873,7 @@ static BlockJob *mirror_start_job( s->replaces =3D g_strdup(replaces); s->on_source_error =3D on_source_error; s->on_target_error =3D on_target_error; - s->is_none_mode =3D is_none_mode; + s->sync_mode =3D sync_mode; s->backing_mode =3D backing_mode; s->zero_target =3D zero_target; qatomic_set(&s->copy_mode, copy_mode); @@ -2008,20 +2010,18 @@ void mirror_start(const char *job_id, BlockDriverSt= ate *bs, bool unmap, const char *filter_node_name, MirrorCopyMode copy_mode, Error **errp) { - bool is_none_mode; BlockDriverState *base; =20 GLOBAL_STATE_CODE(); =20 bdrv_graph_rdlock_main_loop(); - is_none_mode =3D mode =3D=3D MIRROR_SYNC_MODE_NONE; base =3D mode =3D=3D MIRROR_SYNC_MODE_TOP ? bdrv_backing_chain_next(bs= ) : NULL; bdrv_graph_rdunlock_main_loop(); =20 mirror_start_job(job_id, bs, creation_flags, target, replaces, speed, granularity, buf_size, backing_mode, zero_targ= et, on_source_error, on_target_error, unmap, NULL, NULL, - &mirror_job_driver, is_none_mode, base, false, + &mirror_job_driver, mode, base, false, filter_node_name, true, copy_mode, errp); } =20 @@ -2049,9 +2049,9 @@ BlockJob *commit_active_start(const char *job_id, Blo= ckDriverState *bs, job_id, bs, creation_flags, base, NULL, speed, 0, 0, MIRROR_LEAVE_BACKING_CHAIN, false, on_error, on_error, true, cb, opaque, - &commit_active_job_driver, false, base, auto_complete, - filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND, - errp); + &commit_active_job_driver, MIRROR_SYNC_MODE_FULL, bas= e, + auto_complete, filter_node_name, false, + MIRROR_COPY_MODE_BACKGROUND, errp); if (!job) { goto error_restore_flags; } --=20 2.39.2 From nobody Mon Nov 25 09:50:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347114268730.0278843260406; Fri, 10 May 2024 06:18:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q7l-0005ay-Rl; Fri, 10 May 2024 09:17:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7Y-0005VI-H9; Fri, 10 May 2024 09:17:10 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7T-0002Ac-EY; Fri, 10 May 2024 09:17:07 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1EA13473CD; Fri, 10 May 2024 15:16:54 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, f.gruenbichler@proxmox.com, t.lamprecht@proxmox.com, mahaocong@didichuxing.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com Subject: [PATCH v3 3/5] mirror: allow specifying working bitmap Date: Fri, 10 May 2024 15:16:45 +0200 Message-Id: <20240510131647.1256467-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240510131647.1256467-1-f.ebner@proxmox.com> References: <20240510131647.1256467-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1715347115740100003 From: John Snow for the mirror job. The bitmap's granularity is used as the job's granularity. The new @bitmap parameter is marked unstable in the QAPI and can currently only be used for @sync=3Dfull mode. Clusters initially dirty in the bitmap as well as new writes are copied to the target. Using block-dirty-bitmap-clear and block-dirty-bitmap-merge API, callers can simulate the three kinds of @BitmapSyncMode (which is used by backup): 1. always: default, just pass bitmap as working bitmap. 2. never: copy bitmap and pass copy to the mirror job. 3. on-success: copy bitmap and pass copy to the mirror job and if successful, merge bitmap into original afterwards. When the target image is a non-COW "diff image", i.e. one that was not used as the target of a previous mirror and the target image's cluster size is larger than the bitmap's granularity, or when @copy-mode=3Dwrite-blocking is used, there is a pitfall, because the cluster in the target image will be allocated, but not contain all the data corresponding to the same region in the source image. An idea to avoid the limitation would be to mark clusters which are affected by unaligned writes and are not allocated in the target image dirty, so they would be copied fully later. However, for migration, the invariant that an actively synced mirror stays actively synced (unless an error happens) is useful, because without that invariant, migration might inactivate block devices when mirror still got work to do and run into an assertion failure [0]. Another approach would be to read the missing data from the source upon unaligned writes to be able to write the full target cluster instead. But certain targets like NBD do not allow querying the cluster size. To avoid limiting/breaking the use case of syncing to an existing target, which is arguably more common than the diff image use case, document the limitation in QAPI. This patch was originally based on one by Ma Haocong, but it has since been modified pretty heavily, first by John and then again by Fiona. [0]: https://lore.kernel.org/qemu-devel/1db7f571-cb7f-c293-04cc-cd856e060c3= f@proxmox.com/ Suggested-by: Ma Haocong Signed-off-by: Ma Haocong Signed-off-by: John Snow [FG: switch to bdrv_dirty_bitmap_merge_internal] Signed-off-by: Fabian Gr=C3=BCnbichler Signed-off-by: Thomas Lamprecht [FE: rebase for 9.1 get rid of bitmap mode parameter use caller-provided bitmap as working bitmap turn bitmap parameter experimental] Signed-off-by: Fiona Ebner Acked-by: Markus Armbruster --- Changes in v3: * remove duplicate "use" in QAPI description * clarify that cluster size caveats only applies to non-COW diff image * split changing is_none_mode to sync_mode in job struct into a separate patch * use shorter sync_mode !=3D none rather than sync_mode =3D=3D top || full in an if condition * also disallow read-only bitmap (cannot be used as working bitmap) * require that bitmap is enabled at the start of the job block/mirror.c | 80 +++++++++++++++++++++----- blockdev.c | 44 +++++++++++--- include/block/block_int-global-state.h | 5 +- qapi/block-core.json | 37 +++++++++++- tests/unit/test-block-iothread.c | 2 +- 5 files changed, 143 insertions(+), 25 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index ca23d6ef65..d3d0698116 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -73,6 +73,11 @@ typedef struct MirrorBlockJob { size_t buf_size; int64_t bdev_length; unsigned long *cow_bitmap; + /* + * Whether the bitmap is created locally or provided by the caller (for + * incremental sync). + */ + bool dirty_bitmap_is_local; BdrvDirtyBitmap *dirty_bitmap; BdrvDirtyBitmapIter *dbi; uint8_t *buf; @@ -691,7 +696,11 @@ static int mirror_exit_common(Job *job) bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs); } =20 - bdrv_release_dirty_bitmap(s->dirty_bitmap); + if (s->dirty_bitmap_is_local) { + bdrv_release_dirty_bitmap(s->dirty_bitmap); + } else { + bdrv_enable_dirty_bitmap(s->dirty_bitmap); + } =20 /* Make sure that the source BDS doesn't go away during bdrv_replace_n= ode, * before we can call bdrv_drained_end */ @@ -820,6 +829,16 @@ static void mirror_abort(Job *job) assert(ret =3D=3D 0); } =20 +/* Always called after commit/abort. */ +static void mirror_clean(Job *job) +{ + MirrorBlockJob *s =3D container_of(job, MirrorBlockJob, common.job); + + if (!s->dirty_bitmap_is_local && s->dirty_bitmap) { + bdrv_dirty_bitmap_set_busy(s->dirty_bitmap, false); + } +} + static void coroutine_fn mirror_throttle(MirrorBlockJob *s) { int64_t now =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); @@ -1016,7 +1035,7 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) mirror_free_init(s); =20 s->last_pause_ns =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); - if (s->sync_mode !=3D MIRROR_SYNC_MODE_NONE) { + if (s->sync_mode !=3D MIRROR_SYNC_MODE_NONE && s->dirty_bitmap_is_loca= l) { ret =3D mirror_dirty_init(s); if (ret < 0 || job_is_cancelled(&s->common.job)) { goto immediate_exit; @@ -1029,6 +1048,14 @@ static int coroutine_fn mirror_run(Job *job, Error *= *errp) */ mirror_top_opaque->job =3D s; =20 + /* + * External/caller-provided bitmap can only be disabled now that + * bdrv_mirror_top_do_write() can access it. + */ + if (!s->dirty_bitmap_is_local) { + bdrv_disable_dirty_bitmap(s->dirty_bitmap); + } + assert(!s->dbi); s->dbi =3D bdrv_dirty_iter_new(s->dirty_bitmap); for (;;) { @@ -1305,6 +1332,7 @@ static const BlockJobDriver mirror_job_driver =3D { .run =3D mirror_run, .prepare =3D mirror_prepare, .abort =3D mirror_abort, + .clean =3D mirror_clean, .pause =3D mirror_pause, .complete =3D mirror_complete, .cancel =3D mirror_cancel, @@ -1323,6 +1351,7 @@ static const BlockJobDriver commit_active_job_driver = =3D { .run =3D mirror_run, .prepare =3D mirror_prepare, .abort =3D mirror_abort, + .clean =3D mirror_clean, .pause =3D mirror_pause, .complete =3D mirror_complete, .cancel =3D commit_active_cancel, @@ -1716,6 +1745,7 @@ static BlockJob *mirror_start_job( void *opaque, const BlockJobDriver *driver, MirrorSyncMode sync_mode, + BdrvDirtyBitmap *bitmap, BlockDriverState *base, bool auto_complete, const char *filter_node_n= ame, bool is_mirror, MirrorCopyMode copy_mode, @@ -1730,10 +1760,15 @@ static BlockJob *mirror_start_job( =20 GLOBAL_STATE_CODE(); =20 - if (granularity =3D=3D 0) { + /* QMP interface ensures these conditions */ + assert(!bitmap || sync_mode =3D=3D MIRROR_SYNC_MODE_FULL); + assert(!(bitmap && granularity)); + + if (bitmap) { + granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + } else if (granularity =3D=3D 0) { granularity =3D bdrv_get_default_bitmap_granularity(target); } - assert(is_power_of_2(granularity)); =20 if (buf_size < 0) { @@ -1887,17 +1922,27 @@ static BlockJob *mirror_start_job( } bdrv_graph_rdunlock_main_loop(); =20 - s->dirty_bitmap =3D bdrv_create_dirty_bitmap(s->mirror_top_bs, granula= rity, - NULL, errp); - if (!s->dirty_bitmap) { - goto fail; + if (bitmap) { + s->dirty_bitmap_is_local =3D false; + s->dirty_bitmap =3D bitmap; + bdrv_dirty_bitmap_set_busy(s->dirty_bitmap, true); + } else { + s->dirty_bitmap_is_local =3D true; + s->dirty_bitmap =3D bdrv_create_dirty_bitmap(s->mirror_top_bs, + granularity, NULL, errp= ); + if (!s->dirty_bitmap) { + goto fail; + } } =20 /* * The dirty bitmap is set by bdrv_mirror_top_do_write() when not in a= ctive - * mode. + * mode. For external/caller-provided bitmap, need to wait until + * bdrv_mirror_top_do_write() can actually access it before disabling. */ - bdrv_disable_dirty_bitmap(s->dirty_bitmap); + if (s->dirty_bitmap_is_local) { + bdrv_disable_dirty_bitmap(s->dirty_bitmap); + } =20 bdrv_graph_wrlock(); ret =3D block_job_add_bdrv(&s->common, "source", bs, 0, @@ -1979,7 +2024,11 @@ fail: blk_unref(s->target); bs_opaque->job =3D NULL; if (s->dirty_bitmap) { - bdrv_release_dirty_bitmap(s->dirty_bitmap); + if (s->dirty_bitmap_is_local) { + bdrv_release_dirty_bitmap(s->dirty_bitmap); + } else { + bdrv_dirty_bitmap_set_busy(s->dirty_bitmap, false); + } } job_early_fail(&s->common.job); } @@ -2003,7 +2052,8 @@ void mirror_start(const char *job_id, BlockDriverStat= e *bs, BlockDriverState *target, const char *replaces, int creation_flags, int64_t speed, uint32_t granularity, int64_t buf_size, - MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, + MirrorSyncMode mode, BdrvDirtyBitmap *bitmap, + BlockMirrorBackingMode backing_mode, bool zero_target, BlockdevOnError on_source_error, BlockdevOnError on_target_error, @@ -2021,7 +2071,7 @@ void mirror_start(const char *job_id, BlockDriverStat= e *bs, mirror_start_job(job_id, bs, creation_flags, target, replaces, speed, granularity, buf_size, backing_mode, zero_targ= et, on_source_error, on_target_error, unmap, NULL, NULL, - &mirror_job_driver, mode, base, false, + &mirror_job_driver, mode, bitmap, base, false, filter_node_name, true, copy_mode, errp); } =20 @@ -2049,8 +2099,8 @@ BlockJob *commit_active_start(const char *job_id, Blo= ckDriverState *bs, job_id, bs, creation_flags, base, NULL, speed, 0, 0, MIRROR_LEAVE_BACKING_CHAIN, false, on_error, on_error, true, cb, opaque, - &commit_active_job_driver, MIRROR_SYNC_MODE_FULL, bas= e, - auto_complete, filter_node_name, false, + &commit_active_job_driver, MIRROR_SYNC_MODE_FULL, NUL= L, + base, auto_complete, filter_node_name, false, MIRROR_COPY_MODE_BACKGROUND, errp); if (!job) { goto error_restore_flags; diff --git a/blockdev.c b/blockdev.c index 32c93869ae..4f72a72dc7 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2776,6 +2776,7 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, BlockDriverState *target, const char *replaces, enum MirrorSyncMode sync, + const char *bitmap_name, BlockMirrorBackingMode backing_mode, bool zero_target, bool has_speed, int64_t speed, @@ -2794,6 +2795,7 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, { BlockDriverState *unfiltered_bs; int job_flags =3D JOB_DEFAULT; + BdrvDirtyBitmap *bitmap =3D NULL; =20 GLOBAL_STATE_CODE(); GRAPH_RDLOCK_GUARD_MAINLOOP(); @@ -2844,6 +2846,33 @@ static void blockdev_mirror_common(const char *job_i= d, BlockDriverState *bs, return; } =20 + if (bitmap_name) { + if (sync !=3D MIRROR_SYNC_MODE_FULL) { + error_setg(errp, "Sync mode '%s' not supported with bitmap.", + MirrorSyncMode_str(sync)); + return; + } + if (granularity) { + error_setg(errp, "Granularity and bitmap cannot both be set"); + return; + } + + bitmap =3D bdrv_find_dirty_bitmap(bs, bitmap_name); + if (!bitmap) { + error_setg(errp, "Dirty bitmap '%s' not found", bitmap_name); + return; + } + + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { + return; + } + + if (!bdrv_dirty_bitmap_enabled(bitmap)) { + error_setg(errp, "Bitmap '%s' is not enabled", bitmap_name); + return; + } + } + if (!bdrv_backing_chain_next(bs) && sync =3D=3D MIRROR_SYNC_MODE_TOP) { sync =3D MIRROR_SYNC_MODE_FULL; } @@ -2889,10 +2918,9 @@ static void blockdev_mirror_common(const char *job_i= d, BlockDriverState *bs, * and will allow to check whether the node still exist at mirror comp= letion */ mirror_start(job_id, bs, target, - replaces, job_flags, - speed, granularity, buf_size, sync, backing_mode, zero_ta= rget, - on_source_error, on_target_error, unmap, filter_node_name, - copy_mode, errp); + replaces, job_flags, speed, granularity, buf_size, sync, + bitmap, backing_mode, zero_target, on_source_error, + on_target_error, unmap, filter_node_name, copy_mode, errp= ); } =20 void qmp_drive_mirror(DriveMirror *arg, Error **errp) @@ -3033,7 +3061,7 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) } =20 blockdev_mirror_common(arg->job_id, bs, target_bs, - arg->replaces, arg->sync, + arg->replaces, arg->sync, arg->bitmap, backing_mode, zero_target, arg->has_speed, arg->speed, arg->has_granularity, arg->granularity, @@ -3053,6 +3081,7 @@ void qmp_blockdev_mirror(const char *job_id, const char *device, const char *target, const char *replaces, MirrorSyncMode sync, + const char *bitmap, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, @@ -3093,8 +3122,9 @@ void qmp_blockdev_mirror(const char *job_id, } =20 blockdev_mirror_common(job_id, bs, target_bs, - replaces, sync, backing_mode, - zero_target, has_speed, speed, + replaces, sync, bitmap, + backing_mode, zero_target, + has_speed, speed, has_granularity, granularity, has_buf_size, buf_size, has_on_source_error, on_source_error, diff --git a/include/block/block_int-global-state.h b/include/block/block_i= nt-global-state.h index 54f8c8cbcb..8b93db017e 100644 --- a/include/block/block_int-global-state.h +++ b/include/block/block_int-global-state.h @@ -138,6 +138,8 @@ BlockJob *commit_active_start(const char *job_id, Block= DriverState *bs, * @granularity: The chosen granularity for the dirty bitmap. * @buf_size: The amount of data that can be in flight at one time. * @mode: Whether to collapse all images in the chain to the target. + * @bitmap: Use this bitmap as a working bitmap, i.e. non-dirty clusters a= re + only mirrored if written to later. * @backing_mode: How to establish the target's backing chain after comple= tion. * @zero_target: Whether the target should be explicitly zero-initialized * @on_source_error: The action to take upon error reading from the source. @@ -158,7 +160,8 @@ void mirror_start(const char *job_id, BlockDriverState = *bs, BlockDriverState *target, const char *replaces, int creation_flags, int64_t speed, uint32_t granularity, int64_t buf_size, - MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, + MirrorSyncMode mode, BdrvDirtyBitmap *bitmap, + BlockMirrorBackingMode backing_mode, bool zero_target, BlockdevOnError on_source_error, BlockdevOnError on_target_error, diff --git a/qapi/block-core.json b/qapi/block-core.json index 9d94129ea2..5ddebe71ee 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2191,6 +2191,18 @@ # destination (all the disk, only the sectors allocated in the # topmost image, or only new I/O). # +# @bitmap: The name of a bitmap to use as a working bitmap for +# sync=3Dfull mode. This argument must be not be present for other +# sync modes and not at the same time as @granularity. The +# bitmap's granularity is used as the job's granularity. When +# the target does not support COW and is a diff image, i.e. one +# that should only contain the delta and was not synced to +# previously, the target's cluster size must not be larger than +# the bitmap's granularity and copy-mode=3Dwrite-blocking should not +# be used. That is, because unaligned writes will lead to +# allocated clusters with partial data in the target image! +# (Since 9.1) +# # @granularity: granularity of the dirty bitmap, default is 64K if the # image format doesn't have clusters, 4K if the clusters are # smaller than that, else the cluster size. Must be a power of 2 @@ -2228,12 +2240,18 @@ # disappear from the query list without user intervention. # Defaults to true. (Since 3.1) # +# Features: +# +# @unstable: Member @bitmap is experimental. +# # Since: 1.3 ## { 'struct': 'DriveMirror', 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*format': 'str', '*node-name': 'str', '*replaces': 'str', - 'sync': 'MirrorSyncMode', '*mode': 'NewImageMode', + 'sync': 'MirrorSyncMode', + '*bitmap': { 'type': 'str', 'features': [ 'unstable' ] }, + '*mode': 'NewImageMode', '*speed': 'int', '*granularity': 'uint32', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', @@ -2513,6 +2531,18 @@ # destination (all the disk, only the sectors allocated in the # topmost image, or only new I/O). # +# @bitmap: The name of a bitmap to use as a working bitmap for +# sync=3Dfull mode. This argument must be not be present for other +# sync modes and not at the same time as @granularity. The +# bitmap's granularity is used as the job's granularity. When +# the target does not support COW and is a diff image, i.e. one +# that should only contain the delta and was not synced to +# previously, the target's cluster size must not be larger than +# the bitmap's granularity and copy-mode=3Dwrite-blocking should not +# be used. That is, because unaligned writes will lead to +# allocated clusters with partial data in the target image! +# (Since 9.1) +# # @granularity: granularity of the dirty bitmap, default is 64K if the # image format doesn't have clusters, 4K if the clusters are # smaller than that, else the cluster size. Must be a power of 2 @@ -2548,6 +2578,10 @@ # disappear from the query list without user intervention. # Defaults to true. (Since 3.1) # +# Features: +# +# @unstable: Member @bitmap is experimental. +# # Since: 2.6 # # Example: @@ -2562,6 +2596,7 @@ 'data': { '*job-id': 'str', 'device': 'str', 'target': 'str', '*replaces': 'str', 'sync': 'MirrorSyncMode', + '*bitmap': { 'type': 'str', 'features': [ 'unstable' ] }, '*speed': 'int', '*granularity': 'uint32', '*buf-size': 'int', '*on-source-error': 'BlockdevOnError', '*on-target-error': 'BlockdevOnError', diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 3766d5de6b..b64158aa11 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -755,7 +755,7 @@ static void test_propagate_mirror(void) =20 /* Start a mirror job */ mirror_start("job0", src, target, NULL, JOB_DEFAULT, 0, 0, 0, - MIRROR_SYNC_MODE_NONE, MIRROR_OPEN_BACKING_CHAIN, false, + MIRROR_SYNC_MODE_NONE, NULL, MIRROR_OPEN_BACKING_CHAIN, f= alse, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, false, "filter_node", MIRROR_COPY_MODE_BACKGROUND, &error_abort); --=20 2.39.2 From nobody Mon Nov 25 09:50:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347135100881.2773436040775; Fri, 10 May 2024 06:18:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q7n-0005cJ-GA; Fri, 10 May 2024 09:17:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7j-0005YQ-0f; Fri, 10 May 2024 09:17:19 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7a-0002DU-O0; Fri, 10 May 2024 09:17:18 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 76891473ED; Fri, 10 May 2024 15:16:57 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, f.gruenbichler@proxmox.com, t.lamprecht@proxmox.com, mahaocong@didichuxing.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com Subject: [PATCH v3 4/5] iotests: add test for bitmap mirror Date: Fri, 10 May 2024 15:16:46 +0200 Message-Id: <20240510131647.1256467-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240510131647.1256467-1-f.ebner@proxmox.com> References: <20240510131647.1256467-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1715347135974100001 From: Fabian Gr=C3=BCnbichler heavily based on/practically forked off iotest 257 for bitmap backups, but: - no writes to filter node 'mirror-top' between completion and finalization, as those seem to deadlock? - extra set of reference/test mirrors to verify that writes in parallel with active mirror work Intentionally keeping copyright and ownership of original test case to honor provenance. The test was originally adapted by Fabian from 257, but has seen rather big changes, because the interface for mirror with bitmap was changed, i.e. no @bitmap-mode parameter anymore and bitmap is used as the working bitmap, and the test was changed to use backing images and @sync-mode=3Dwrite-blocking. Signed-off-by: Fabian Gr=C3=BCnbichler Signed-off-by: Thomas Lamprecht [FE: rebase for 9.1 adapt to changes to mirror bitmap interface rename test from '384' to 'mirror-bitmap' use backing files, copy-mode=3Dwrite-blocking, larger cluster size] Signed-off-by: Fiona Ebner --- Changes in v3: * avoid script potentially waiting on non-existent job when blockdev-mirror QMP command fails by asserting that there is no error when none is expected. * fix pylint issues * rename test from sync-bitmap-mirror to mirror-bitmap * use backing files (rather than stand-alone diff images) in combination with copy-mode=3Dwrite-blocking and larger cluster size for target images, to have a more realistic use-case and show that COW prevents ending up with cluster with partial data upon unaligned writes tests/qemu-iotests/tests/mirror-bitmap | 597 ++++ tests/qemu-iotests/tests/mirror-bitmap.out | 3191 ++++++++++++++++++++ 2 files changed, 3788 insertions(+) create mode 100755 tests/qemu-iotests/tests/mirror-bitmap create mode 100644 tests/qemu-iotests/tests/mirror-bitmap.out diff --git a/tests/qemu-iotests/tests/mirror-bitmap b/tests/qemu-iotests/te= sts/mirror-bitmap new file mode 100755 index 0000000000..37bbe0f241 --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-bitmap @@ -0,0 +1,597 @@ +#!/usr/bin/env python3 +# group: rw +# +# Test bitmap-sync mirrors (incremental, differential, and partials) +# +# Copyright (c) 2019 John Snow for Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# owner=3Djsnow@redhat.com + +import os + +import iotests +from iotests import log, qemu_img + +SIZE =3D 64 * 1024 * 1024 +GRANULARITY =3D 64 * 1024 +IMAGE_CLUSTER_SIZE =3D 128 * 1024 + + +class Pattern: + def __init__(self, byte, offset, size=3DGRANULARITY): + self.byte =3D byte + self.offset =3D offset + self.size =3D size + + def bits(self, granularity): + lower =3D self.offset // granularity + upper =3D (self.offset + self.size - 1) // granularity + return set(range(lower, upper + 1)) + + +class PatternGroup: + """Grouping of Pattern objects. Initialize with an iterable of Pattern= s.""" + def __init__(self, patterns): + self.patterns =3D patterns + + def bits(self, granularity): + """Calculate the unique bits dirtied by this pattern grouping""" + res =3D set() + for pattern in self.patterns: + res |=3D pattern.bits(granularity) + return res + + +GROUPS =3D [ + PatternGroup([ + # Batch 0: 4 clusters + Pattern('0x49', 0x0000000), + Pattern('0x6c', 0x0100000), # 1M + Pattern('0x6f', 0x2000000), # 32M + Pattern('0x76', 0x3ff0000)]), # 64M - 64K + PatternGroup([ + # Batch 1: 6 clusters (3 new) + Pattern('0x65', 0x0000000), # Full overwrite + Pattern('0x77', 0x00f8000), # Partial-left (1M-32K) + Pattern('0x72', 0x2008000), # Partial-right (32M+32K) + Pattern('0x69', 0x3fe0000)]), # Adjacent-left (64M - 128K) + PatternGroup([ + # Batch 2: 7 clusters (3 new) + Pattern('0x74', 0x0010000), # Adjacent-right + Pattern('0x69', 0x00e8000), # Partial-left (1M-96K) + Pattern('0x6e', 0x2018000), # Partial-right (32M+96K) + Pattern('0x67', 0x3fe0000, + 2*GRANULARITY)]), # Overwrite [(64M-128K)-64M) + PatternGroup([ + # Batch 3: 8 clusters (5 new) + # Carefully chosen such that nothing re-dirties the one cluster + # that copies out successfully before failure in Group #1. + Pattern('0xaa', 0x0010000, + 3*GRANULARITY), # Overwrite and 2x Adjacent-right + Pattern('0xbb', 0x00d8000), # Partial-left (1M-160K) + Pattern('0xcc', 0x2028000), # Partial-right (32M+160K) + Pattern('0xdd', 0x3fc0000)]), # New; leaving a gap to the right +] + + +class EmulatedBitmap: + def __init__(self, granularity=3DGRANULARITY): + self._bits =3D set() + self.granularity =3D granularity + + def dirty_bits(self, bits): + self._bits |=3D set(bits) + + def dirty_group(self, n): + self.dirty_bits(GROUPS[n].bits(self.granularity)) + + def clear(self): + self._bits =3D set() + + def clear_bits(self, bits): + self._bits -=3D set(bits) + + def clear_bit(self, bit): + self.clear_bits({bit}) + + def clear_group(self, n): + self.clear_bits(GROUPS[n].bits(self.granularity)) + + @property + def first_bit(self): + return sorted(self.bits)[0] + + @property + def bits(self): + return self._bits + + @property + def count(self): + return len(self.bits) + + def compare(self, qmp_bitmap): + """ + Print a nice human-readable message checking that a bitmap as repo= rted + by the QMP interface has as many bits set as we expect it to. + """ + + name =3D qmp_bitmap.get('name', '(anonymous)') + log("=3D Checking Bitmap {:s} =3D".format(name)) + + want =3D self.count + have =3D qmp_bitmap['count'] // qmp_bitmap['granularity'] + + log("expecting {:d} dirty sectors; have {:d}. {:s}".format( + want, have, "OK!" if want =3D=3D have else "ERROR!")) + log('') + + +class Drive: + """Represents, vaguely, a drive attached to a VM. + Includes format, graph, and device information.""" + + def __init__(self, path, vm=3DNone): + self.path =3D path + self.vm =3D vm + self.fmt =3D None + self.size =3D None + self.node =3D None + self.file_node =3D None + + def img_create(self, fmt, size): + self.fmt =3D fmt + self.size =3D size + iotests.qemu_img_create('-f', self.fmt, self.path, str(self.size)) + + def create_target(self, name, fmt, size, backing_file): + basename =3D os.path.basename(self.path) + file_node_name =3D "file_{}".format(basename) + vm =3D self.vm + + log(vm.cmd('blockdev-create', job_id=3D'bdc-file-job', + options=3D{ + 'driver': 'file', + 'filename': self.path, + 'size': 0, + })) + vm.run_job('bdc-file-job') + log(vm.cmd('blockdev-add', driver=3D'file', + node_name=3Dfile_node_name, filename=3Dself.path)) + + bdc_fmt_opts =3D { + 'driver': fmt, + 'file': file_node_name, + 'size': size, + 'cluster-size': IMAGE_CLUSTER_SIZE, + } + + if backing_file is not None: + bdc_fmt_opts['backing-file'] =3D backing_file + + log(vm.cmd('blockdev-create', job_id=3D'bdc-fmt-job', + options=3Dbdc_fmt_opts)) + vm.run_job('bdc-fmt-job') + log(vm.cmd('blockdev-add', driver=3Dfmt, + node_name=3Dname, + file=3Dfile_node_name)) + self.fmt =3D fmt + self.size =3D size + self.node =3D name + self.file_node =3D file_node_name + + def detach_target(self): + vm =3D self.vm + log('--- Detaching {} ---'.format(self.node)) + log(vm.cmd('blockdev-del', node_name=3Dself.node)) + log(vm.cmd('blockdev-del', node_name=3Dself.file_node)) + log('') + + +def blockdev_mirror(vm, device, target, sync, **kwargs): + # Strip any arguments explicitly nulled by the caller: + kwargs =3D {key: val for key, val in kwargs.items() if val is not None} + result =3D vm.qmp_log('blockdev-mirror', + device=3Ddevice, + target=3Dtarget, + sync=3Dsync, + copy_mode=3D'write-blocking', + filter_node_name=3D'mirror-top', + **kwargs) + return result + +def blockdev_mirror_mktarget(drive, target_id, filepath, target_backing, s= ync, + **kwargs): + target_drive =3D Drive(filepath, vm=3Ddrive.vm) + target_drive.create_target(target_id, drive.fmt, drive.size, + target_backing) + result =3D blockdev_mirror(drive.vm, drive.node, target_id, sync, **kw= args) + assert result.get("error") is None + return target_drive + +def reference_mirror(drive, n, filepath): + log("--- Reference mirror #{:d} ---\n".format(n)) + target_id =3D "ref_target_{:d}".format(n) + job_id =3D "ref_mirror_{:d}".format(n) + target_drive =3D blockdev_mirror_mktarget(drive, target_id, filepath, = None, + "full", job_id=3Djob_id) + drive.vm.run_job(job_id, auto_dismiss=3DTrue) + log('') + target_drive.detach_target() + return target_drive + +def bitmap_sync_pre(drive, bitmap_sync, bitmap): + vm =3D drive.vm + log("--- Prepare bitmap for sync mode '{}' ---\n".format(bitmap_sync)) + if bitmap_sync in ('never', 'on-success'): + vm.qmp_log("block-dirty-bitmap-add", node=3Ddrive.node, + name=3D"mirror-bitmap", granularity=3DGRANULARITY) + vm.qmp_log("block-dirty-bitmap-merge", node=3Ddrive.node, + target=3D"mirror-bitmap", bitmaps=3D[bitmap]) + log('') + return "mirror-bitmap" + elif bitmap_sync =3D=3D 'always': + log("passing current bitmap '{}'\n".format(bitmap)) + return bitmap + else: + raise ValueError("unkown bitmap sync mode '{}'".format(bitmap_sync= )) + +def bitmap_sync_post(drive, bitmap_sync, bitmap, success): + vm =3D drive.vm + log("--- Post-process bitmap for sync mode '{}' ---\n".format(bitmap_s= ync)) + if bitmap_sync =3D=3D 'never': + vm.qmp_log("block-dirty-bitmap-remove", node=3Ddrive.node, + name=3D"mirror-bitmap") + log('') + return + elif bitmap_sync =3D=3D 'on-success': + if success: + vm.qmp_log("block-dirty-bitmap-clear", node=3Ddrive.node, + name=3Dbitmap) + vm.qmp_log("block-dirty-bitmap-merge", node=3Ddrive.node, + target=3Dbitmap, bitmaps=3D["mirror-bitmap"]) + vm.qmp_log("block-dirty-bitmap-remove", node=3Ddrive.node, + name=3D"mirror-bitmap") + log('') + return + elif bitmap_sync =3D=3D 'always': + log('nothing to do\n') + return + else: + raise ValueError("unkown bitmap sync mode '{}'".format(bitmap_sync= )) + +def mirror(drive, n, filepath, target_backing, sync, **kwargs): + log("--- Test mirror #{:d} ---\n".format(n)) + target_id =3D "mirror_target_{:d}".format(n) + job_id =3D "mirror_{:d}".format(n) + kwargs.setdefault('auto-finalize', False) + target_drive =3D blockdev_mirror_mktarget(drive, target_id, filepath, + target_backing, sync, + job_id=3Djob_id, **kwargs) + return (job_id, target_drive) + +def perform_writes(drive, n, filter_node_name=3DNone): + log("--- Write #{:d} ---\n".format(n)) + for pattern in GROUPS[n].patterns: + cmd =3D "write -P{:s} 0x{:07x} 0x{:x}".format( + pattern.byte, + pattern.offset, + pattern.size) + log(cmd) + log(drive.vm.hmp_qemu_io(filter_node_name or drive.node, cmd)) + bitmaps =3D drive.vm.query_bitmaps() + log({'bitmaps': bitmaps}, indent=3D2) + log('') + return bitmaps + + +def compare_images(image, reference, baseimg=3DNone, expected_match=3DTrue= ): + """ + Print a nice human-readable message comparing these images. + """ + expected_ret =3D 0 if expected_match else 1 + if baseimg: + qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, imag= e) + + sub =3D qemu_img("compare", image, reference, check=3DFalse) + + log('qemu_img compare "{:s}" "{:s}" =3D=3D> {:s}, {:s}'.format( + image, reference, + "Identical" if sub.returncode =3D=3D 0 else "Mismatch", + "OK!" if sub.returncode =3D=3D expected_ret else "ERROR!"), + filters=3D[iotests.filter_testfiles]) + +def test_bitmap_sync(bsync_mode, failure=3DNone): + """ + Test bitmap mirror routines. + + :param bsync_mode: Is the Bitmap Sync mode, and can be any of: + - on-success: This is the "incremental" style mode. Bitmaps are + synchronized to what was copied out only on success. + (Partial images must be discarded.) + - never: This is the "differential" style mode. + Bitmaps are never synchronized. + - always: This is a "best effort" style mode. + Bitmaps are always synchronized, regardless of failu= re. + (Partial images must be kept.) + + :param failure: Is the (optional) failure mode, and can be any of: + - None: No failure. Test the normative path. Default. + - simulated: Cancel the job right before it completes. + This also tests writes "during" the job. + - intermediate: This tests a job that fails mid-process and produc= es + an incomplete mirror. Testing limitations prevent + testing competing writes. + """ + with iotests.FilePath('img', 'bsync1', 'bsync2', 'bsync3', + 'fmirror0', 'fmirror1', 'fmirror2', 'fmirror3') = as \ + (img_path, bsync1, bsync2, bsync3, + fmirror0, fmirror1, fmirror2, fmirror3), \ + iotests.VM() as vm: + + mode =3D "Bitmap Sync {:s}".format(bsync_mode) + preposition =3D "with" if failure else "without" + cond =3D "{:s} {:s}".format(preposition, + "{:s} failure".format(failure) if failure + else "failure") + log("\n=3D=3D=3D {:s} {:s} =3D=3D=3D\n".format(mode, cond)) + + log('--- Preparing image & VM ---\n') + drive0 =3D Drive(img_path, vm=3Dvm) + drive0.img_create(iotests.imgfmt, SIZE) + vm.add_device("virtio-scsi,id=3Dscsi0") + vm.launch() + + file_config =3D { + 'driver': 'file', + 'filename': drive0.path + } + + if failure =3D=3D 'intermediate': + file_config =3D { + 'driver': 'blkdebug', + 'image': file_config, + 'set-state': [{ + 'event': 'flush_to_disk', + 'state': 1, + 'new_state': 2 + }, { + 'event': 'read_aio', + 'state': 2, + 'new_state': 3 + }, { + 'event': 'read_aio', + 'state': 3, + 'new_state': 4 + }], + 'inject-error': [{ + 'event': 'read_aio', + 'errno': 5, + 'state': 3, + 'immediately': False, + 'once': True + }, { + 'event': 'read_aio', + 'errno': 5, + 'state': 4, + 'immediately': False, + 'once': True + }] + } + + drive0.node =3D 'drive0' + vm.qmp_log('blockdev-add', + filters=3D[iotests.filter_qmp_testfiles], + node_name=3Ddrive0.node, + driver=3Ddrive0.fmt, + file=3Dfile_config) + log('') + + # 0 - Writes and Reference mirror + perform_writes(drive0, 0) + fmirror0_target =3D reference_mirror(drive0, 0, fmirror0) + log('--- Add Bitmap ---\n') + vm.qmp_log("block-dirty-bitmap-add", node=3Ddrive0.node, + name=3D"bitmap0", granularity=3DGRANULARITY) + log('') + ebitmap =3D EmulatedBitmap() + + # 1 - Writes and Reference mirror + bitmaps =3D perform_writes(drive0, 1) + ebitmap.dirty_group(1) + bitmap =3D vm.get_bitmap(drive0.node, 'bitmap0', bitmaps=3Dbitmaps) + ebitmap.compare(bitmap) + reference_mirror(drive0, 1, fmirror1) + + # 1 - Test mirror (w/ Optional induced failure) + if failure =3D=3D 'intermediate': + # Activate blkdebug induced failure for second-to-next read + log(vm.hmp_qemu_io(drive0.node, 'flush')) + log('') + mirror_bitmap =3D bitmap_sync_pre(drive0, bsync_mode, "bitmap0") + # First reference mirror is used as the inital base image + (job, bsync1_target) =3D mirror(drive0, 1, bsync1, fmirror0_target= .path, + 'full', bitmap=3Dmirror_bitmap) + + vm.run_job(job, auto_dismiss=3DTrue, auto_finalize=3DFalse, + cancel=3Dfailure =3D=3D 'simulated') + bsync1_target.detach_target() + bitmap_sync_post(drive0, bsync_mode, "bitmap0", not failure) + + bitmaps =3D vm.query_bitmaps() + log({'bitmaps': bitmaps}, indent=3D2) + log('') + + if bsync_mode =3D=3D 'always': + if failure =3D=3D 'intermediate': + # We manage to copy one sector (one bit) before the error. + ebitmap.clear_bit(ebitmap.first_bit) + else: + # successful mirror / cancelled complete mirror + ebitmap.clear() + + if bsync_mode =3D=3D 'on-success' and not failure: + ebitmap.clear() + + ebitmap.compare(vm.get_bitmap(drive0.node, 'bitmap0', bitmaps=3Dbi= tmaps)) + + # 2 - Reference mirror + reference_mirror(drive0, 2, fmirror2) + + # 2 - Bitmap mirror with writes before completion + mirror_bitmap =3D bitmap_sync_pre(drive0, bsync_mode, "bitmap0") + (job, bsync2_target) =3D mirror(drive0, 2, bsync2, bsync1_target.p= ath, + "full", bitmap=3Dmirror_bitmap) + + bitmaps =3D perform_writes(drive0, 2, filter_node_name=3D'mirror-t= op') + ebitmap.dirty_group(2) + + # Can't compare against bitmap0 if used as the mirror bitmap, beca= use + # mirror could already clear it. + if mirror_bitmap !=3D "bitmap0": + ebitmap.compare(vm.get_bitmap(drive0.node, "bitmap0", + bitmaps=3Dbitmaps)) + + # don't use run_job as that logs too much even with use_log=3DFalse + events =3D [('JOB_STATUS_CHANGE', {'data': {'id': job}})] + while True: + ev =3D iotests.filter_qmp_event(vm.events_wait(events, timeout= =3D10)) + status =3D ev['data']['status'] + if status =3D=3D 'ready': + vm.qmp('job-complete', id=3Djob) + elif status =3D=3D 'standby': + vm.qmp('job-resume', id=3Djob) + elif status =3D=3D 'pending': + vm.qmp('job-finalize', id=3Djob) + elif status =3D=3D 'null': + break + + bsync2_target.detach_target() + bitmap_sync_post(drive0, bsync_mode, "bitmap0", True) + + if bsync_mode !=3D 'never': + ebitmap.clear() + + bitmaps =3D vm.query_bitmaps() + ebitmap.compare(vm.get_bitmap(drive0.node, 'bitmap0', bitmaps=3Dbi= tmaps)) + + # 3 - Writes and Reference mirror + bitmaps =3D perform_writes(drive0, 3) + ebitmap.dirty_group(3) + ebitmap.compare(vm.get_bitmap(drive0.node, 'bitmap0', bitmaps=3Dbi= tmaps)) + reference_mirror(drive0, 3, fmirror3) + + # 3 - Bitmap mirror (In failure modes, this is a recovery.) + mirror_bitmap =3D bitmap_sync_pre(drive0, bsync_mode, "bitmap0") + (job, bsync3_target) =3D mirror(drive0, 3, bsync3, bsync2_target.p= ath, + "full", bitmap=3Dmirror_bitmap) + + vm.run_job(job, auto_dismiss=3DTrue, auto_finalize=3DFalse) + bsync3_target.detach_target() + bitmap_sync_post(drive0, bsync_mode, "bitmap0", True) + bitmaps =3D vm.query_bitmaps() + + log({'bitmaps': bitmaps}, indent=3D2) + log('') + if bsync_mode !=3D 'never': + ebitmap.clear() + ebitmap.compare(vm.get_bitmap(drive0.node, 'bitmap0', bitmaps=3Dbi= tmaps)) + + log('--- Cleanup ---\n') + vm.qmp_log("block-dirty-bitmap-remove", + node=3Ddrive0.node, name=3D"bitmap0") + bitmaps =3D vm.query_bitmaps() + log({'bitmaps': bitmaps}, indent=3D2) + vm.shutdown() + log('') + + log('--- Verification ---\n') + compare_images(bsync1, fmirror1, baseimg=3Dfmirror0, + expected_match=3Dfailure !=3D 'intermediate') + if not failure or bsync_mode =3D=3D 'always': + # Always keep the last mirror on success or when using 'always' + base =3D bsync1 + else: + base =3D fmirror1 + + compare_images(bsync2, fmirror2, baseimg=3Dbase, expected_match=3D= 0) + compare_images(bsync3, fmirror3, baseimg=3Dbsync2) + compare_images(img_path, fmirror3) + log('') + +def test_mirror_api(): + """ + Test malformed and prohibited invocations of the mirror API. + """ + with iotests.FilePath('img', 'bsync1') as \ + (img_path, mirror_path), \ + iotests.VM() as vm: + + log("\n=3D=3D=3D API failure tests =3D=3D=3D\n") + log('--- Preparing image & VM ---\n') + drive0 =3D Drive(img_path, vm=3Dvm) + drive0.img_create(iotests.imgfmt, SIZE) + vm.add_device("virtio-scsi,id=3Dscsi0") + vm.launch() + + file_config =3D { + 'driver': 'file', + 'filename': drive0.path + } + + drive0.node =3D 'drive0' + vm.qmp_log('blockdev-add', + filters=3D[iotests.filter_qmp_testfiles], + node_name=3Ddrive0.node, + driver=3Ddrive0.fmt, + file=3Dfile_config) + log('') + + target0 =3D Drive(mirror_path, vm=3Dvm) + target0.create_target("mirror_target", drive0.fmt, drive0.size, No= ne) + log('') + + vm.qmp_log("block-dirty-bitmap-add", node=3Ddrive0.node, + name=3D"bitmap0", granularity=3DGRANULARITY) + log('') + + log('-- Testing invalid QMP commands --\n') + + error_cases =3D { + 'full' : ['bitmap404'], + 'top' : ['bitmap404', 'bitmap0'], + 'none' : ['bitmap404', 'bitmap0'], + } + + # Dicts, as always, are not stably-ordered prior to 3.7, so use tu= ples: + for sync_mode in ('full', 'top', 'none'): + log("-- Sync mode {:s} tests --\n".format(sync_mode)) + for bitmap in error_cases[sync_mode]: + blockdev_mirror(drive0.vm, drive0.node, "mirror_target", + sync_mode, job_id=3D'api_job', + bitmap=3Dbitmap) + log('') + + +def main(): + for bsync_mode in ("never", "on-success", "always"): + for failure in ("simulated", "intermediate", None): + test_bitmap_sync(bsync_mode, failure) + + test_mirror_api() + +if __name__ =3D=3D '__main__': + iotests.script_main(main, supported_fmts=3D['qcow2'], + supported_protocols=3D['file']) diff --git a/tests/qemu-iotests/tests/mirror-bitmap.out b/tests/qemu-iotest= s/tests/mirror-bitmap.out new file mode 100644 index 0000000000..5c8acc1d69 --- /dev/null +++ b/tests/qemu-iotests/tests/mirror-bitmap.out @@ -0,0 +1,3191 @@ + +=3D=3D=3D Bitmap Sync never with simulated failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "targ= et": "mirror_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-cancel", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"id": "mirror_1", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "targ= et": "mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "mirror-bitmap", + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 655360, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 983040, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 15 dirty sectors; have 15. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "targ= et": "mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 983040, "offset": 983040, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 983040, "offset": 983040, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 983040, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 15 dirty sectors; have 15. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync never with intermediate failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "blkdebug", "image": {"driver": "file", "filename": "TEST_DIR/PID-img= "}, "inject-error": [{"errno": 5, "event": "read_aio", "immediately": false= , "once": true, "state": 3}, {"errno": 5, "event": "read_aio", "immediately= ": false, "once": true, "state": 4}], "set-state": [{"event": "flush_to_dis= k", "new-state": 2, "state": 1}, {"event": "read_aio", "new-state": 3, "sta= te": 2}, {"event": "read_aio", "new-state": 4, "state": 3}]}, "node-name": = "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +{"return": ""} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "targ= et": "mirror_target_1"}} +{"return": {}} +{"data": {"action": "report", "device": "mirror_1", "operation": "read"}, = "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds= ": "SECS"}} +{"data": {"action": "report", "device": "mirror_1", "operation": "read"}, = "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds= ": "SECS"}} +{"data": {"device": "mirror_1", "error": "Input/output error", "len": 3932= 16, "offset": 65536, "speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COM= PLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "targ= et": "mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "mirror-bitmap", + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 655360, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 983040, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 15 dirty sectors; have 15. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "targ= et": "mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 983040, "offset": 983040, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 983040, "offset": 983040, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 983040, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 15 dirty sectors; have 15. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync never without failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "targ= et": "mirror_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"id": "mirror_1", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "targ= et": "mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "mirror-bitmap", + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 655360, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 983040, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 15 dirty sectors; have 15. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "targ= et": "mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 983040, "offset": 983040, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 983040, "offset": 983040, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'never' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 983040, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 15 dirty sectors; have 15. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync on-success with simulated failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "targ= et": "mirror_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-cancel", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"id": "mirror_1", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "targ= et": "mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "mirror-bitmap", + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 655360, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 8 dirty sectors; have 8. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "targ= et": "mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync on-success with intermediate failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "blkdebug", "image": {"driver": "file", "filename": "TEST_DIR/PID-img= "}, "inject-error": [{"errno": 5, "event": "read_aio", "immediately": false= , "once": true, "state": 3}, {"errno": 5, "event": "read_aio", "immediately= ": false, "once": true, "state": 4}], "set-state": [{"event": "flush_to_dis= k", "new-state": 2, "state": 1}, {"event": "read_aio", "new-state": 3, "sta= te": 2}, {"event": "read_aio", "new-state": 4, "state": 3}]}, "node-name": = "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +{"return": ""} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "targ= et": "mirror_target_1"}} +{"return": {}} +{"data": {"action": "report", "device": "mirror_1", "operation": "read"}, = "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds= ": "SECS"}} +{"data": {"action": "report", "device": "mirror_1", "operation": "read"}, = "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds= ": "SECS"}} +{"data": {"device": "mirror_1", "error": "Input/output error", "len": 3932= 16, "offset": 65536, "speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COM= PLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "targ= et": "mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "mirror-bitmap", + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 655360, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 10 dirty sectors; have 10. OK! + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 8 dirty sectors; have 8. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "targ= et": "mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync on-success without failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "targ= et": "mirror_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"id": "mirror_1", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "targ= et": "mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "mirror-bitmap", + "persistent": false, + "recording": false + }, + { + "busy": false, + "count": 458752, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 7 dirty sectors; have 7. OK! + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 8 dirty sectors; have 8. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "mirror-bitmap", "node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["bitmap0= "], "node": "drive0", "target": "mirror-bitmap"}} +{"return": {}} + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "mirror-bitmap", "copy-mode": "write-blocking", "device": "drive0", "f= ilter-node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "targ= et": "mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'on-success' --- + +{"execute": "block-dirty-bitmap-clear", "arguments": {"name": "bitmap0", "= node": "drive0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-merge", "arguments": {"bitmaps": ["mirror-= bitmap"], "node": "drive0", "target": "bitmap0"}} +{"return": {}} +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "mirror-bit= map", "node": "drive0"}} +{"return": {}} + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync always with simulated failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "target": "= mirror_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-cancel", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"id": "mirror_1", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "target": "= mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": false + } + ] + } +} + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 8 dirty sectors; have 8. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "target": "= mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync always with intermediate failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "blkdebug", "image": {"driver": "file", "filename": "TEST_DIR/PID-img= "}, "inject-error": [{"errno": 5, "event": "read_aio", "immediately": false= , "once": true, "state": 3}, {"errno": 5, "event": "read_aio", "immediately= ": false, "once": true, "state": 4}], "set-state": [{"event": "flush_to_dis= k", "new-state": 2, "state": 1}, {"event": "read_aio", "new-state": 3, "sta= te": 2}, {"event": "read_aio", "new-state": 4, "state": 3}]}, "node-name": = "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +{"return": ""} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "target": "= mirror_target_1"}} +{"return": {}} +{"data": {"action": "report", "device": "mirror_1", "operation": "read"}, = "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds= ": "SECS"}} +{"data": {"action": "report", "device": "mirror_1", "operation": "read"}, = "event": "BLOCK_JOB_ERROR", "timestamp": {"microseconds": "USECS", "seconds= ": "SECS"}} +{"data": {"device": "mirror_1", "error": "Input/output error", "len": 3932= 16, "offset": 65536, "speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COM= PLETED", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 327680, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 5 dirty sectors; have 5. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "target": "= mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": false + } + ] + } +} + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 8 dirty sectors; have 8. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "target": "= mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D Bitmap Sync always without failure =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +--- Write #0 --- + +write -P0x49 0x0000000 0x10000 +{"return": ""} +write -P0x6c 0x0100000 0x10000 +{"return": ""} +write -P0x6f 0x2000000 0x10000 +{"return": ""} +write -P0x76 0x3ff0000 0x10000 +{"return": ""} +{ + "bitmaps": {} +} + +--- Reference mirror #0 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_0", "sync": "full", "target": "ref_target_0"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_0"}} +{"return": {}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_0", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_0 --- +{} +{} + +--- Add Bitmap --- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +--- Write #1 --- + +write -P0x65 0x0000000 0x10000 +{"return": ""} +write -P0x77 0x00f8000 0x10000 +{"return": ""} +write -P0x72 0x2008000 0x10000 +{"return": ""} +write -P0x69 0x3fe0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 393216, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 6 dirty sectors; have 6. OK! + +--- Reference mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_1", "sync": "full", "target": "ref_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_1"}} +{"return": {}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_1", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_1 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #1 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_1", "sync": "full", "target": "= mirror_target_1"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_1"}} +{"return": {}} +{"data": {"id": "mirror_1", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_1", "len": 393216, "offset": 393216, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_1 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Reference mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_2", "sync": "full", "target": "ref_target_2"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_2"}} +{"return": {}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_2", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_2 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #2 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_2", "sync": "full", "target": "= mirror_target_2"}} +{"return": {}} +--- Write #2 --- + +write -P0x74 0x0010000 0x10000 +{"return": ""} +write -P0x69 0x00e8000 0x10000 +{"return": ""} +write -P0x6e 0x2018000 0x10000 +{"return": ""} +write -P0x67 0x3fe0000 0x20000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": true, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": false + } + ] + } +} + +--- Detaching mirror_target_2 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Write #3 --- + +write -P0xaa 0x0010000 0x30000 +{"return": ""} +write -P0xbb 0x00d8000 0x10000 +{"return": ""} +write -P0xcc 0x2028000 0x10000 +{"return": ""} +write -P0xdd 0x3fc0000 0x10000 +{"return": ""} +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 524288, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 8 dirty sectors; have 8. OK! + +--- Reference mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"copy-mode": "write-blocking"= , "device": "drive0", "filter-node-name": "mirror-top", "job-id": "ref_mirr= or_3", "sync": "full", "target": "ref_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "ref_mirror_3"}} +{"return": {}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"mi= croseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "ref_mirror_3", "len": 67108864, "offset": 67108864, "= speed": 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": = {"microseconds": "USECS", "seconds": "SECS"}} + +--- Detaching ref_target_3 --- +{} +{} + +--- Prepare bitmap for sync mode 'always' --- + +passing current bitmap 'bitmap0' + +--- Test mirror #3 --- + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} +{"execute": "blockdev-mirror", "arguments": {"auto-finalize": false, "bitm= ap": "bitmap0", "copy-mode": "write-blocking", "device": "drive0", "filter-= node-name": "mirror-top", "job-id": "mirror_3", "sync": "full", "target": "= mirror_target_3"}} +{"return": {}} +{"execute": "job-complete", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_READY", "timestamp": {"microsecon= ds": "USECS", "seconds": "SECS"}} +{"execute": "job-finalize", "arguments": {"id": "mirror_3"}} +{"return": {}} +{"data": {"id": "mirror_3", "type": "mirror"}, "event": "BLOCK_JOB_PENDING= ", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}} +{"data": {"device": "mirror_3", "len": 524288, "offset": 524288, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_COMPLETED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +--- Detaching mirror_target_3 --- +{} +{} + +--- Post-process bitmap for sync mode 'always' --- + +nothing to do + +{ + "bitmaps": { + "drive0": [ + { + "busy": false, + "count": 0, + "granularity": 65536, + "name": "bitmap0", + "persistent": false, + "recording": true + } + ] + } +} + +=3D Checking Bitmap bitmap0 =3D +expecting 0 dirty sectors; have 0. OK! + +--- Cleanup --- + +{"execute": "block-dirty-bitmap-remove", "arguments": {"name": "bitmap0", = "node": "drive0"}} +{"return": {}} +{ + "bitmaps": {} +} + +--- Verification --- + +qemu_img compare "TEST_DIR/PID-bsync1" "TEST_DIR/PID-fmirror1" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-bsync2" "TEST_DIR/PID-fmirror2" =3D=3D> Mis= match, OK! +qemu_img compare "TEST_DIR/PID-bsync3" "TEST_DIR/PID-fmirror3" =3D=3D> Ide= ntical, OK! +qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fmirror3" =3D=3D> Identi= cal, OK! + + +=3D=3D=3D API failure tests =3D=3D=3D + +--- Preparing image & VM --- + +{"execute": "blockdev-add", "arguments": {"driver": "qcow2", "file": {"dri= ver": "file", "filename": "TEST_DIR/PID-img"}, "node-name": "drive0"}} +{"return": {}} + +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-file-job"}} +{"return": {}} +{} +{} +{"execute": "job-dismiss", "arguments": {"id": "bdc-fmt-job"}} +{"return": {}} +{} + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap0", "node": "drive0"}} +{"return": {}} + +-- Testing invalid QMP commands -- + +-- Sync mode full tests -- + +{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "copy-= mode": "write-blocking", "device": "drive0", "filter-node-name": "mirror-to= p", "job-id": "api_job", "sync": "full", "target": "mirror_target"}} +{"error": {"class": "GenericError", "desc": "Dirty bitmap 'bitmap404' not = found"}} + +-- Sync mode top tests -- + +{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "copy-= mode": "write-blocking", "device": "drive0", "filter-node-name": "mirror-to= p", "job-id": "api_job", "sync": "top", "target": "mirror_target"}} +{"error": {"class": "GenericError", "desc": "Sync mode 'top' not supported= with bitmap."}} + +{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "copy-mo= de": "write-blocking", "device": "drive0", "filter-node-name": "mirror-top"= , "job-id": "api_job", "sync": "top", "target": "mirror_target"}} +{"error": {"class": "GenericError", "desc": "Sync mode 'top' not supported= with bitmap."}} + +-- Sync mode none tests -- + +{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap404", "copy-= mode": "write-blocking", "device": "drive0", "filter-node-name": "mirror-to= p", "job-id": "api_job", "sync": "none", "target": "mirror_target"}} +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supporte= d with bitmap."}} + +{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "copy-mo= de": "write-blocking", "device": "drive0", "filter-node-name": "mirror-top"= , "job-id": "api_job", "sync": "none", "target": "mirror_target"}} +{"error": {"class": "GenericError", "desc": "Sync mode 'none' not supporte= d with bitmap."}} + --=20 2.39.2 From nobody Mon Nov 25 09:50:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347151842884.3925952621789; Fri, 10 May 2024 06:19:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q7j-0005Z6-Bz; Fri, 10 May 2024 09:17:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7a-0005VQ-LV; Fri, 10 May 2024 09:17:12 -0400 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s5Q7T-0002AT-RP; Fri, 10 May 2024 09:17:08 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 72A22473D9; Fri, 10 May 2024 15:16:53 +0200 (CEST) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, armbru@redhat.com, eblake@redhat.com, hreitz@redhat.com, kwolf@redhat.com, vsementsov@yandex-team.ru, jsnow@redhat.com, f.gruenbichler@proxmox.com, t.lamprecht@proxmox.com, mahaocong@didichuxing.com, xiechanglong.d@gmail.com, wencongyang2@huawei.com Subject: [PATCH v3 5/5] blockdev: mirror: check for target's cluster size when using bitmap Date: Fri, 10 May 2024 15:16:47 +0200 Message-Id: <20240510131647.1256467-6-f.ebner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240510131647.1256467-1-f.ebner@proxmox.com> References: <20240510131647.1256467-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1715347153875100003 Content-Type: text/plain; charset="utf-8" When using mirror with a bitmap and the target does not do COW and is is a diff image, i.e. one that should only contain the delta and was not synced to previously, a too large cluster size for the target can be problematic. In particular, when the mirror sends data to the target aligned to the jobs granularity, but not aligned to the larger target image's cluster size, the target's cluster would be allocated but only be filled partially. When rebasing such a diff image later, the corresponding cluster of the base image would get "masked" and the part of the cluster not in the diff image is not accessible anymore. Unfortunately, it is not always possible to check for the target image's cluster size, e.g. when it's NBD. Because the limitation is already documented in the QAPI description for the @bitmap parameter and it's only required for special diff image use-case, simply skip the check then. Signed-off-by: Fiona Ebner --- Changes in v3: * detect when the target does COW and do not error out in that case * treat ENOTSUP differently from other failure when querying the cluster size blockdev.c | 57 ++++++++++++++++++++++ tests/qemu-iotests/tests/mirror-bitmap | 6 +++ tests/qemu-iotests/tests/mirror-bitmap.out | 7 +++ 3 files changed, 70 insertions(+) diff --git a/blockdev.c b/blockdev.c index 4f72a72dc7..468974108e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2769,6 +2769,59 @@ void qmp_blockdev_backup(BlockdevBackup *backup, Err= or **errp) blockdev_do_action(&action, errp); } =20 +static int blockdev_mirror_check_bitmap_granularity(BlockDriverState *targ= et, + BdrvDirtyBitmap *bitma= p, + Error **errp) +{ + int ret; + BlockDriverInfo bdi; + uint32_t bitmap_granularity; + + GLOBAL_STATE_CODE(); + GRAPH_RDLOCK_GUARD_MAINLOOP(); + + if (bdrv_backing_chain_next(target)) { + /* + * No need to worry about creating clusters with partial data when= the + * target does COW. + */ + return 0; + } + + /* + * If there is no backing file on the target, we cannot rely on COW if= our + * backup cluster size is smaller than the target cluster size. Even f= or + * targets with a backing file, try to avoid COW if possible. + */ + ret =3D bdrv_get_info(target, &bdi); + if (ret =3D=3D -ENOTSUP) { + /* + * Ignore if unable to get the info, e.g. when target is NBD. It's= only + * relevant for syncing to a diff image and the documentation alre= ady + * states that the target's cluster size needs to small enough the= n. + */ + return 0; + } else if (ret < 0) { + error_setg_errno(errp, -ret, + "Couldn't determine the cluster size of the target image, " + "which has no backing file"); + return ret; + } + + bitmap_granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + if (bitmap_granularity < bdi.cluster_size || + bitmap_granularity % bdi.cluster_size !=3D 0) { + error_setg(errp, "Bitmap granularity %u is not a multiple of the " + "target image's cluster size %u and the target image ha= s " + "no backing file", + bitmap_granularity, bdi.cluster_size); + return -EINVAL; + } + + return 0; +} + + /* Parameter check and block job starting for drive mirroring. * Caller should hold @device and @target's aio context (must be the same). **/ @@ -2863,6 +2916,10 @@ static void blockdev_mirror_common(const char *job_i= d, BlockDriverState *bs, return; } =20 + if (blockdev_mirror_check_bitmap_granularity(target, bitmap, errp)= ) { + return; + } + if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) { return; } diff --git a/tests/qemu-iotests/tests/mirror-bitmap b/tests/qemu-iotests/te= sts/mirror-bitmap index 37bbe0f241..e8cd482a19 100755 --- a/tests/qemu-iotests/tests/mirror-bitmap +++ b/tests/qemu-iotests/tests/mirror-bitmap @@ -584,6 +584,12 @@ def test_mirror_api(): bitmap=3Dbitmap) log('') =20 + log("-- Test bitmap with too small granularity to non-COW target -= -\n") + vm.qmp_log("block-dirty-bitmap-add", node=3Ddrive0.node, + name=3D"bitmap-small", granularity=3DGRANULARITY) + blockdev_mirror(drive0.vm, drive0.node, "mirror_target", "full", + job_id=3D'api_job', bitmap=3D"bitmap-small") + log('') =20 def main(): for bsync_mode in ("never", "on-success", "always"): diff --git a/tests/qemu-iotests/tests/mirror-bitmap.out b/tests/qemu-iotest= s/tests/mirror-bitmap.out index 5c8acc1d69..af605f3803 100644 --- a/tests/qemu-iotests/tests/mirror-bitmap.out +++ b/tests/qemu-iotests/tests/mirror-bitmap.out @@ -3189,3 +3189,10 @@ qemu_img compare "TEST_DIR/PID-img" "TEST_DIR/PID-fm= irror3" =3D=3D> Identical, OK! {"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap0", "copy-mo= de": "write-blocking", "device": "drive0", "filter-node-name": "mirror-top"= , "job-id": "api_job", "sync": "none", "target": "mirror_target"}} {"error": {"class": "GenericError", "desc": "Sync mode 'none' not supporte= d with bitmap."}} =20 +-- Test bitmap with too small granularity to non-COW target -- + +{"execute": "block-dirty-bitmap-add", "arguments": {"granularity": 65536, = "name": "bitmap-small", "node": "drive0"}} +{"return": {}} +{"execute": "blockdev-mirror", "arguments": {"bitmap": "bitmap-small", "co= py-mode": "write-blocking", "device": "drive0", "filter-node-name": "mirror= -top", "job-id": "api_job", "sync": "full", "target": "mirror_target"}} +{"error": {"class": "GenericError", "desc": "Bitmap granularity 65536 is n= ot a multiple of the target image's cluster size 131072 and the target imag= e has no backing file"}} + --=20 2.39.2