From nobody Sat May 18 23:14:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613151428; cv=none; d=zohomail.com; s=zohoarc; b=bt9krIZwaQ/6kMYrworqeu3yd/e1BSxo3TCKR7YxhKnKhbnAz3A6Xxg9LCB5P7ASgmUj3rFuIZVudr/zKp7GLl1Xvjt9uK9/P+QLEWfw/K8t3jvC5q4KluNN9oTbHcJsTOiqLyc8amidYWbdmL9mpR0yCdMULW9j/1uNwLcGfjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613151428; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TO4BQumFIl7/aAYl141t0YbKuoSPET1RIML/rjIZeyU=; b=i2oIpSib/gOiUFJS5lygooanyBhaJcokAABItJzQ8BQKXPagrSM+RV3AcRFGrekewQmky9oP0o9oTZUOmhhB7jmidB2DVYkEfOnep34GbiYyMrMmqWxlgo0iV1akOhVqQlFsBZm0Fc10+UWIhZcPmBzDNhmGp8ERiYRQkSYoCks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613151428175764.3822279778533; Fri, 12 Feb 2021 09:37:08 -0800 (PST) Received: from localhost ([::1]:59760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAcNP-0001Bj-8z for importer@patchew.org; Fri, 12 Feb 2021 12:37:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAcL1-0007S3-Jm for qemu-devel@nongnu.org; Fri, 12 Feb 2021 12:34:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lAcKw-0005kX-K5 for qemu-devel@nongnu.org; Fri, 12 Feb 2021 12:34:39 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-JXDTqZ5qNWyCDdA5HFiQAA-1; Fri, 12 Feb 2021 12:34:31 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86307801977; Fri, 12 Feb 2021 17:34:30 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 308295C3E0; Fri, 12 Feb 2021 17:34:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613151273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TO4BQumFIl7/aAYl141t0YbKuoSPET1RIML/rjIZeyU=; b=N7YkJZS2Kpk7JLLFEiIHJ5inbAaWKhEAHqfQhqlSaD1ba36jmOOfHaudc4JrMq25UG4K6y vAM74eZ3wi0Z+GMnknlOsgY+Wvkp6DnYpAXOsSD7HzE7+uKr0C6/pSJH9D4h7D+xfICrIP QP8uafaXxkj1gtGtFHjMmCCkzjtdSrw= X-MC-Unique: JXDTqZ5qNWyCDdA5HFiQAA-1 From: Peter Krempa To: qemu-devel@nongnu.org Subject: [PATCH v3 1/3] migration: dirty-bitmap: Convert alias map inner members to BitmapMigrationBitmapAlias Date: Fri, 12 Feb 2021 18:34:23 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pkrempa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.569, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Currently the alias mapping hash stores just strings of the target objects internally. In further patches we'll be adding another member which will need to be stored in the map so pass a copy of the whole BitmapMigrationBitmapAlias QAPI struct into the map. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- migration/block-dirty-bitmap.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) Note that there's a very long line but there doesn't seem to be a sensible point where to break it. v3: - use a copy of BitmapMigrationBitmapAlias QAPI sctruct to do the mapping - dropped R-b's because the above is a significant change v2: - NULL-check in freeing function (Eric) - style problems (Vladimir) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index c61d382be8..0244f9bb1d 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -75,6 +75,8 @@ #include "qemu/id.h" #include "qapi/error.h" #include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-visit-migration.h" +#include "qapi/clone-visitor.h" #include "trace.h" #define CHUNK_SIZE (1 << 10) @@ -263,8 +265,8 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, node_map_to =3D bmna->node_name; } - bitmaps_map =3D g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, g_free); + bitmaps_map =3D g_hash_table_new_full(g_str_hash, g_str_equal, g_f= ree, + (GDestroyNotify) qapi_free_Bit= mapMigrationBitmapAlias); amin =3D g_new(AliasMapInnerNode, 1); *amin =3D (AliasMapInnerNode){ @@ -276,7 +278,7 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, for (bmbal =3D bmna->bitmaps; bmbal; bmbal =3D bmbal->next) { const BitmapMigrationBitmapAlias *bmba =3D bmbal->value; - const char *bmap_map_from, *bmap_map_to; + const char *bmap_map_from; if (strlen(bmba->alias) > UINT8_MAX) { error_setg(errp, @@ -293,7 +295,6 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, if (name_to_alias) { bmap_map_from =3D bmba->name; - bmap_map_to =3D bmba->alias; if (g_hash_table_contains(bitmaps_map, bmba->name)) { error_setg(errp, "The bitmap '%s'/'%s' is mapped twice= ", @@ -302,7 +303,6 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, } } else { bmap_map_from =3D bmba->alias; - bmap_map_to =3D bmba->name; if (g_hash_table_contains(bitmaps_map, bmba->alias)) { error_setg(errp, "The bitmap alias '%s'/'%s' is used t= wice", @@ -312,7 +312,8 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, } g_hash_table_insert(bitmaps_map, - g_strdup(bmap_map_from), g_strdup(bmap_map= _to)); + g_strdup(bmap_map_from), + QAPI_CLONE(BitmapMigrationBitmapAlias, bmb= a)); } } @@ -538,11 +539,15 @@ static int add_bitmaps_to_list(DBMSaveState *s, Block= DriverState *bs, } if (bitmap_aliases) { - bitmap_alias =3D g_hash_table_lookup(bitmap_aliases, bitmap_na= me); - if (!bitmap_alias) { + BitmapMigrationBitmapAlias *bmap_inner; + + bmap_inner =3D g_hash_table_lookup(bitmap_aliases, bitmap_name= ); + if (!bmap_inner) { /* Skip bitmaps with no alias */ continue; } + + bitmap_alias =3D bmap_inner->alias; } else { if (strlen(bitmap_name) > UINT8_MAX) { error_report("Cannot migrate bitmap '%s' on node '%s': " @@ -1074,13 +1079,16 @@ static int dirty_bitmap_load_header(QEMUFile *f, DB= MLoadState *s, bitmap_name =3D s->bitmap_alias; if (!s->cancelled && bitmap_alias_map) { - bitmap_name =3D g_hash_table_lookup(bitmap_alias_map, - s->bitmap_alias); - if (!bitmap_name) { + BitmapMigrationBitmapAlias *bmap_inner; + + bmap_inner =3D g_hash_table_lookup(bitmap_alias_map, s->bitmap= _alias); + if (!bmap_inner) { error_report("Error: Unknown bitmap alias '%s' on node " "'%s' (alias '%s')", s->bitmap_alias, s->bs->node_name, s->node_alias); cancel_incoming_locked(s); + } else { + bitmap_name =3D bmap_inner->name; } } --=20 2.29.2 From nobody Sat May 18 23:14:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613151435; cv=none; d=zohomail.com; s=zohoarc; b=EZoSJocKod+Szy337pbQM2vKZ4ki8oD/K3oX3S0lTyFxzh8VfSWPvY/dTtR+mb/4XtZtLaZcrdcp5sU5vkPqY1UN5R77GZ8/sxgfOi7A3Q0kmFk7wurqvmfyjeYf5H4clTktOVVNS0wIySFKEPcRM7vDUfPHJykFSkpvlQO/fBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613151435; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yPBtbkYzBVGUiNvomTzlUjJ6P/WKBXin0NxArowiHXY=; b=gmGqpwoFjx+fj0bTlR2qQBuFi0r8ZVAuYzG9qv8TalOjln3xJA7BHrRsssEhHyfMmf8a+K90fLcZ8UqX2005vg3ebFH95uTqWHtUNCPWb65KZ6yD/D6aFWgionD0vk/rXafz0TFYv20m9iEkWFW8Y0yb6vPcLswWi7GLDcF+EQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613151435212426.75314924355246; Fri, 12 Feb 2021 09:37:15 -0800 (PST) Received: from localhost ([::1]:59828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAcNW-0001Da-Fs for importer@patchew.org; Fri, 12 Feb 2021 12:37:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAcL3-0007Uf-J3 for qemu-devel@nongnu.org; Fri, 12 Feb 2021 12:34:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lAcKy-0005lI-GM for qemu-devel@nongnu.org; Fri, 12 Feb 2021 12:34:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500-W6-JZt4GP_qiYS9WLQVCnQ-1; Fri, 12 Feb 2021 12:34:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3461DC282; Fri, 12 Feb 2021 17:34:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E960D5C23D; Fri, 12 Feb 2021 17:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613151275; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yPBtbkYzBVGUiNvomTzlUjJ6P/WKBXin0NxArowiHXY=; b=Vi0DBoW8atCoothSGm0RTb6ZxcCi/lfej8w4utjwEhrun8GyBmz0s/wq8cQjFoc8hiVToZ FH0cwTR5LKTtAjLCISCXgksLl3lLkqS3RAmWllMfyMkidji/eyVwm9EHLqPAt0Ihh0Uh6b c9sR/zUc2o2yjfAmw/lGC/VvqcEYt5c= X-MC-Unique: W6-JZt4GP_qiYS9WLQVCnQ-1 From: Peter Krempa To: qemu-devel@nongnu.org Subject: [PATCH v3 2/3] migration: dirty-bitmap: Allow control of bitmap persistence Date: Fri, 12 Feb 2021 18:34:24 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pkrempa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.569, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Bitmap's source persistence is transported over the migration stream and the destination mirrors it. In some cases the destination might want to persist bitmaps which are not persistent on the source (e.g. the result of merge of bitmaps from a number of layers on the source when migrating into a squashed image) but currently it would need to create another set of persistent bitmaps and merge them. This patch adds a 'transform' property to the alias map which allows to override the persistence of migrated bitmaps both on the source and destination sides. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- migration/block-dirty-bitmap.c | 30 +++++++++++++++++++++++++++--- qapi/migration.json | 19 ++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) v3: - adapted to full passtrhough of BitmapMigrationBitmapAlias into the map hash table (Vladimir) - schema and commit message language fixes (Eric) v2: - grammar fixes (Eric) - added 'transform' object to group other possible transformations (Vladim= ir) - transformation can also be used on source (Vladimir) - put bmap_inner directly into DBMLoadState for deduplication (Vladimir) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 0244f9bb1d..80781de5d8 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -150,6 +150,7 @@ typedef struct DBMLoadState { BdrvDirtyBitmap *bitmap; bool before_vm_start_handled; /* set in dirty_bitmap_mig_before_vm_sta= rt */ + BitmapMigrationBitmapAlias *bmap_inner; /* * cancelled @@ -528,6 +529,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, } FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + BitmapMigrationBitmapAliasTransform *bitmap_transform =3D NULL; bitmap_name =3D bdrv_dirty_bitmap_name(bitmap); if (!bitmap_name) { continue; @@ -548,6 +550,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, } bitmap_alias =3D bmap_inner->alias; + if (bmap_inner->has_transform) { + bitmap_transform =3D bmap_inner->transform; + } } else { if (strlen(bitmap_name) > UINT8_MAX) { error_report("Cannot migrate bitmap '%s' on node '%s': " @@ -573,8 +578,15 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockD= riverState *bs, if (bdrv_dirty_bitmap_enabled(bitmap)) { dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_ENABLED; } - if (bdrv_dirty_bitmap_get_persistence(bitmap)) { - dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT; + if (bitmap_transform && + bitmap_transform->has_persistent) { + if (bitmap_transform->persistent) { + dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT; + } + } else { + if (bdrv_dirty_bitmap_get_persistence(bitmap)) { + dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT; + } } QSIMPLEQ_INSERT_TAIL(&s->dbms_list, dbms, entry); @@ -782,6 +794,7 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoad= State *s) uint32_t granularity =3D qemu_get_be32(f); uint8_t flags =3D qemu_get_byte(f); LoadBitmapState *b; + bool persistent; if (s->cancelled) { return 0; @@ -806,7 +819,16 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoa= dState *s) return -EINVAL; } - if (flags & DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT) { + if (s->bmap_inner && + s->bmap_inner->has_transform && + s->bmap_inner->transform && + s->bmap_inner->transform->has_persistent) { + persistent =3D s->bmap_inner->transform->persistent; + } else { + persistent =3D flags & DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT; + } + + if (persistent) { bdrv_dirty_bitmap_set_persistence(s->bitmap, true); } @@ -1090,6 +1112,8 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBML= oadState *s, } else { bitmap_name =3D bmap_inner->name; } + + s->bmap_inner =3D bmap_inner; } if (!s->cancelled) { diff --git a/qapi/migration.json b/qapi/migration.json index ce14d78071..8a85a6d041 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -536,6 +536,19 @@ 'data': [ 'none', 'zlib', { 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] } +## +# @BitmapMigrationBitmapAliasTransform: +# +# @persistent: If present, the bitmap will be made persistent +# or transient depending on this parameter. +# +# Since: 6.0 +## +{ 'struct': 'BitmapMigrationBitmapAliasTransform', + 'data': { + '*persistent': 'bool' + } } + ## # @BitmapMigrationBitmapAlias: # @@ -544,12 +557,16 @@ # @alias: An alias name for migration (for example the bitmap name on # the opposite site). # +# @transform: Allows to modify properties of the migrated bitmap. +# (since 6.0) +# # Since: 5.2 ## { 'struct': 'BitmapMigrationBitmapAlias', 'data': { 'name': 'str', - 'alias': 'str' + 'alias': 'str', + '*transform': 'BitmapMigrationBitmapAliasTransform' } } ## --=20 2.29.2 From nobody Sat May 18 23:14:44 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613151459; cv=none; d=zohomail.com; s=zohoarc; b=icJIxJglT+6KKFXs5MqWBonom5go22ucirs3rLwKyFdFyxvdze900Ov+38NJPJVAn2aADClZrio7ScMuKamkxXxUFrjnk4gLnoNbADgTGB+WBLwSRPw2YXTJoQxhbDB27VMv4j+4Xlzxdsm/lTN81R9kaFHtDBhJ8rCUhhQI280= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613151459; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PJhYx9mR3cgdynjG+SxzoRa+zGx4gUR64+nUb3i0FPU=; b=F0c7HR38I+RHHisumdrwU7HQHLaPF6/j+pu15vKKXBsog8FIoMSDga0dHDmZGn+QG5Y10JwG+QpxzezpLyN+vhehpiMp0xzGA8lcNV7HRfv89pQmEScmv+pzOO/E2rtujaZghkJxICeczdogz5A3B7xJ7mLesaeEG5Hr6c2RT2M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613151459370466.18435509504377; Fri, 12 Feb 2021 09:37:39 -0800 (PST) Received: from localhost ([::1]:60380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAcNs-0001Rj-8Z for importer@patchew.org; Fri, 12 Feb 2021 12:37:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAcL4-0007WI-2o for qemu-devel@nongnu.org; Fri, 12 Feb 2021 12:34:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lAcL2-0005mf-Eb for qemu-devel@nongnu.org; Fri, 12 Feb 2021 12:34:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-b6bT18tvOPaNSLGMrETOCg-1; Fri, 12 Feb 2021 12:34:36 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0789E1936B60; Fri, 12 Feb 2021 17:34:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D4555C3E0; Fri, 12 Feb 2021 17:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613151279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PJhYx9mR3cgdynjG+SxzoRa+zGx4gUR64+nUb3i0FPU=; b=PIzHnCx4lB64BW8lT818DQ8x1A0HJNMO4XSNRzRPBPSOABaxn+NSIEPR0kaJ+GSQSR5vn4 4ow1iEuKHbr9fi+lXRC+9fxwTtmEZkoXxx/zFTPrJ6OhKrSbdrM8lS/PA8ltFWa1WpGNFf 3E6VXh2KnC4DHDywE0HAC32I7uTSpVY= X-MC-Unique: b6bT18tvOPaNSLGMrETOCg-1 From: Peter Krempa To: qemu-devel@nongnu.org Subject: [PATCH v3 3/3] qemu-iotests: 300: Add test case for modifying persistence of bitmap Date: Fri, 12 Feb 2021 18:34:25 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pkrempa@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.569, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Verify that the modification of the bitmap persistence over migration which is controlled via BitmapMigrationBitmapAliasTransform works properly. Based on TestCrossAliasMigration Signed-off-by: Peter Krempa --- tests/qemu-iotests/300 | 91 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/300.out | 4 +- 2 files changed, 93 insertions(+), 2 deletions(-) v3: new in series diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300 index 43264d883d..9d4ec6a381 100755 --- a/tests/qemu-iotests/300 +++ b/tests/qemu-iotests/300 @@ -600,6 +600,97 @@ class TestCrossAliasMigration(TestDirtyBitmapMigration= ): self.verify_dest_has_all_bitmaps() self.verify_dest_error(None) +class TestAliasTransformMigration(TestDirtyBitmapMigration): + """ + Tests the 'transform' option which modifies bitmap persistence on migr= ation. + """ + + src_node_name =3D 'node-a' + dst_node_name =3D 'node-b' + src_bmap_name =3D 'bmap-a' + dst_bmap_name =3D 'bmap-b' + + def setUp(self) -> None: + TestDirtyBitmapMigration.setUp(self) + + # Now create another block device and let both have two bitmaps ea= ch + result =3D self.vm_a.qmp('blockdev-add', + node_name=3D'node-b', driver=3D'null-co') + self.assert_qmp(result, 'return', {}) + + result =3D self.vm_b.qmp('blockdev-add', + node_name=3D'node-a', driver=3D'null-co') + self.assert_qmp(result, 'return', {}) + + bmaps_to_add =3D (('node-a', 'bmap-b'), + ('node-b', 'bmap-a'), + ('node-b', 'bmap-b')) + + for (node, bmap) in bmaps_to_add: + result =3D self.vm_a.qmp('block-dirty-bitmap-add', + node=3Dnode, name=3Dbmap) + self.assert_qmp(result, 'return', {}) + + @staticmethod + def transform_mapping() -> BlockBitmapMapping: + return [ + { + 'node-name': 'node-a', + 'alias': 'node-a', + 'bitmaps': [ + { + 'name': 'bmap-a', + 'alias': 'bmap-a', + 'transform': + { + 'persistent': True + } + }, + { + 'name': 'bmap-b', + 'alias': 'bmap-b' + } + ] + }, + { + 'node-name': 'node-b', + 'alias': 'node-b', + 'bitmaps': [ + { + 'name': 'bmap-a', + 'alias': 'bmap-a' + }, + { + 'name': 'bmap-b', + 'alias': 'bmap-b' + } + ] + } + ] + + def verify_dest_bitmap_state(self) -> None: + bitmaps =3D self.vm_b.query_bitmaps() + + for node in bitmaps: + bitmaps[node] =3D sorted(((bmap['name'], bmap['persistent']) f= or bmap in bitmaps[node])) + + self.assertEqual(bitmaps, + {'node-a': [('bmap-a', True), ('bmap-b', False)], + 'node-b': [('bmap-a', False), ('bmap-b', False)]= }) + + def test_transform_on_src(self) -> None: + self.set_mapping(self.vm_a, self.transform_mapping()) + + self.migrate() + self.verify_dest_bitmap_state() + self.verify_dest_error(None) + + def test_transform_on_dst(self) -> None: + self.set_mapping(self.vm_b, self.transform_mapping()) + + self.migrate() + self.verify_dest_bitmap_state() + self.verify_dest_error(None) if __name__ =3D=3D '__main__': iotests.main(supported_protocols=3D['file']) diff --git a/tests/qemu-iotests/300.out b/tests/qemu-iotests/300.out index cafb8161f7..12e9ab7d57 100644 --- a/tests/qemu-iotests/300.out +++ b/tests/qemu-iotests/300.out @@ -1,5 +1,5 @@ -..................................... +....................................... ---------------------------------------------------------------------- -Ran 37 tests +Ran 39 tests OK --=20 2.29.2