From nobody Sun May 19 13:07:51 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 ARC-Seal: i=1; a=rsa-sha256; t=1603291654; cv=none; d=zohomail.com; s=zohoarc; b=bcsdA4cUQ+w0ZQog9SwXghHZJWoMGD0cva2yGun1yuq5ENM35KDIjBcneydG/OzfZK1XwH7IqXDiyDUdNICUPCCCTT24SE2ITQO8g8gLJZrMXkOLiEx+/OfMRsDwry2ZY5QD8F7vhiNY83YNe8FyNHjGPmd3V87Bpq3hQin32lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603291654; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=9ur9ZOP25cHzkQLmcUOBXQP4cUN5SUYn0D5CwfERsfY=; b=FdKe9bscgEKIlOz7T9709suwI585HQv7turphpidy94nXW84OQ7IQS484y/D9N2WvPJwchUxjBp91N0b2SXEmHgzHYc5g2dieBrj4BD5AcCcD0uCytA/dV5i0X/Ioey86VzOyaDmIbpTNbcjfYJk/CcHm/A9XzCYICFLbpgvZh0= ARC-Authentication-Results: i=1; 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 1603291654166321.56246858015845; Wed, 21 Oct 2020 07:47:34 -0700 (PDT) Received: from localhost ([::1]:53492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVFOn-0003YH-3r for importer@patchew.org; Wed, 21 Oct 2020 10:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFNF-0002Le-Rk; Wed, 21 Oct 2020 10:45:57 -0400 Received: from proxmox-new.maurer-it.com ([212.186.127.180]:19541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVFNA-0006Iw-UD; Wed, 21 Oct 2020 10:45:56 -0400 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 30DA345EA5; Wed, 21 Oct 2020 16:45:39 +0200 (CEST) From: Stefan Reiter To: quintela@redhat.com, dgilbert@redhat.com Subject: [PATCH] migration/block-dirty-bitmap: fix larger granularity bitmaps Date: Wed, 21 Oct 2020 16:44:56 +0200 Message-Id: <20201021144456.1072-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 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=212.186.127.180; envelope-from=s.reiter@proxmox.com; helo=proxmox-new.maurer-it.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 10:45:39 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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@euphon.net, vsementsov@virtuozzo.com, qemu-block@nongnu.org, jsnow@redhat.com, s.reiter@proxmox.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" sectors_per_chunk is a 64 bit integer, but the calculation is done in 32 bits, leading to an overflow for coarse bitmap granularities. If that results in the value 0, it leads to a hang where no progress is made but send_bitmap_bits is constantly called with nr_sectors being 0. Signed-off-by: Stefan Reiter Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/block-dirty-bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index 5bef793ac0..5398869e2b 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -562,8 +562,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDr= iverState *bs, dbms->bitmap_alias =3D g_strdup(bitmap_alias); dbms->bitmap =3D bitmap; dbms->total_sectors =3D bdrv_nb_sectors(bs); - dbms->sectors_per_chunk =3D CHUNK_SIZE * 8 * + dbms->sectors_per_chunk =3D CHUNK_SIZE * 8lu * bdrv_dirty_bitmap_granularity(bitmap) >> BDRV_SECTOR_BITS; + assert(dbms->sectors_per_chunk !=3D 0); if (bdrv_dirty_bitmap_enabled(bitmap)) { dbms->flags |=3D DIRTY_BITMAP_MIG_START_FLAG_ENABLED; } --=20 2.20.1