From nobody Sun Feb 8 19:59:52 2026 Delivered-To: importer@patchew.org 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; 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; dmarc=fail(p=none dis=none) header.from=virtuozzo.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1581952606478974.740082489098; Mon, 17 Feb 2020 07:16:46 -0800 (PST) Received: from localhost ([::1]:47044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3i8b-00029i-Av for importer@patchew.org; Mon, 17 Feb 2020 10:16:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39269) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j3hvk-0004yN-UT for qemu-devel@nongnu.org; Mon, 17 Feb 2020 10:03:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j3hvj-0007aK-29 for qemu-devel@nongnu.org; Mon, 17 Feb 2020 10:03:28 -0500 Received: from relay.sw.ru ([185.231.240.75]:47534) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j3hvi-0007RU-Px; Mon, 17 Feb 2020 10:03:26 -0500 Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1j3hvC-0007Zt-KZ; Mon, 17 Feb 2020 18:02:54 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [PATCH v2 02/22] migration/block-dirty-bitmap: rename state structure types Date: Mon, 17 Feb 2020 18:02:26 +0300 Message-Id: <20200217150246.29180-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200217150246.29180-1-vsementsov@virtuozzo.com> References: <20200217150246.29180-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 185.231.240.75 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 , vsementsov@virtuozzo.com, qemu-block@nongnu.org, quintela@redhat.com, dgilbert@redhat.com, Stefan Hajnoczi , andrey.shinkevich@virtuozzo.com, John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Rename types to be symmetrical for load/save part and shorter. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Eric Blake --- migration/block-dirty-bitmap.c | 68 ++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 16f1793ee3..73792ab005 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -100,23 +100,25 @@ /* 0x04 was "AUTOLOAD" flags on elder versions, no it is ignored */ #define DIRTY_BITMAP_MIG_START_FLAG_RESERVED_MASK 0xf8 =20 -typedef struct DirtyBitmapMigBitmapState { +/* State of one bitmap during save process */ +typedef struct SaveBitmapState { /* Written during setup phase. */ BlockDriverState *bs; const char *node_name; BdrvDirtyBitmap *bitmap; uint64_t total_sectors; uint64_t sectors_per_chunk; - QSIMPLEQ_ENTRY(DirtyBitmapMigBitmapState) entry; + QSIMPLEQ_ENTRY(SaveBitmapState) entry; uint8_t flags; =20 /* For bulk phase. */ bool bulk_completed; uint64_t cur_sector; -} DirtyBitmapMigBitmapState; +} SaveBitmapState; =20 -typedef struct DirtyBitmapMigState { - QSIMPLEQ_HEAD(, DirtyBitmapMigBitmapState) dbms_list; +/* State of the dirty bitmap migration (DBM) during save process */ +typedef struct DBMSaveState { + QSIMPLEQ_HEAD(, SaveBitmapState) dbms_list; =20 bool bulk_completed; bool no_bitmaps; @@ -124,23 +126,25 @@ typedef struct DirtyBitmapMigState { /* for send_bitmap_bits() */ BlockDriverState *prev_bs; BdrvDirtyBitmap *prev_bitmap; -} DirtyBitmapMigState; +} DBMSaveState; =20 -typedef struct DirtyBitmapLoadState { +/* State of the dirty bitmap migration (DBM) during load process */ +typedef struct DBMLoadState { uint32_t flags; char node_name[256]; char bitmap_name[256]; BlockDriverState *bs; BdrvDirtyBitmap *bitmap; -} DirtyBitmapLoadState; +} DBMLoadState; =20 -static DirtyBitmapMigState dirty_bitmap_mig_state; +static DBMSaveState dirty_bitmap_mig_state; =20 -typedef struct DirtyBitmapLoadBitmapState { +/* State of one bitmap during load process */ +typedef struct LoadBitmapState { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; bool migrated; -} DirtyBitmapLoadBitmapState; +} LoadBitmapState; static GSList *enabled_bitmaps; QemuMutex finish_lock; =20 @@ -170,7 +174,7 @@ static void qemu_put_bitmap_flags(QEMUFile *f, uint32_t= flags) qemu_put_byte(f, flags); } =20 -static void send_bitmap_header(QEMUFile *f, DirtyBitmapMigBitmapState *dbm= s, +static void send_bitmap_header(QEMUFile *f, SaveBitmapState *dbms, uint32_t additional_flags) { BlockDriverState *bs =3D dbms->bs; @@ -199,19 +203,19 @@ static void send_bitmap_header(QEMUFile *f, DirtyBitm= apMigBitmapState *dbms, } } =20 -static void send_bitmap_start(QEMUFile *f, DirtyBitmapMigBitmapState *dbms) +static void send_bitmap_start(QEMUFile *f, SaveBitmapState *dbms) { send_bitmap_header(f, dbms, DIRTY_BITMAP_MIG_FLAG_START); qemu_put_be32(f, bdrv_dirty_bitmap_granularity(dbms->bitmap)); qemu_put_byte(f, dbms->flags); } =20 -static void send_bitmap_complete(QEMUFile *f, DirtyBitmapMigBitmapState *d= bms) +static void send_bitmap_complete(QEMUFile *f, SaveBitmapState *dbms) { send_bitmap_header(f, dbms, DIRTY_BITMAP_MIG_FLAG_COMPLETE); } =20 -static void send_bitmap_bits(QEMUFile *f, DirtyBitmapMigBitmapState *dbms, +static void send_bitmap_bits(QEMUFile *f, SaveBitmapState *dbms, uint64_t start_sector, uint32_t nr_sectors) { /* align for buffer_is_zero() */ @@ -257,7 +261,7 @@ static void send_bitmap_bits(QEMUFile *f, DirtyBitmapMi= gBitmapState *dbms, /* Called with iothread lock taken. */ static void dirty_bitmap_mig_cleanup(void) { - DirtyBitmapMigBitmapState *dbms; + SaveBitmapState *dbms; =20 while ((dbms =3D QSIMPLEQ_FIRST(&dirty_bitmap_mig_state.dbms_list)) != =3D NULL) { QSIMPLEQ_REMOVE_HEAD(&dirty_bitmap_mig_state.dbms_list, entry); @@ -272,7 +276,7 @@ static int init_dirty_bitmap_migration(void) { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; - DirtyBitmapMigBitmapState *dbms; + SaveBitmapState *dbms; Error *local_err =3D NULL; =20 dirty_bitmap_mig_state.bulk_completed =3D false; @@ -303,7 +307,7 @@ static int init_dirty_bitmap_migration(void) bdrv_ref(bs); bdrv_dirty_bitmap_set_busy(bitmap, true); =20 - dbms =3D g_new0(DirtyBitmapMigBitmapState, 1); + dbms =3D g_new0(SaveBitmapState, 1); dbms->bs =3D bs; dbms->node_name =3D name; dbms->bitmap =3D bitmap; @@ -340,7 +344,7 @@ fail: } =20 /* Called with no lock taken. */ -static void bulk_phase_send_chunk(QEMUFile *f, DirtyBitmapMigBitmapState *= dbms) +static void bulk_phase_send_chunk(QEMUFile *f, SaveBitmapState *dbms) { uint32_t nr_sectors =3D MIN(dbms->total_sectors - dbms->cur_sector, dbms->sectors_per_chunk); @@ -356,7 +360,7 @@ static void bulk_phase_send_chunk(QEMUFile *f, DirtyBit= mapMigBitmapState *dbms) /* Called with no lock taken. */ static void bulk_phase(QEMUFile *f, bool limit) { - DirtyBitmapMigBitmapState *dbms; + SaveBitmapState *dbms; =20 QSIMPLEQ_FOREACH(dbms, &dirty_bitmap_mig_state.dbms_list, entry) { while (!dbms->bulk_completed) { @@ -393,7 +397,7 @@ static int dirty_bitmap_save_iterate(QEMUFile *f, void = *opaque) =20 static int dirty_bitmap_save_complete(QEMUFile *f, void *opaque) { - DirtyBitmapMigBitmapState *dbms; + SaveBitmapState *dbms; trace_dirty_bitmap_save_complete_enter(); =20 if (!dirty_bitmap_mig_state.bulk_completed) { @@ -418,7 +422,7 @@ static void dirty_bitmap_save_pending(QEMUFile *f, void= *opaque, uint64_t *res_compatible, uint64_t *res_postcopy_only) { - DirtyBitmapMigBitmapState *dbms; + SaveBitmapState *dbms; uint64_t pending =3D 0; =20 qemu_mutex_lock_iothread(); @@ -439,7 +443,7 @@ static void dirty_bitmap_save_pending(QEMUFile *f, void= *opaque, } =20 /* First occurrence of this bitmap. It should be created if doesn't exist = */ -static int dirty_bitmap_load_start(QEMUFile *f, DirtyBitmapLoadState *s) +static int dirty_bitmap_load_start(QEMUFile *f, DBMLoadState *s) { Error *local_err =3D NULL; uint32_t granularity =3D qemu_get_be32(f); @@ -470,7 +474,7 @@ static int dirty_bitmap_load_start(QEMUFile *f, DirtyBi= tmapLoadState *s) =20 bdrv_disable_dirty_bitmap(s->bitmap); if (flags & DIRTY_BITMAP_MIG_START_FLAG_ENABLED) { - DirtyBitmapLoadBitmapState *b; + LoadBitmapState *b; =20 bdrv_dirty_bitmap_create_successor(s->bitmap, &local_err); if (local_err) { @@ -478,7 +482,7 @@ static int dirty_bitmap_load_start(QEMUFile *f, DirtyBi= tmapLoadState *s) return -EINVAL; } =20 - b =3D g_new(DirtyBitmapLoadBitmapState, 1); + b =3D g_new(LoadBitmapState, 1); b->bs =3D s->bs; b->bitmap =3D s->bitmap; b->migrated =3D false; @@ -495,7 +499,7 @@ void dirty_bitmap_mig_before_vm_start(void) qemu_mutex_lock(&finish_lock); =20 for (item =3D enabled_bitmaps; item; item =3D g_slist_next(item)) { - DirtyBitmapLoadBitmapState *b =3D item->data; + LoadBitmapState *b =3D item->data; =20 if (b->migrated) { bdrv_enable_dirty_bitmap(b->bitmap); @@ -512,7 +516,7 @@ void dirty_bitmap_mig_before_vm_start(void) qemu_mutex_unlock(&finish_lock); } =20 -static void dirty_bitmap_load_complete(QEMUFile *f, DirtyBitmapLoadState *= s) +static void dirty_bitmap_load_complete(QEMUFile *f, DBMLoadState *s) { GSList *item; trace_dirty_bitmap_load_complete(); @@ -521,7 +525,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, Dir= tyBitmapLoadState *s) qemu_mutex_lock(&finish_lock); =20 for (item =3D enabled_bitmaps; item; item =3D g_slist_next(item)) { - DirtyBitmapLoadBitmapState *b =3D item->data; + LoadBitmapState *b =3D item->data; =20 if (b->bitmap =3D=3D s->bitmap) { b->migrated =3D true; @@ -553,7 +557,7 @@ static void dirty_bitmap_load_complete(QEMUFile *f, Dir= tyBitmapLoadState *s) qemu_mutex_unlock(&finish_lock); } =20 -static int dirty_bitmap_load_bits(QEMUFile *f, DirtyBitmapLoadState *s) +static int dirty_bitmap_load_bits(QEMUFile *f, DBMLoadState *s) { uint64_t first_byte =3D qemu_get_be64(f) << BDRV_SECTOR_BITS; uint64_t nr_bytes =3D (uint64_t)qemu_get_be32(f) << BDRV_SECTOR_BITS; @@ -598,7 +602,7 @@ static int dirty_bitmap_load_bits(QEMUFile *f, DirtyBit= mapLoadState *s) return 0; } =20 -static int dirty_bitmap_load_header(QEMUFile *f, DirtyBitmapLoadState *s) +static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s) { Error *local_err =3D NULL; bool nothing; @@ -647,7 +651,7 @@ static int dirty_bitmap_load_header(QEMUFile *f, DirtyB= itmapLoadState *s) =20 static int dirty_bitmap_load(QEMUFile *f, void *opaque, int version_id) { - static DirtyBitmapLoadState s; + static DBMLoadState s; int ret =3D 0; =20 trace_dirty_bitmap_load_enter(); @@ -685,7 +689,7 @@ static int dirty_bitmap_load(QEMUFile *f, void *opaque,= int version_id) =20 static int dirty_bitmap_save_setup(QEMUFile *f, void *opaque) { - DirtyBitmapMigBitmapState *dbms =3D NULL; + SaveBitmapState *dbms =3D NULL; if (init_dirty_bitmap_migration() < 0) { return -1; } --=20 2.21.0