From nobody Sun May 12 00:39: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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035597394814.6263812480614; Mon, 21 Nov 2022 04:59:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6OQ-0001X6-7u; Mon, 21 Nov 2022 07:59:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OO-0001WT-4V for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OM-0006O1-9H for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:19 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-7CThAzJtMSudgaeBtqyYUA-1; Mon, 21 Nov 2022 07:59:15 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 770A8101A54E; Mon, 21 Nov 2022 12:59:15 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7722BC15BB3; Mon, 21 Nov 2022 12:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035557; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NgY27LzJ2uT9zxS51v2nfe7D++QJeM61SQkE9yjjQQ8=; b=JO2Wtx9enwAhuEZQ+OwCRDicSMu8EdkH79Fehi8LEvT8OxwNM+x95pfSSRsTPmlggIKd3n LYYErckINJJn2zN9ujBcZOHE70hEqs0c3guKvyXU+M+mu5s28PH/unyXeYtO7vNzPP75e3 nILoBCiYt2wBy3lKEbD9EQPBDwMOVrI= X-MC-Unique: 7CThAzJtMSudgaeBtqyYUA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini , Fiona Ebner Subject: [PULL 1/8] migration/channel-block: fix return value for qio_channel_block_{readv, writev} Date: Mon, 21 Nov 2022 13:59:00 +0100 Message-Id: <20221121125907.62469-2-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1669035599580100007 Content-Type: text/plain; charset="utf-8" From: Fiona Ebner in the error case. The documentation in include/io/channel.h states that -1 or QIO_CHANNEL_ERR_BLOCK should be returned upon error. Simply passing along the return value from the bdrv-functions has the potential to confuse the call sides. Non-blocking mode is not implemented currently, so -1 it is. Signed-off-by: Fiona Ebner Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/channel-block.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/channel-block.c b/migration/channel-block.c index c55c8c93ce..f4ab53acdb 100644 --- a/migration/channel-block.c +++ b/migration/channel-block.c @@ -62,7 +62,8 @@ qio_channel_block_readv(QIOChannel *ioc, qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov); ret =3D bdrv_readv_vmstate(bioc->bs, &qiov, bioc->offset); if (ret < 0) { - return ret; + error_setg_errno(errp, -ret, "bdrv_readv_vmstate failed"); + return -1; } =20 bioc->offset +=3D qiov.size; @@ -86,7 +87,8 @@ qio_channel_block_writev(QIOChannel *ioc, qemu_iovec_init_external(&qiov, (struct iovec *)iov, niov); ret =3D bdrv_writev_vmstate(bioc->bs, &qiov, bioc->offset); if (ret < 0) { - return ret; + error_setg_errno(errp, -ret, "bdrv_writev_vmstate failed"); + return -1; } =20 bioc->offset +=3D qiov.size; --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669036065; cv=none; d=zohomail.com; s=zohoarc; b=CxBSt+6RBkZAX/jQDneMONqvLBShxbILIDa8mzPXv0xKS/1xuczikWUt3gkOayYLuI6C0h9fuwQTT6Iz3fm3cM8EGSyw6kJOkAVckqO6CvjBXpbqH8Uxg8rrEyytVr2UwsFvaaUOBZWcQuaNhCjE4hPte/UbQUINq+Si1nLC/NY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669036065; h=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=KqEMNGfO+9FCgLhL/tSP3g81IW8o7xa3Zcbo6/dqmM0=; b=TeMU9nH9CloZRrLwBPvpCevHViBGkjdiSYcND54zvSFW1GkFIX8DUvicxb4a+YL6NryB3FRoPbdCWRjmlnl0ci5OPVMq4bDexhypHJfCF4OMKpgJAF9wE+dlEc9MH+9abKWny0XgQfnddwxazxKH2neoJ6+pKKkpE+DThfORL7E= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669036065566759.0792306968939; Mon, 21 Nov 2022 05:07:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6OR-0001Yh-Rc; Mon, 21 Nov 2022 07:59:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OQ-0001XH-8J for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OO-0006P7-Me for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:21 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-qGDp30biNVqyaE4NYkZGoQ-1; Mon, 21 Nov 2022 07:59:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD2C3185A792; Mon, 21 Nov 2022 12:59:17 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id C173CC15BB3; Mon, 21 Nov 2022 12:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KqEMNGfO+9FCgLhL/tSP3g81IW8o7xa3Zcbo6/dqmM0=; b=cEOSmvn2ajTm94chv2vzGrETD/eOdC2yZ78GbqXPj2WeEQMKSlkJIVAe6POuvy0B+QffzX J0+RHtwNcPl0XqR2hSGxVoEKdGmrPQfg5uezInG5+bs7nwGAVC5OvOjjl3kfVW77NSEnYP so5Q6QgeUBdsVvNZVyWmyozgP4QBXzg= X-MC-Unique: qGDp30biNVqyaE4NYkZGoQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini , Leonardo Bras Subject: [PULL 2/8] migration/multifd/zero-copy: Create helper function for flushing Date: Mon, 21 Nov 2022 13:59:01 +0100 Message-Id: <20221121125907.62469-3-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669036067137100003 Content-Type: text/plain; charset="utf-8" From: Leonardo Bras Move flushing code from multifd_send_sync_main() to a new helper, and call it in multifd_send_sync_main(). Signed-off-by: Leonardo Bras Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/multifd.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 586ddc9d65..509bbbe3bf 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -566,6 +566,23 @@ void multifd_save_cleanup(void) multifd_send_state =3D NULL; } =20 +static int multifd_zero_copy_flush(QIOChannel *c) +{ + int ret; + Error *err =3D NULL; + + ret =3D qio_channel_flush(c, &err); + if (ret < 0) { + error_report_err(err); + return -1; + } + if (ret =3D=3D 1) { + dirty_sync_missed_zero_copy(); + } + + return ret; +} + int multifd_send_sync_main(QEMUFile *f) { int i; @@ -616,17 +633,8 @@ int multifd_send_sync_main(QEMUFile *f) qemu_mutex_unlock(&p->mutex); qemu_sem_post(&p->sem); =20 - if (flush_zero_copy && p->c) { - int ret; - Error *err =3D NULL; - - ret =3D qio_channel_flush(p->c, &err); - if (ret < 0) { - error_report_err(err); - return -1; - } else if (ret =3D=3D 1) { - dirty_sync_missed_zero_copy(); - } + if (flush_zero_copy && p->c && (multifd_zero_copy_flush(p->c) < 0)= ) { + return -1; } } for (i =3D 0; i < migrate_multifd_channels(); i++) { --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669035610; cv=none; d=zohomail.com; s=zohoarc; b=CEz4H9vmT+B94UYMM0T43KE0kSsXUs1g/Ddtt5sTEZ6ZVeZhNnU5ooMfq4nlE6UTQC8j04ud0NMQImoUcGGSmFbL2CPMPOR2s0rWpVt51x7wrmqOFmdrcfNunFHC7ckGFvPx9VgXANRgyxCZ0DaZc7ubjsv3qLfgkKgboYkCNoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035610; h=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=C43sXzuDPrCVxw3vYvZA3vkx4qjmhBG5GAMoIDyKDro=; b=jFTxTLA0/tK8+PMGoCf9FXn2k5M1bln3oGhaPInj8L+r758pb2nSCWYKPy2/nIckXGIBlA5y2tsid8V86eqyBNPVXmFstrI2qjaYBQYGPlNwf4xmI07xRm4LZ/HavjBANNBkk1bxggpA1rW6DisAFIxKz0B+FAJmjU9UnbZcQes= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035610369118.93825102284961; Mon, 21 Nov 2022 05:00:10 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6OU-0001a0-J1; Mon, 21 Nov 2022 07:59:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OT-0001Za-AN for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OR-0006Qj-TY for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:25 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-94-clqyI-BYPgiqhT9ZfcFXAA-1; Mon, 21 Nov 2022 07:59:20 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B3E1C101A528; Mon, 21 Nov 2022 12:59:19 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E12AC15BB3; Mon, 21 Nov 2022 12:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035563; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C43sXzuDPrCVxw3vYvZA3vkx4qjmhBG5GAMoIDyKDro=; b=YOJzGVdwAtnOnGSRfnOZiNZGFRu27wFDlPCh5oaf4VWxigpAb8x1653mhpj6MPTASGs8fc E0Yuih6P66O9ZCFUZLuSKOeMqGcJ3JIlg0SNyZPVjszZqY0ppl0T+3ztPT3WzzmtU9ghrq 1/XEAOwt732wVE4a4x56AIGbjf9nmqk= X-MC-Unique: clqyI-BYPgiqhT9ZfcFXAA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini Subject: [PULL 3/8] migration: Fix possible infinite loop of ram save process Date: Mon, 21 Nov 2022 13:59:02 +0100 Message-Id: <20221121125907.62469-4-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669035611914100003 Content-Type: text/plain; charset="utf-8" From: Peter Xu When starting ram saving procedure (especially at the completion phase), always set last_seen_block to non-NULL to make sure we can always correctly detect the case where "we've migrated all the dirty pages". Then we'll guarantee both last_seen_block and pss.block will be valid always before the loop starts. See the comment in the code for some details. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index dc1de9ddbc..1d42414ecc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2546,14 +2546,22 @@ static int ram_find_and_save_block(RAMState *rs) return pages; } =20 + /* + * Always keep last_seen_block/last_page valid during this procedure, + * because find_dirty_block() relies on these values (e.g., we compare + * last_seen_block with pss.block to see whether we searched all the + * ramblocks) to detect the completion of migration. Having NULL value + * of last_seen_block can conditionally cause below loop to run foreve= r. + */ + if (!rs->last_seen_block) { + rs->last_seen_block =3D QLIST_FIRST_RCU(&ram_list.blocks); + rs->last_page =3D 0; + } + pss.block =3D rs->last_seen_block; pss.page =3D rs->last_page; pss.complete_round =3D false; =20 - if (!pss.block) { - pss.block =3D QLIST_FIRST_RCU(&ram_list.blocks); - } - do { again =3D true; found =3D get_queued_page(rs, &pss); --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669035617; cv=none; d=zohomail.com; s=zohoarc; b=CD3sMZ9yrMW7YSYrW3mCnXGZTfchPsotrTUJtbPlNxe7ExsJ9xrrTc7Izi158Fs2nhem/+ziClEDKHGllnsHssczV5K1h6bn5HIbxzFnpZL8IANTQzYNfpGHqoLgC9lVgreGjkMuauf/4IaUs1MjGCDvvGtVbNjwynPogl2aZtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035617; h=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=lv4vZEI7OQUfHArHUOc7UL/dhPGExU7enAwFsaFQkm8=; b=djon4uYGJ1GHuMafblARvVDRlNOZD2tHKRdqtNgo8eDDFUmSW6U4EoOgSPEyh9XIBEikMy2HvHULyyOfbU5+uY+W6kR6NLbqGlVhwLeePRnPemlMibjKserYel+F55RB4Toln2p6rf0sJdM3++A0HHPx3T5KBauZYs7stlKsERM= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035617504709.7981933174473; Mon, 21 Nov 2022 05:00:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6Oc-0001bv-DT; Mon, 21 Nov 2022 07:59:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OW-0001ay-IN for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OV-0006RT-1o for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:28 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-TksasngsNL-g8bRS6tYCNA-1; Mon, 21 Nov 2022 07:59:22 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6FF78027FE; Mon, 21 Nov 2022 12:59:21 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08FA7C15BB9; Mon, 21 Nov 2022 12:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lv4vZEI7OQUfHArHUOc7UL/dhPGExU7enAwFsaFQkm8=; b=OLFD3fLRomdyFChNX3BC9bJzRAaTW+BFPOWJt0rvTfes1Esy7LDUI53xTPfyXHtMobtkOE IC0W31zpbe9mE873c4fp+FXrCBMh5GfDHvIIABywHRdub5g148Ax8xhzFfY0TBMTcblp9Q Y1Xn5lYsHWohr5ae0fiYo6Gx32DlwLQ= X-MC-Unique: TksasngsNL-g8bRS6tYCNA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini , "Daniel P . Berrange" Subject: [PULL 4/8] migration: Fix race on qemu_file_shutdown() Date: Mon, 21 Nov 2022 13:59:03 +0100 Message-Id: <20221121125907.62469-5-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669035619903100003 Content-Type: text/plain; charset="utf-8" From: Peter Xu In qemu_file_shutdown(), there's a possible race if with current order of operation. There're two major things to do: (1) Do real shutdown() (e.g. shutdown() syscall on socket) (2) Update qemufile's last_error We must do (2) before (1) otherwise there can be a race condition like: page receiver other thread ------------- ------------ qemu_get_buffer() do shutdown() returns 0 (buffer all zero) (meanwhile we didn't check this retcode) try to detect IO error last_error=3D=3DNULL, IO okay install ALL-ZERO page set last_error --> guest crash! To fix this, we can also check retval of qemu_get_buffer(), but not all APIs can be properly checked and ultimately we still need to go back to qemu_file_get_error(). E.g. qemu_get_byte() doesn't return error. Maybe some day a rework of qemufile API is really needed, but for now keep using qemu_file_get_error() and fix it by not allowing that race condition to happen. Here shutdown() is indeed special because the last_error was emulated. For real -EIO errors it'll always be set when e.g. sendmsg() error triggers so we won't miss those ones, only shutdown() is a bit tricky here. Cc: Daniel P. Berrange Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/qemu-file.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 4f400c2e52..2d5f74ffc2 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -79,6 +79,30 @@ int qemu_file_shutdown(QEMUFile *f) int ret =3D 0; =20 f->shutdown =3D true; + + /* + * We must set qemufile error before the real shutdown(), otherwise + * there can be a race window where we thought IO all went though + * (because last_error=3D=3DNULL) but actually IO has already stopped. + * + * If without correct ordering, the race can happen like this: + * + * page receiver other thread + * ------------- ------------ + * qemu_get_buffer() + * do shutdown() + * returns 0 (buffer all zero) + * (we didn't check this retcode) + * try to detect IO error + * last_error=3D=3DNULL, IO okay + * install ALL-ZERO page + * set last_error + * --> guest crash! + */ + if (!f->last_error) { + qemu_file_set_error(f, -EIO); + } + if (!qio_channel_has_feature(f->ioc, QIO_CHANNEL_FEATURE_SHUTDOWN)) { return -ENOSYS; @@ -88,9 +112,6 @@ int qemu_file_shutdown(QEMUFile *f) ret =3D -EIO; } =20 - if (!f->last_error) { - qemu_file_set_error(f, -EIO); - } return ret; } =20 --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669035596; cv=none; d=zohomail.com; s=zohoarc; b=h1QkdSg6VlO2XIHkB1R5f9Dc/L5lXd1j9CcjRcoeg5pQkPVj4VkKDrs0R5TtI3uDYoc40kENugprRGyGLSROQSBsfeh0aE4p4g7FUvN9K3jKgvjYaieqGld1U+3C3AdUpwsD4AkKtamqQBkacHc5gpn3+QmRhnxo8Ca+sejQ05Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035596; h=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=403oEb4nMshaBr2VAMAZkkpkxyQZ3/0zt2xOM1yNz0I=; b=TeHw0L0tWwtNnorLUWM4biHborVPXMg7voLUqMqPOjRGl7MxzXo8Ud7zkusX1E2wYwDoBrtZgyWhUxzdhlEbYXWqL/j7NCF+N5sNUjP/VK+fDI/MdEl4XJu0m2p0rUzhlg06HfVPLSieN3XuV3StUahmFG8yK7LVJ/ougEsFpSU= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035596903362.76743518197213; Mon, 21 Nov 2022 04:59:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6Oh-0001cT-8x; Mon, 21 Nov 2022 07:59:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OX-0001bP-BY for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6OV-0006Rd-TI for qemu-devel@nongnu.org; Mon, 21 Nov 2022 07:59:29 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-318-2s1HgUuXO_eevD_z1JFycQ-1; Mon, 21 Nov 2022 07:59:24 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4203811E84; Mon, 21 Nov 2022 12:59:23 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E7F3C15BB3; Mon, 21 Nov 2022 12:59:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=403oEb4nMshaBr2VAMAZkkpkxyQZ3/0zt2xOM1yNz0I=; b=DqYBHv8JFrn04L28nsp1o4xPVQ1HONRAH8x0v1Z6Xx78ouwfpn2V/7snChANqAda29famt JA9XEs/xBGfDBJG7tkc/b3bIChKyKlTrJfy3pecf0HgkbpRcLAEw3rhTlMRJYYGNfY6r1d 3SmMM4YIPkXMnNKLBadGxbCmH6zjT/U= X-MC-Unique: 2s1HgUuXO_eevD_z1JFycQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini Subject: [PULL 5/8] migration: Disallow postcopy preempt to be used with compress Date: Mon, 21 Nov 2022 13:59:04 +0100 Message-Id: <20221121125907.62469-6-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669035597695100002 Content-Type: text/plain; charset="utf-8" From: Peter Xu The preempt mode requires the capability to assign channel for each of the page, while the compression logic will currently assign pages to different compress thread/local-channel so potentially they're incompatible. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 739bb683f3..f3ed77a7d0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1337,6 +1337,17 @@ static bool migrate_caps_check(bool *cap_list, error_setg(errp, "Postcopy preempt requires postcopy-ram"); return false; } + + /* + * Preempt mode requires urgent pages to be sent in separate + * channel, OTOH compression logic will disorder all pages into + * different compression channels, which is not compatible with the + * preempt assumptions on channel assignments. + */ + if (cap_list[MIGRATION_CAPABILITY_COMPRESS]) { + error_setg(errp, "Postcopy preempt not compatible with compres= s"); + return false; + } } =20 return true; --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669035646; cv=none; d=zohomail.com; s=zohoarc; b=UAnny8jOsy5/CjOVsU65TGfpj1WUh03y0WAXNGlgp93om/dTVOs8rmr6Y39kQmdtoKUU86Tg7FMSLkJXHSJ0h59Sve4LXdx3gA1RHvu980JXR6tAjAK8WynSBTboGe2kOsc8GvTxv0VLDP9k2LaUk+LIeVioZfOpbNLNxK0+vx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035646; h=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=4j3dbCKGLbNDGAn+c9H7VpwArQIYSq5GKQxPanVzcRI=; b=X3i6xIkZgrgC6rfkgqVIAI737goJrujzW0Y3/Ucj6xsdLMvk3FLVzwaNVH95NLCb8cOsQX7ydK3a+XOiA6tweCXCdR+4tYftIEjaObhW1V2iEFIbVKORdKToZhQVZBKtkP8o6ovEmBFMrgX0LPerXOqhZyVxA1XNxf3xGQLykto= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035646221962.4100855074828; Mon, 21 Nov 2022 05:00:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6P9-0001uE-U9; Mon, 21 Nov 2022 08:00:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6P8-0001sn-E1 for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:00:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6P5-0006Wv-BG for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:00:05 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-484-ltezkVFBNSOuWcOaYs99xA-1; Mon, 21 Nov 2022 07:59:26 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C82181C09B60; Mon, 21 Nov 2022 12:59:25 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2608FC15BB3; Mon, 21 Nov 2022 12:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4j3dbCKGLbNDGAn+c9H7VpwArQIYSq5GKQxPanVzcRI=; b=dNXjPKK1ykJDr4RLdIKewB9q4S5LehDDv6iD+PKQGpxXbmFhn/qcWqvfLHX71l8BluwKtE rwmrs7onFj6N5Jd7YLwFQgcjcmO/Rfe0LiI8Uw2ADNR24Id/ymuQDKX0kcGaO66Y/dxiFJ t8g8KNmr9Z1lHP6dw6+LCR4OdPNkyW8= X-MC-Unique: ltezkVFBNSOuWcOaYs99xA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini Subject: [PULL 6/8] migration: Use non-atomic ops for clear log bitmap Date: Mon, 21 Nov 2022 13:59:05 +0100 Message-Id: <20221121125907.62469-7-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669035648325100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Since we already have bitmap_mutex to protect either the dirty bitmap or the clear log bitmap, we don't need atomic operations to set/clear/test on the clear log bitmap. Switching all ops from atomic to non-atomic versions, meanwhile touch up the comments to show which lock is in charge. Introduced non-atomic version of bitmap_test_and_clear_atomic(), mostly the same as the atomic version but simplified a few places, e.g. dropped the "old_bits" variable, and also the explicit memory barriers. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- include/exec/ram_addr.h | 11 +++++----- include/exec/ramblock.h | 3 +++ include/qemu/bitmap.h | 1 + util/bitmap.c | 45 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 1500680458..f4fb6a2111 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -42,7 +42,8 @@ static inline long clear_bmap_size(uint64_t pages, uint8_= t shift) } =20 /** - * clear_bmap_set: set clear bitmap for the page range + * clear_bmap_set: set clear bitmap for the page range. Must be with + * bitmap_mutex held. * * @rb: the ramblock to operate on * @start: the start page number @@ -55,12 +56,12 @@ static inline void clear_bmap_set(RAMBlock *rb, uint64_= t start, { uint8_t shift =3D rb->clear_bmap_shift; =20 - bitmap_set_atomic(rb->clear_bmap, start >> shift, - clear_bmap_size(npages, shift)); + bitmap_set(rb->clear_bmap, start >> shift, clear_bmap_size(npages, shi= ft)); } =20 /** - * clear_bmap_test_and_clear: test clear bitmap for the page, clear if set + * clear_bmap_test_and_clear: test clear bitmap for the page, clear if set. + * Must be with bitmap_mutex held. * * @rb: the ramblock to operate on * @page: the page number to check @@ -71,7 +72,7 @@ static inline bool clear_bmap_test_and_clear(RAMBlock *rb= , uint64_t page) { uint8_t shift =3D rb->clear_bmap_shift; =20 - return bitmap_test_and_clear_atomic(rb->clear_bmap, page >> shift, 1); + return bitmap_test_and_clear(rb->clear_bmap, page >> shift, 1); } =20 static inline bool offset_in_ramblock(RAMBlock *b, ram_addr_t offset) diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index 6cbedf9e0c..adc03df59c 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -53,6 +53,9 @@ struct RAMBlock { * and split clearing of dirty bitmap on the remote node (e.g., * KVM). The bitmap will be set only when doing global sync. * + * It is only used during src side of ram migration, and it is + * protected by the global ram_state.bitmap_mutex. + * * NOTE: this bitmap is different comparing to the other bitmaps * in that one bit can represent multiple guest pages (which is * decided by the `clear_bmap_shift' variable below). On diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index 82a1d2f41f..3ccb00865f 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -253,6 +253,7 @@ void bitmap_set(unsigned long *map, long i, long len); void bitmap_set_atomic(unsigned long *map, long i, long len); void bitmap_clear(unsigned long *map, long start, long nr); bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr); +bool bitmap_test_and_clear(unsigned long *map, long start, long nr); void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src, long nr); unsigned long bitmap_find_next_zero_area(unsigned long *map, diff --git a/util/bitmap.c b/util/bitmap.c index f81d8057a7..8d12e90a5a 100644 --- a/util/bitmap.c +++ b/util/bitmap.c @@ -240,6 +240,51 @@ void bitmap_clear(unsigned long *map, long start, long= nr) } } =20 +bool bitmap_test_and_clear(unsigned long *map, long start, long nr) +{ + unsigned long *p =3D map + BIT_WORD(start); + const long size =3D start + nr; + int bits_to_clear =3D BITS_PER_LONG - (start % BITS_PER_LONG); + unsigned long mask_to_clear =3D BITMAP_FIRST_WORD_MASK(start); + bool dirty =3D false; + + assert(start >=3D 0 && nr >=3D 0); + + /* First word */ + if (nr - bits_to_clear > 0) { + if ((*p) & mask_to_clear) { + dirty =3D true; + } + *p &=3D ~mask_to_clear; + nr -=3D bits_to_clear; + bits_to_clear =3D BITS_PER_LONG; + p++; + } + + /* Full words */ + if (bits_to_clear =3D=3D BITS_PER_LONG) { + while (nr >=3D BITS_PER_LONG) { + if (*p) { + dirty =3D true; + *p =3D 0; + } + nr -=3D BITS_PER_LONG; + p++; + } + } + + /* Last word */ + if (nr) { + mask_to_clear &=3D BITMAP_LAST_WORD_MASK(size); + if ((*p) & mask_to_clear) { + dirty =3D true; + } + *p &=3D ~mask_to_clear; + } + + return dirty; +} + bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr) { unsigned long *p =3D map + BIT_WORD(start); --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669035644; cv=none; d=zohomail.com; s=zohoarc; b=l9xZ9eDBIFZqXDes7X0NMWJPBcYejVK43+pteXWeBWkyODwstgsgYaMuDleiw4XomNsSn72b3+ax2DpTg3h771aimsttxPJy7gIi4orsFWcxM43Oyn7tX9H+tavBaIwb9mjHkNacMgLyICWJJZCtB4BCTsIjm0hToLPuXW5iEIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035644; h=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=o0zwjIEQ0RGHrg3uupRJrCxkZxGKrVGbvF+zRHI8YNI=; b=Ur1tc0RDkw51Ux7O0/EWdpg4NgzzjaBoKjS0RGiWrTAim2+oed+QnA1PmE/dAdtN8GpDWqPHgcQt84q8dkYMNko7UrGlTE94L2Cl1m3VPVwU0Zy9WbPPCAzcN5PAJrKEoizCZZC+qG2eYcCeTXtRhud1JoJRRLUk8DeSZ6/6By0= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035644662583.4489831974155; Mon, 21 Nov 2022 05:00:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6P9-0001tw-JW; Mon, 21 Nov 2022 08:00:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6P8-0001si-8r for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:00:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6P5-0006XW-Bb for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:00:05 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-Ez6osqvMOOWF37znrdMTig-1; Mon, 21 Nov 2022 07:59:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0EA0801585; Mon, 21 Nov 2022 12:59:27 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18A8FC15BB3; Mon, 21 Nov 2022 12:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o0zwjIEQ0RGHrg3uupRJrCxkZxGKrVGbvF+zRHI8YNI=; b=MsO7w6q5Kux9llAAh02tIZC0LWVOfe/q52+3HZDvUSyMmuShWTHtNHZrp8Rm2Hhn0iDzSv tq1V3YnrUFxl8C5S54a3xIMIY+SDjPXZwRFqxRAn+Emg1XP5wiG+LUt3Ghm6/vzPV2040V MNtS2JcZyMl71X36gWLps18B4DUqYb0= X-MC-Unique: Ez6osqvMOOWF37znrdMTig-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini Subject: [PULL 7/8] migration: Disable multifd explicitly with compression Date: Mon, 21 Nov 2022 13:59:06 +0100 Message-Id: <20221121125907.62469-8-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669035650402100003 Content-Type: text/plain; charset="utf-8" From: Peter Xu Multifd thread model does not work for compression, explicitly disable it. Note that previuosly even we can enable both of them, nothing will go wrong, because the compression code has higher priority so multifd feature will just be ignored. Now we'll fail even earlier at config time so the user should be aware of the consequence better. Note that there can be a slight chance of breaking existing users, but let's assume they're not majority and not serious users, or they should have found that multifd is not working already. With that, we can safely drop the check in ram_save_target_page() for using multifd, because when multifd=3Don then compression=3Doff, then the removed check on save_page_use_compression() will also always return false too. Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/migration.c | 7 +++++++ migration/ram.c | 11 +++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index f3ed77a7d0..f485eea5fb 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1350,6 +1350,13 @@ static bool migrate_caps_check(bool *cap_list, } } =20 + if (cap_list[MIGRATION_CAPABILITY_MULTIFD]) { + if (cap_list[MIGRATION_CAPABILITY_COMPRESS]) { + error_setg(errp, "Multifd is not compatible with compress"); + return false; + } + } + return true; } =20 diff --git a/migration/ram.c b/migration/ram.c index 1d42414ecc..1338e47665 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2305,13 +2305,12 @@ static int ram_save_target_page(RAMState *rs, PageS= earchStatus *pss) } =20 /* - * Do not use multifd for: - * 1. Compression as the first page in the new block should be posted = out - * before sending the compressed page - * 2. In postcopy as one whole host page should be placed + * Do not use multifd in postcopy as one whole host page should be + * placed. Meanwhile postcopy requires atomic update of pages, so even + * if host page size =3D=3D guest page size the dest guest during run = may + * still see partially copied pages which is data corruption. */ - if (!save_page_use_compression(rs) && migrate_use_multifd() - && !migration_in_postcopy()) { + if (migrate_use_multifd() && !migration_in_postcopy()) { return ram_save_multifd_page(rs, block, offset); } =20 --=20 2.38.1 From nobody Sun May 12 00:39:44 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669035669; cv=none; d=zohomail.com; s=zohoarc; b=gm3rljpfnLUEfYpB2YxJC4A6w3b9uv9Hgg8el3oNgjjTL2lNk0B+tPkMKtIFPRoyz5KABlQ7XcpmVAOpHDqYg0+jUgYD51dR/Fkc+J+Gr7LQwV2VcfSF6p0jSue2Ow96BIA7kSumRIKRTf82xVViRdD6w6nsPzCk/3Xh1CWZySc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669035669; h=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=shYvfY1m4aFGTKlg3Ec60OJ8M+Vs1dd+K/kBHRLF7PM=; b=WH241RkvVe/Q3xj404TUTw3DfNE9rOz8oJsB7XhJqAHExb0X9fA3zK+BmNiN/3XyzH/vcVHoy9prSAHarx1tKI0/6y1HTwJN61JKzetNBKeho9+Qj/mStdqlhthvs3V2uu1l18I2uDQ6T8zP+ZCfCMbrXXFfe75QstK+GSlXqg4= ARC-Authentication-Results: i=1; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669035669276571.0277961647436; Mon, 21 Nov 2022 05:01:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ox6PC-0001xH-G9; Mon, 21 Nov 2022 08:00:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6P8-0001sk-6j for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:00:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ox6P6-0006cb-Jg for qemu-devel@nongnu.org; Mon, 21 Nov 2022 08:00:05 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-jaqLidZzPfqBVWmNNphoXw-1; Mon, 21 Nov 2022 07:59:30 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD39F382C96E; Mon, 21 Nov 2022 12:59:29 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1534BC15BB3; Mon, 21 Nov 2022 12:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669035603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=shYvfY1m4aFGTKlg3Ec60OJ8M+Vs1dd+K/kBHRLF7PM=; b=ZVrtPrIyS2bjHedMmpSOopzvW8PYOddGmi2vUwH+wKJ/O8Uy83kYfB//e7NbCU2QYijW6V PIL7pKT8fhswknuEAOplMReJKurMGLLA6fR/2EtmezxkxehZhp19XjVwRZ7M3bI6nfOZ/L gS8LIoaFNc5RAAGUrd5Deruc28VU5UQ= X-MC-Unique: jaqLidZzPfqBVWmNNphoXw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Dr. David Alan Gilbert" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , Juan Quintela , qemu-block@nongnu.org, David Hildenbrand , Peter Xu , Paolo Bonzini Subject: [PULL 8/8] migration: Block migration comment or code is wrong Date: Mon, 21 Nov 2022 13:59:07 +0100 Message-Id: <20221121125907.62469-9-quintela@redhat.com> In-Reply-To: <20221121125907.62469-1-quintela@redhat.com> References: <20221121125907.62469-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669035671043100001 Content-Type: text/plain; charset="utf-8" And it appears that what is wrong is the code. During bulk stage we need to make sure that some block is dirty, but no games with max_size at all. Signed-off-by: Juan Quintela Reviewed-by: Stefan Hajnoczi --- migration/block.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/block.c b/migration/block.c index 3577c815a9..4347da1526 100644 --- a/migration/block.c +++ b/migration/block.c @@ -880,8 +880,8 @@ static void block_save_pending(QEMUFile *f, void *opaqu= e, uint64_t max_size, blk_mig_unlock(); =20 /* Report at least one block pending during bulk phase */ - if (pending <=3D max_size && !block_mig_state.bulk_completed) { - pending =3D max_size + BLK_MIG_BLOCK_SIZE; + if (!pending && !block_mig_state.bulk_completed) { + pending =3D BLK_MIG_BLOCK_SIZE; } =20 trace_migration_block_save_pending(pending); --=20 2.38.1