From nobody Mon Feb 9 07:05:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=2; a=rsa-sha256; t=1595580575; cv=pass; d=zohomail.com; s=zohoarc; b=JDG567tG/43TTOx1MLapsI/OnkfUyTmP1PjVCXgud2OEWD6eKAQpBOTA3sYkoI1QtD26JUg05I06BMLI5wr/41H0FB1uaH6DDQKmg8Clnh/hLikTRfZZGWsuP/1xWas2yHQOVz6EfUwBG7z5ofob3Nf/sQKhvhOT9z5RiGxGOT0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595580575; 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=AJz/6uNkQvviCpEQRT82foNK1gNYcCC5arhGIcj14zU=; b=FJlMhpKs8kLYUw1oIL7zZFRx+G4oZKeHshziqPOhsb2lI2GA/EZVB3zJ1NFGGVxPr7PceAHqmuiqHP1A5nYTVQu7elC0hn0tAoH5UUhX/A/+SWmUdA44VQtvG4AQPNo5R+/JYM68NHJEN3+1b6Cb2wNoRaS6UBcMOAC571n28xA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; 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; arc=pass (i=1dmarc=pass fromdomain=virtuozzo.com); dmarc=pass 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 1595580575707924.5202115427538; Fri, 24 Jul 2020 01:49:35 -0700 (PDT) Received: from localhost ([::1]:39652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jytOY-0003Bl-9z for importer@patchew.org; Fri, 24 Jul 2020 04:49:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jytJK-000263-GJ; Fri, 24 Jul 2020 04:44:10 -0400 Received: from mail-eopbgr80095.outbound.protection.outlook.com ([40.107.8.95]:31299 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jytJI-0008Pz-Hy; Fri, 24 Jul 2020 04:44:10 -0400 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) by AM6PR08MB4534.eurprd08.prod.outlook.com (2603:10a6:20b:ba::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.17; Fri, 24 Jul 2020 08:43:56 +0000 Received: from AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::8c0c:c056:97a5:484a]) by AM7PR08MB5494.eurprd08.prod.outlook.com ([fe80::8c0c:c056:97a5:484a%4]) with mapi id 15.20.3216.024; Fri, 24 Jul 2020 08:43:56 +0000 Received: from localhost.localdomain (185.215.60.156) by AM0PR01CA0160.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21 via Frontend Transport; Fri, 24 Jul 2020 08:43:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAZFJwKmKTKJhiEsm5lLliYASuQ5BVrBSHGXGqGCyW91tbk/TDWr5IU3AE81TLsh+sUlS46ioHen1/e60d+Ndcpw3DNAlN8o/oMVV2vYez2aPlNfodjiLSMPe0okpk/hUOqMvUhQf88+2YNj0VByl/vhPH6q9VJZcFAiISdK03xehRN1ecFaCoUwBc2ao17aqatD9yhUVb8rhPjoA1BhhjDwosHJJiaBCGkl6Q7kejENj+tQcnoZoDxp8onIuqphSChscmRHkEqdKqceEhyrl3ESJGa4YbVIvaLRqgOA4LzGOzczjFWx52imkTk6aP15V8SL7xXAlp8lwBg/MGXmlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AJz/6uNkQvviCpEQRT82foNK1gNYcCC5arhGIcj14zU=; b=UuN9dJV45zn7jLqmLbyRbmt58Y/o8bcyIwIFPCfbqvAOE9Jzw4oljDRiHld46+49IdcLlrSpdEjmeoOHESN1MZziKlL2XpwTiLUlBIWKrDsEFE1KNLuDti44G+Wb/xLvAXNEw3t0e6JwE1+Zrs7RABeZZwmeS5FXP2oG5zR3y61ITvSWOhTjgYa/q7Gi2b3+JbJG7Tf/EJB7beeIGa+v3U+mdF/HtiVfqHAc8coExQIqBnj3+sijp2nyxve2+9WaN5Cz4i7xbqi0kRCNQ7aBKfV9GfHuuBhJczKxGJEVynT6ISTZ3iPsLJxl705guFoYebGz8qEIQB9gbFfiqcnqmg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AJz/6uNkQvviCpEQRT82foNK1gNYcCC5arhGIcj14zU=; b=ciA/shivq4BkIhM2Q5ypdgZLcxOTHIFumTLd46yC90rIHiuEvirZsp0YjXXZJaQuXXKruYhC/jtuzkBv55d0pENCYbV8zyaWBESAStwo3QwleLeUHE8f3EHiHsfISjqUmxeh/Z0w/Fwhqfw/9rZJdfg9inw054CHuqJq1092/8Q= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=virtuozzo.com; From: Vladimir Sementsov-Ogievskiy To: qemu-block@nongnu.org Subject: [PATCH v3 14/21] migration/block-dirty-bitmap: keep bitmap state for all bitmaps Date: Fri, 24 Jul 2020 11:43:20 +0300 Message-Id: <20200724084327.15665-15-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200724084327.15665-1-vsementsov@virtuozzo.com> References: <20200724084327.15665-1-vsementsov@virtuozzo.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: AM0PR01CA0160.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::29) To AM7PR08MB5494.eurprd08.prod.outlook.com (2603:10a6:20b:dc::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Mailer: git-send-email 2.21.0 X-Originating-IP: [185.215.60.156] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb596f1b-05f0-4338-efa4-08d82fadb37b X-MS-TrafficTypeDiagnostic: AM6PR08MB4534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:28; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u3mu2qXgzV7YHxkKxFefQlSmqdpBTvW7gk+lHwgZG5tIN/+RA8paTl2XYWTeIGRvdBC+EDSLbSg1hDlHC4CnfyKx/66Dn/9mEBcibC2BEZd3nsj374Q0f/r80EDkueEdegLqF0/ffzzFpSxaLYIsrtLzhFKSJzJvs9slac6p3N9aqEaoWNOtPD9mnbevV+H3x5hATMrVJcdXs9n2QCDeYZbpYcpJd9VmaclbwRclWV6Es3GdRdLVAWAYRo/I0CDDbMJcrSLgZ3YqTUAEkJwkH40q4tdfULQCvDCIHs3DjT9iOykJl8UwkTFKHcJGZGf+qCc+r1P7/1YpQOW4NFCY9ZrOflBoC6yT8zFURt/6rCslTsRojDmO6fBPMf91fj77ipGEIBONZmRS3g65U9zUhQHX4AoLRT4HeMrsmBU0Mgc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR08MB5494.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(346002)(396003)(136003)(39840400004)(376002)(6512007)(6916009)(66476007)(8676002)(66556008)(52116002)(66946007)(4326008)(83380400001)(6506007)(36756003)(6486002)(956004)(26005)(6666004)(2616005)(69590400007)(7416002)(186003)(5660300002)(478600001)(8936002)(2906002)(107886003)(16526019)(86362001)(316002)(1076003)(14143004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +toFTHe2z4Gerx3BR1ChHeYmEks4ok435FGn0zp8fzjR4xqTF9biEpBLVb/3m7qKqSCUjtIXEhnCBMveQtC/7sTp6n4x9O4oyeE7vDPDTa2t71SM5sVGkvOS9VJ2J2P90R+wYyyHSnvU2Z+vgc4X0iBLzsoLa585unKiFC68TTgTeuDqmx+l7dDul5KNFy6e+ezXR3aTmVxNNnNPk8mShaEE2acVsyPKBPoCeQgwb5El0cbrglAVAO//KrsbTDEotE8yH/SOudCiRzUmdUGRTaW6X8MhpAfyxU/CiE5tH0hcJoAZ/M7mqNiJBEFs2FuPKk4OzRK2m/ueJry1pSqStYeVRVbuGJL5+xzqHaOjaiDiaPNEkQL5VxFPQFqMmVZF5XIPS0uI3rFM4MQ9sD6T+g60ZRmLYp9PuKiA0NMPZ8Cv+LhgBCf/TGHYZl3ynMmUHRns+5EPSHTsRzmRe2X4T2klBEYibIsQb0pnvrmlow8= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb596f1b-05f0-4338-efa4-08d82fadb37b X-MS-Exchange-CrossTenant-AuthSource: AM7PR08MB5494.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2020 08:43:56.1569 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9CsJWiChmbDF46PU1Rnd2+zcZw8cFFqwU0oAeyhay/qQCSDfcrD008y4QUSo8V6/9QZctmu+WgJ9HEDwgPSe3T0JCQ2543czUVEnIPKtv8A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4534 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=40.107.8.95; envelope-from=vsementsov@virtuozzo.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/24 04:43:59 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=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: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, quintela@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @virtuozzo.com) Content-Type: text/plain; charset="utf-8" Keep bitmap state for disabled bitmaps too. Keep the state until the end of the process. It's needed for the following commit to implement bitmap postcopy canceling. To clean-up the new list the following logic is used: We need two events to consider bitmap migration finished: 1. chunk with DIRTY_BITMAP_MIG_FLAG_COMPLETE flag should be received 2. dirty_bitmap_mig_before_vm_start should be called These two events may come in any order, so we understand which one is last, and on the last of them we remove bitmap migration state from the list. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Andrey Shinkevich --- migration/block-dirty-bitmap.c | 64 +++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 405a259296..eb4ffeac4d 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -132,6 +132,7 @@ typedef struct LoadBitmapState { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; bool migrated; + bool enabled; } LoadBitmapState; =20 /* State of the dirty bitmap migration (DBM) during load process */ @@ -142,8 +143,10 @@ typedef struct DBMLoadState { BlockDriverState *bs; BdrvDirtyBitmap *bitmap; =20 - GSList *enabled_bitmaps; - QemuMutex lock; /* protect enabled_bitmaps */ + bool before_vm_start_handled; /* set in dirty_bitmap_mig_before_vm_sta= rt */ + + GSList *bitmaps; + QemuMutex lock; /* protect bitmaps */ } DBMLoadState; =20 typedef struct DBMState { @@ -526,6 +529,7 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoad= State *s) Error *local_err =3D NULL; uint32_t granularity =3D qemu_get_be32(f); uint8_t flags =3D qemu_get_byte(f); + LoadBitmapState *b; =20 if (s->bitmap) { error_report("Bitmap with the same name ('%s') already exists on " @@ -552,45 +556,59 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLo= adState *s) =20 bdrv_disable_dirty_bitmap(s->bitmap); if (flags & DIRTY_BITMAP_MIG_START_FLAG_ENABLED) { - LoadBitmapState *b; - bdrv_dirty_bitmap_create_successor(s->bitmap, &local_err); if (local_err) { error_report_err(local_err); return -EINVAL; } - - b =3D g_new(LoadBitmapState, 1); - b->bs =3D s->bs; - b->bitmap =3D s->bitmap; - b->migrated =3D false; - s->enabled_bitmaps =3D g_slist_prepend(s->enabled_bitmaps, b); } =20 + b =3D g_new(LoadBitmapState, 1); + b->bs =3D s->bs; + b->bitmap =3D s->bitmap; + b->migrated =3D false; + b->enabled =3D flags & DIRTY_BITMAP_MIG_START_FLAG_ENABLED; + + s->bitmaps =3D g_slist_prepend(s->bitmaps, b); + return 0; } =20 -void dirty_bitmap_mig_before_vm_start(void) +/* + * before_vm_start_handle_item + * + * g_slist_foreach helper + * + * item is LoadBitmapState* + * opaque is DBMLoadState* + */ +static void before_vm_start_handle_item(void *item, void *opaque) { - DBMLoadState *s =3D &dbm_state.load; - GSList *item; - - qemu_mutex_lock(&s->lock); - - for (item =3D s->enabled_bitmaps; item; item =3D g_slist_next(item)) { - LoadBitmapState *b =3D item->data; + DBMLoadState *s =3D opaque; + LoadBitmapState *b =3D item; =20 + if (b->enabled) { if (b->migrated) { bdrv_enable_dirty_bitmap(b->bitmap); } else { bdrv_dirty_bitmap_enable_successor(b->bitmap); } + } =20 + if (b->migrated) { + s->bitmaps =3D g_slist_remove(s->bitmaps, b); g_free(b); } +} =20 - g_slist_free(s->enabled_bitmaps); - s->enabled_bitmaps =3D NULL; +void dirty_bitmap_mig_before_vm_start(void) +{ + DBMLoadState *s =3D &dbm_state.load; + qemu_mutex_lock(&s->lock); + + assert(!s->before_vm_start_handled); + g_slist_foreach(s->bitmaps, before_vm_start_handle_item, s); + s->before_vm_start_handled =3D true; =20 qemu_mutex_unlock(&s->lock); } @@ -607,11 +625,15 @@ static void dirty_bitmap_load_complete(QEMUFile *f, D= BMLoadState *s) bdrv_reclaim_dirty_bitmap(s->bitmap, &error_abort); } =20 - for (item =3D s->enabled_bitmaps; item; item =3D g_slist_next(item)) { + for (item =3D s->bitmaps; item; item =3D g_slist_next(item)) { LoadBitmapState *b =3D item->data; =20 if (b->bitmap =3D=3D s->bitmap) { b->migrated =3D true; + if (s->before_vm_start_handled) { + s->bitmaps =3D g_slist_remove(s->bitmaps, b); + g_free(b); + } break; } } --=20 2.21.0