From nobody Sun Oct 5 19:23:32 2025 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=1613172278; cv=none; d=zohomail.com; s=zohoarc; b=iGPz2JEJf/hb+sEmRbW7vTk+k8NTFKFLZDmKsoEmtd74p6opth5wuxO2vXGmt6cKx1xbeeankYczRLpLco7EurFFkT0jJHkXwNisoVKxmn5+tqC8ElSGfBAsFmo7D4okr8ddroZkuOOaoCfpedJW+7BOjezhUQiXgE8mmFD1ynQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613172278; 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=VdSEoDOZbbnjSFp5z36yXbF6/ucjVRY7rw2sh+fZSgU=; b=G/RU19Inf56/kgPhCxUtz8s3pHbJuqDyyj+4ELVT1eeOQU1FE/Dn9k8vuf5QGLwwX1DjB/hw3to23HcV8Rqzw1ZZrY4GBmML8MdG/fLBZt4NDbFQp8AEa6vxqQ2Y7IXFm6LVDRt6kRL9HLhpEUCxavrS1E/YsN3R3Cwmwxzh7jk= 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 1613172278180600.8421260944536; Fri, 12 Feb 2021 15:24:38 -0800 (PST) Received: from localhost ([::1]:43450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAhnb-0006YI-IN for importer@patchew.org; Fri, 12 Feb 2021 18:24:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAhlR-0004ga-SL for qemu-devel@nongnu.org; Fri, 12 Feb 2021 18:22:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lAhlP-000619-UW for qemu-devel@nongnu.org; Fri, 12 Feb 2021 18:22:17 -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-374-peRK4CoGMvyEme6zEObIvw-1; Fri, 12 Feb 2021 18:21:43 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F30D1E563; Fri, 12 Feb 2021 23:21:42 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-150.phx2.redhat.com [10.3.114.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 576A219D6C; Fri, 12 Feb 2021 23:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613172135; 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=VdSEoDOZbbnjSFp5z36yXbF6/ucjVRY7rw2sh+fZSgU=; b=OT092+logj2WcqxKs70gnU+deVNLcSx51hJhYXIOY67F8gQVgEI6zoSkGvlWSaLevzn/zx bPEoq5X9BNcfzhsS8mOmsEOgXkiLkempb6tB18wmpPTVmSoiVQK8KkMZ4xXt+ynMfRRO+R qIa//l9rLVsbHpJAjfGqYJCsKFl9m/U= X-MC-Unique: peRK4CoGMvyEme6zEObIvw-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 2/5] migration: dirty-bitmap: Allow control of bitmap persistence Date: Fri, 12 Feb 2021 17:21:31 -0600 Message-Id: <20210212232134.1462756-3-eblake@redhat.com> In-Reply-To: <20210212232134.1462756-1-eblake@redhat.com> References: <20210212232134.1462756-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@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=eblake@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=ham 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: Fam Zheng , Peter Krempa , "open list:Dirty Bitmaps" , Juan Quintela , "Dr. David Alan Gilbert" , Markus Armbruster , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , John Snow 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" From: Peter Krempa 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 merging 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 overriding the persistence of migrated bitmaps both on the source and destination sides. Signed-off-by: Peter Krempa Message-Id: Reviewed-by: Eric Blake [eblake: grammar tweaks, drop dead conditional] Signed-off-by: Eric Blake --- qapi/migration.json | 19 ++++++++++++++++++- migration/block-dirty-bitmap.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index ce14d78071a5..6e5943fbb443 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 the modification of the migrated bitmap. +# (since 6.0) +# # Since: 5.2 ## { 'struct': 'BitmapMigrationBitmapAlias', 'data': { 'name': 'str', - 'alias': 'str' + 'alias': 'str', + '*transform': 'BitmapMigrationBitmapAliasTransform' } } ## diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index b39c13ce4ebe..975093610a41 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 @@ -529,6 +530,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; @@ -549,6 +551,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': " @@ -574,8 +579,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); @@ -783,6 +795,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; @@ -807,7 +820,15 @@ 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->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); } @@ -1091,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) { --=20 2.30.1