From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676775; cv=none; d=zohomail.com; s=zohoarc; b=kDEjntl6HWivXwGKOXR6NIEEboD0685FwnJYHJyNMqTPsTaXk351bZqNMDL5eWJzZvLEnrvQnpz8scENAkQKcrpqS8363j28S0sbpP7G90UneepQvWaQoGRNjitSdI/y8jDzSeIPNHzGt7seA5PJIphvRz+e89egJTnJAoYmZEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676775; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2hkkcDDKW3DzXc310oMI/NYDVD946MPATIpbxQ70/iE=; b=l0ShPdM18MXyzZsO9GaWUL5trYjF9x4iGB/UycKaqBuWe8SOkWn2NtRRkC/ZDDE1hc9BKPJ7o7LDh/IIdE6SbL8PkYySCb/ChKqtXC4YwY53rrTVs5Omz+hlPhATBnQSA8G/wsxxKSxq3RaLq41mHmYGCOB/UFL+t43+5AWz75g= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676775558236.88145356149812; Wed, 8 Apr 2026 12:32:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYT4-0006Yj-BK; Wed, 08 Apr 2026 15:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY49-0006LU-3u for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:55:53 -0400 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 1wAWCF-00026z-LJ for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:10 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-oxB8IKRKMsSI7OsPv4PnRA-1; Wed, 08 Apr 2026 12:56:05 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50d8e4c29caso3423151cf.0 for ; Wed, 08 Apr 2026 09:56:05 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667366; 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=2hkkcDDKW3DzXc310oMI/NYDVD946MPATIpbxQ70/iE=; b=MRE5i90/LyoGKiisuNs0IgqmKtKECUnBp9vlz9QXsNiGMjuzIhn3qHCUGWMw/fbS9OZC58 wxeyjv4DS38OGGyNuXKWxDAlKO6/Tuz95d+DIr/3BZXk8WlcKdhA5HGVMpKAj89igv6BV8 LqQdIFO3y03iQtZwxqMsNW6E3IuSdgw= X-MC-Unique: oxB8IKRKMsSI7OsPv4PnRA-1 X-Mimecast-MFC-AGG-ID: oxB8IKRKMsSI7OsPv4PnRA_1775667364 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667364; x=1776272164; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2hkkcDDKW3DzXc310oMI/NYDVD946MPATIpbxQ70/iE=; b=G8wKDi1x5gzg3mdzxnkHCPbmoXL6vac8kKTnVdoyEPaq0weB2D1z1zpvDv0kSsRHo/ aViV98n1aoyzoEEdn8xhvKghQoy3Dy2cCUfL8tmXFlgv7Dvx89ZI8KK5r4x5mo3Ejznc uUHwAZTEyLR6gE/1LBgcMuDHTO5A1yyi0OdjAfili9mdXeCtzljszm89bK7G2nZHBUDF MJoVaTt1tYwF0o22OKs1i0qBwSsJwTLaClGP495BqRt8ECsGBQLlpWY5M2mytaxWmqMx VLLUqdUmVAG96exup1aRLtwvKtBMPUw7CrqvuwGEv9eaItw6lA5FHo0iM5rdygfTLf0t vNYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667364; x=1776272164; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2hkkcDDKW3DzXc310oMI/NYDVD946MPATIpbxQ70/iE=; b=K+jd0KjKR95w2+IQHPE8TTy0I2QZiMLggApZyIV3A6Hxzw/bYciWl6auIZVlzmqwe/ aIhdlYfjRH1DrtcBp994hh1hl1xyCMFabMKHtzPFG45Vwl/LD5fvz0t1Rj4QVUdiFwsf 2xgS+PkJ9cFXBM9WFWO5cucXHkyfDYKvNUetdsVDFNHjqWHzQ8sGIg6ZkSkDzX061JOH 8YfJ1NZJX/bXodxwzZFnjoK3yq/9fsvRLW5xQq0s+6d2vjsSz9R4wjH/rjiwXwAIXeeg awoOVkn22HxgUZobnCmqNMbHcTsFsal2b4qlGxk1ibA9Luv5Hc7kB1lP+bXwE3MqfeIo WTRQ== X-Gm-Message-State: AOJu0Yzf7sOLtVSSeTDSW4i1lj/AwUtm1MpxQcQEHS1R1QOi5uTvKvSv 02qxj7OVVnlfVfGRs+V5TA5wwJgmK+g4BDKnMWwk8YpspERCrK0bxDQ6+JdS2b4BFQh3/fqYdy0 MIKfTuK2swBkT2QBlV5gGlxmbYo18agR62nD+15vhB8CeM1IAHtQa7uR4LYAsXWRdKLmZhIIvnl KX6EVbcE/gHkTtsXLxa81sMODkE1y2buusoywLhw== X-Gm-Gg: AeBDietcodyWfntBSgYqzsJx0E1CwsLHyjzZv9i6aKZe+XHH5EUl7RSRK6SRYm8SruU He0HeqtpvO0tGLteJrcui3Ijj/JY5EuxE8M392BTcq5+CTr87SJj+fxZJsbd7Q/jqvfSMRuUhMU 2JHm9DsgeMjPT0aqub1i1TuWW6yGatjP7kaduvj/59qVdw64FCFUXubp8FCCyX4XvXcJgLNTK/T mKux3JENDQJQK017FLb7AZv3Q9LPvM1D/kpCoDFNS4na9rdI3Q2HKL9zBmKeLcKH8ZJrB6LSNO1 AuX0fvLvDDXQhy/QuxUX7Hgj4BemBmvoW8b0ytrxSZYYYJE9VsiaTRD8XqABzn8yPVNgO2S71IT vQekogn4Fe/s4GVLBV0GpzMMaZZDPTl8B+SeP5Anewv4I X-Received: by 2002:ac8:5f4f:0:b0:50d:a8f5:d519 with SMTP id d75a77b69052e-50da8f5de93mr92568191cf.14.1775667363724; Wed, 08 Apr 2026 09:56:03 -0700 (PDT) X-Received: by 2002:ac8:5f4f:0:b0:50d:a8f5:d519 with SMTP id d75a77b69052e-50da8f5de93mr92567241cf.14.1775667362810; Wed, 08 Apr 2026 09:56:02 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson , qemu-stable@nongnu.org Subject: [PATCH 01/14] migration: Fix low possibility downtime violation Date: Wed, 8 Apr 2026 12:55:45 -0400 Message-ID: <20260408165559.157108-2-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676776255154100 Content-Type: text/plain; charset="utf-8" When QEMU queried the estimated version of pending data and thinks it's ready to converge, it'll send another accurate query to make sure of it. It is needed to make sure we collect the latest reports and that equation still holds true. However we missed one tiny little difference here on "<" v.s. "<=3D" when comparing pending_size (A) to threshold_size (B).. QEMU src only re-query if A Signed-off-by: Peter Xu --- migration/migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 5c9aaa6e58..dfc60372cf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3242,7 +3242,7 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) * postcopy started, so ESTIMATE should always match with EXACT * during postcopy phase. */ - if (pending_size < s->threshold_size) { + if (pending_size <=3D s->threshold_size) { qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); pending_size =3D must_precopy + can_postcopy; trace_migrate_pending_exact(pending_size, must_precopy, --=20 2.53.0 From nobody Sat Apr 11 17:07:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1775667432; cv=none; d=zohomail.com; s=zohoarc; b=LQRxvi5UwSl6zfIYGswRFL3BW5MRejPsZz7Q4fRQQtsdNrYjSTckzjTNdNXlhms9MkG4BA8TPj0GlNWtvg17VQICX9YuNhw7EhSeTo47nYTrV/wMPqsYO3kN7H5lv4xIRMcv6WhWgdF3/cYwHB/od+WuDk3xt5vPKJ6eXUs0XlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775667432; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=vMp79kTswNcI5IIMHrzT1aaIDuja5B+32QTFFePbYkM=; b=ZHdM+6nBWtWsPm7fPmH5g3i+Sc0tYgeR2Az3UDC5N1cf6jLsP2yzgyti4ISZACEdVC8LfdIDxAxM1bBeeCRSqP5ZMdyRtlzl9BmX6k7S/GyIv15BFATxO1qTNMAAKgRXK2x6tlz/Vyiz0b3iu1NiDbmg1Y/eSmAWV39yGC2Yjug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775667432506578.9392121235039; Wed, 8 Apr 2026 09:57:12 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 7C280417FB; Wed, 8 Apr 2026 12:57:11 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id E3B56418B1; Wed, 8 Apr 2026 12:56:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E30C3417E1; Wed, 8 Apr 2026 12:56:09 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 153E23F8B0 for ; Wed, 8 Apr 2026 12:56:07 -0400 (EDT) Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-bxDCY3f0PDO8uYLHr651ug-1; Wed, 08 Apr 2026 12:56:05 -0400 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-8dacf883e77so30938685a.2 for ; Wed, 08 Apr 2026 09:56:05 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:03 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667366; 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=vMp79kTswNcI5IIMHrzT1aaIDuja5B+32QTFFePbYkM=; b=hI1N/a1C3xPY+DPS1ku97dAzD+Jo2I0vJvoOuJ5DxvdZVFM9nURPrDC3GWHfjkDZZQKP6R 6h82X+jbeTF7HSZ6blT0B6Zih+3Ec62uqr7j6cJUPhvgUfIYj8a21e+1AulOa/USpVenxP pd9PSAxOQUEkhOgdqWT75FaAZPe9Cto= X-MC-Unique: bxDCY3f0PDO8uYLHr651ug-1 X-Mimecast-MFC-AGG-ID: bxDCY3f0PDO8uYLHr651ug_1775667365 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667365; x=1776272165; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vMp79kTswNcI5IIMHrzT1aaIDuja5B+32QTFFePbYkM=; b=TqHEHLPw+S1vGeoNy6WS1MMTVnaU4hu+BY91ttfgdHozbDxA11hBKlFWEKy7zHathH 4z65Jcc9ChUZUQxjwvmWcqfatvGDlXvqynLPusjtozsYrr+7q2Kn/cTDe3M0AagvOM/J oqOjjh7aD6QTUN1kRED1aiu+uVM8+vUN5Y21WORnaxrAHXpdM5K3r9MYK8yfuuMHdwSA 8T83GZyHMOMqF11AkzRJdt63t2q8gn0xy38GRc6eg8sO/3Dckkjdo63OauVqpnH0Nd5G SIkceOGzPPQ3gzlcNeSWJrQew+UErMe7Gs5KEdAojKY0wfHQLaRwcIT2vs0upyXPbDIv xhAg== X-Forwarded-Encrypted: i=1; AJvYcCXJYlPTlhrLqgZJl3IOw9IC+52ILOhVTvmp/EXdtXJuY8uJblgYRI9sCPpTdFV7pEZmdalvjQ==@lists.libvirt.org X-Gm-Message-State: AOJu0Yz417zbqOTF/8jQD9PMVN8EsUCv1V1QNcO7aEv6XWX0CheG6nrV 1HPHEiHTynPilhz4McFNBQpe7q/0WKmRKA/cuKox7j0LdVVPCfjMUaUPUFn6PmmjHva8kd5k480 3RG2WY7CSoZMU4vyHzMA3S0iH/5UrzDwrgU3+gMUVLQvOHo5P/4YlirKWrzc= X-Gm-Gg: AeBDiesI/G/zccoT6+fQUOdn52BHJLcQTdInAR6vtgvC0+dj6sv7CsB1p4ejHkQxmAC 2qHYNcmGQo40YXtgAUexxpaYKdvfPcxuhiZY2/DVlPAbgVul6ym07CtTnJDYws3hLQl+oLtSMUO Kmpxj6qN2vLTAGHE3rH3KrXgW7cLBvRbCH8fRN26AcTY5x3PtOgIjB5QJnSPkxblkQVye2qhQWI JEFkuInjWg4B8Yi53LEBWYLG6TTxMRcEHsgbXwbYvhuCBOvsbXQG/4SYwyOb9uiwAIUXt0aKgDd c4pMwAphwpHpEjGiw5KrRXbtBqPxO1qKjjrqkaTRtdaYgNOiN2oAc5tL3mmAO+q02puamT4nfJU v/jFcRVoALVJep5Ot6Rc4s5jwsxfo49Hd71IFiHKF1mzp X-Received: by 2002:ac8:5cd0:0:b0:50d:85c1:3616 with SMTP id d75a77b69052e-50dc2261277mr1108001cf.43.1775667364866; Wed, 08 Apr 2026 09:56:04 -0700 (PDT) X-Received: by 2002:ac8:5cd0:0:b0:50d:85c1:3616 with SMTP id d75a77b69052e-50dc2261277mr1107391cf.43.1775667364247; Wed, 08 Apr 2026 09:56:04 -0700 (PDT) To: qemu-devel@nongnu.org Subject: [PATCH 02/14] migration/qapi: Rename MigrationStats to MigrationRAMStats Date: Wed, 8 Apr 2026 12:55:46 -0400 Message-ID: <20260408165559.157108-3-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 3i7jwa7vvZRCcz5V0ShDMtFQ6saihxjfVCEDyga0Zj4_1775667365 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID-Hash: O2SFZMRZD5IKJMU74RZTPYUTVJIXJGLD X-Message-ID-Hash: O2SFZMRZD5IKJMU74RZTPYUTVJIXJGLD X-MailFrom: peterx@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: "Maciej S . Szmigiero" , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson , devel@lists.libvirt.org X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Xu via Devel Reply-To: Peter Xu X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1775667435760154100 This stats is only about RAM, make it accurate. This paves way for statistics for all devices. Thanks to Markus, who pointed out that docs/devel/qapi-code-gen.rst has a section "Compatibility considerations" stated: Since type names are not visible in the Client JSON Protocol, types may be freely renamed. Even certain refactorings are invisible, such as splitting members from one type into a common base type. Hence this change is not ABI violation according to the document. While at it, touch up the lines to make it read better, correct the restriction on migration status being 'active' or 'completed': over time we grew too many new status that will also report "ram" section. Cc: Daniel P. Berrang=C3=A9 Cc: devel@lists.libvirt.org Reviewed-by: Markus Armbruster Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin Reviewed-by: Michal Privoznik --- docs/about/removed-features.rst | 2 +- qapi/migration.json | 10 +++++----- migration/migration-stats.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/about/removed-features.rst b/docs/about/removed-features.= rst index 557a24679a..ccd49b5615 100644 --- a/docs/about/removed-features.rst +++ b/docs/about/removed-features.rst @@ -699,7 +699,7 @@ was superseded by ``sections``. ``query-migrate`` return value member ``skipped`` (removed in 9.1) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' =20 -Member ``skipped`` of the ``MigrationStats`` struct hasn't been used +Member ``skipped`` of the ``MigrationRAMStats`` struct hasn't been used for more than 10 years. Removed with no replacement. =20 ``migrate`` command option ``inc`` (removed in 9.1) diff --git a/qapi/migration.json b/qapi/migration.json index 7134d4ce47..e3ad3f0604 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -12,7 +12,7 @@ { 'include': 'sockets.json' } =20 ## -# @MigrationStats: +# @MigrationRAMStats: # # Detailed migration status. # @@ -64,7 +64,7 @@ # # Since: 0.14 ## -{ 'struct': 'MigrationStats', +{ 'struct': 'MigrationRAMStats', 'data': {'transferred': 'int', 'remaining': 'int', 'total': 'int' , 'duplicate': 'int', 'normal': 'int', @@ -209,8 +209,8 @@ # If this field is not returned, no migration process has been # initiated # -# @ram: `MigrationStats` containing detailed migration status, only -# returned if status is 'active' or 'completed'(since 1.2) +# @ram: Detailed migration RAM statistics, only returned if migration +# is in progress or completed (since 1.2) # # @xbzrle-cache: `XBZRLECacheStats` containing detailed XBZRLE # migration statistics, only returned if XBZRLE feature is on and @@ -309,7 +309,7 @@ # Since: 0.14 ## { 'struct': 'MigrationInfo', - 'data': {'*status': 'MigrationStatus', '*ram': 'MigrationStats', + 'data': {'*status': 'MigrationStatus', '*ram': 'MigrationRAMStats', '*vfio': 'VfioStats', '*xbzrle-cache': 'XBZRLECacheStats', '*total-time': 'int', diff --git a/migration/migration-stats.h b/migration/migration-stats.h index c0f50144c9..1153520f7a 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -27,7 +27,7 @@ =20 /* * These are the ram migration statistic counters. It is loosely - * based on MigrationStats. + * based on MigrationRAMStats. */ typedef struct { /* --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775677156; cv=none; d=zohomail.com; s=zohoarc; b=e5GvNL2urVOfixxP6xv2llmNJ/2h9TWBVJeZmkoRUp1gO4YeES3A7wzhpLnaYE8QeXuv+/+UvecPADwAD5m/KMOCO47y+pcAHXf6dj2C29GRThYZdoTf2+/OwFG5l+3B1M4+ytljZI08BmN0LNc/hq85fQnBHIKppMkQ0eLHqp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775677156; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=O0kLvM+Gei19WRwCTbcZcMBvammqKpOVcflr0Var+P0=; b=aLmm4+mTM5nnqE31ZatKLdoPKKllpLXpRiYIiIJgKVdTHP8STDqC7+m7AEOwyTgEWplfXZRwjlxfbtXiKaw9bqWnoBhYEkOqBv3s6JBDXl6Z4GfHgE7Br41Ebzbeu6VsFMtz46pZZwLNxPFm0WkjdYQR7+x/LLrXIRUF58EqYwk= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775677156769382.60538815443533; Wed, 8 Apr 2026 12:39:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYc1-0004T5-Kj; Wed, 08 Apr 2026 15:30:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAYA0-0000eP-6E for qemu-devel@nongnu.org; Wed, 08 Apr 2026 15:01:56 -0400 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 1wAWCH-00027V-Jm for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:11 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-6u8ACfTEOH6qaFTmWXXM1w-1; Wed, 08 Apr 2026 12:56:07 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50b52a2d70cso3165141cf.3 for ; Wed, 08 Apr 2026 09:56:07 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667369; 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=O0kLvM+Gei19WRwCTbcZcMBvammqKpOVcflr0Var+P0=; b=TOxsC97SY+/CqdyxPyWbwwTN2iXkEGi+4+viWa8QvhthtNsuvMpO4CpFqnMNFhiiC4gJoP QYB2R/BKQqjocs/EjXRU+hngRvt3xxCB/onLOS8njRgAXI6/pDKZFLhalc6E/Bl9cOjdXr 0U0MGfuolKzkMi5M9ua7IKgg93vmC5Q= X-MC-Unique: 6u8ACfTEOH6qaFTmWXXM1w-1 X-Mimecast-MFC-AGG-ID: 6u8ACfTEOH6qaFTmWXXM1w_1775667367 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667366; x=1776272166; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O0kLvM+Gei19WRwCTbcZcMBvammqKpOVcflr0Var+P0=; b=DDZlKDEgEq03sIhsAAWpseF9NY3sC/xZQ+CpfoyUMKyjp379DeuiqfpBIZAY5J1CPJ jI1Jf8ugh+QMjxzbHxPRLxA4edDVyFlvlmr+kbMrpvo4im9SvcIi+oN5iAEmsJl0d4kV BX6joadC9Zq2ZjIaBWMN19qhVNbasIUOZuTHLaOz54ImQ22z31DaG5synaMBlmKspEpN Uzu6qCykXud3whBP5RxOOqSO6SlVQSDPJM8jT2QQIq1ErXEXbe15RPkjhU0RstYfviqs lIxW6rHe9E+WFvs/c+6867t8E6VwLMqLeIZFzWxySljmkvLztTPHpK3cUoHTg1hihS9u JgLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667366; x=1776272166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=O0kLvM+Gei19WRwCTbcZcMBvammqKpOVcflr0Var+P0=; b=p++CQpcXg2T0FbtX6mztUBvKeax2aORg/9eQKfUzXIp0lh0EimVyQWUfDuA1Ly6g3B ZGk9ZnyViZ5zuTsCqxS7NhUb8zW5eORBa1yjVLpfrldVJNkQfHVC+Kx+ynQrGYizbAAG w6PrB6sBmfcWBETgKTMKGAK2X2LOOADnLbtDFWWjNk9DXbsAv3k/SOQhniEoIvVzrppc gCxD/wATSfZIj8lbhkNDWLPW+JCJUKmelCxY0Bp8IbmxRaSE1r0zZYa6SxfYFWPzczXo Xp6jRJuGJ+zAhOzBae5NgcqvT1hweH9ny8z2dHmkIjV7vjUCaDYfVoPag2dtNT6PXwOo yzAQ== X-Gm-Message-State: AOJu0YyNai20Xzv4HNLf2hXzr/IhfdtOsHVwgyGxvAgHHjUKLo7aN0Di WO9ByBaeUfQpfB5UnK/lsSZNaumenOT6unmnA4v+ug0EoihtEGeejBdJTGDzHUiYlzEwhrPxbNM dT1fuOKEn2lsc2Xkqykf74Fvnr0f7R5YL3uVMV8SMeyd0Abkv/YjFngk9fTtpsrx1H+Ajm03+HU O6/o5VWg0Pi5Q0xcNzQmcX8MPiVpKP8NTjAicoZg== X-Gm-Gg: AeBDiesx48/EEo203r/xVn0J5GoP8hDYCa197BeSS5umjMXhOy0YROW148DW9Y67dpp Q6ZIHkaLX3Fwm3aojIrczmC4SIHux7bz8rW3R5l9CVPl7wK7b4h+Fme7B4EiENdUFzTeYMm1qfh cdPrUkWJQy7j3q+5LbHgydYajCVXecb7iglkihn0WD5U1J13QCF97xBZR0pRDmnYU9QuKxfehTk EtOoYyr15CqcKvVVZEXvlU9IQHXtI5S43NhGz466/nqUfQZQYSPVAy4gg/deuTvkPZd4Q+lSi/k /CBbuulgNHlH++aeWN/RnvbRm+AQmbs8G84TltF66wQrodXiqnujPCszTgIh7F/6haV+3ZdsxAt E08EZpZLaGe7SnYNcMqQRqulN2GdQK9Ls+oUM9ZPO/C38 X-Received: by 2002:ac8:6f0d:0:b0:50d:9d34:3b3c with SMTP id d75a77b69052e-50d9d343ca6mr147835321cf.64.1775667366271; Wed, 08 Apr 2026 09:56:06 -0700 (PDT) X-Received: by 2002:ac8:6f0d:0:b0:50d:9d34:3b3c with SMTP id d75a77b69052e-50d9d343ca6mr147834631cf.64.1775667365576; Wed, 08 Apr 2026 09:56:05 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 03/14] vfio/migration: Cache stop size in VFIOMigration Date: Wed, 8 Apr 2026 12:55:47 -0400 Message-ID: <20260408165559.157108-4-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775677158366158500 Content-Type: text/plain; charset="utf-8" Add a field to cache stop size. Note that there's an initial value change in vfio_save_setup for the stop size default, but it shouldn't matter if it is followed with a math of MIN() against VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE. Document that all the three sizes we read from VFIO's uAPI on dirty or stop sizes are estimates, so QEMU needs to always remember they can be anything. Signed-off-by: Peter Xu --- hw/vfio/vfio-migration-internal.h | 8 +++++ hw/vfio/migration.c | 50 ++++++++++++++++++------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-int= ernal.h index 814fbd9eba..a15fc74703 100644 --- a/hw/vfio/vfio-migration-internal.h +++ b/hw/vfio/vfio-migration-internal.h @@ -45,8 +45,16 @@ typedef struct VFIOMigration { void *data_buffer; size_t data_buffer_size; uint64_t mig_flags; + /* + * NOTE: all three sizes cached are reported from VFIO's uAPI, which + * are defined as estimate only. QEMU should not trust these values + * but only use them to do best-effort estimates. Always be prepared + * that these sizes may either grow or even shrink in reality while + * read()ing from the VFIO fds. + */ uint64_t precopy_init_size; uint64_t precopy_dirty_size; + uint64_t stopcopy_size; bool multifd_transfer; VFIOMultifd *multifd; bool initial_data_sent; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 83327b6573..5d5fca09bd 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -41,6 +41,12 @@ */ #define VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE (1 * MiB) =20 +/* + * Migration size of VFIO devices can be as little as a few KBs or as big = as + * many GBs. This value should be big enough to cover the worst case. + */ +#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB) + static unsigned long bytes_transferred; =20 static const char *mig_state_to_str(enum vfio_device_mig_state state) @@ -314,8 +320,7 @@ static void vfio_migration_cleanup(VFIODevice *vbasedev) migration->data_fd =3D -1; } =20 -static int vfio_query_stop_copy_size(VFIODevice *vbasedev, - uint64_t *stop_copy_size) +static int vfio_query_stop_copy_size(VFIODevice *vbasedev) { uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + sizeof(struct vfio_device_feature_mig_data_s= ize), @@ -323,16 +328,22 @@ static int vfio_query_stop_copy_size(VFIODevice *vbas= edev, struct vfio_device_feature *feature =3D (struct vfio_device_feature *)= buf; struct vfio_device_feature_mig_data_size *mig_data_size =3D (struct vfio_device_feature_mig_data_size *)feature->data; + VFIOMigration *migration =3D vbasedev->migration; =20 feature->argsz =3D sizeof(buf); feature->flags =3D VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_MIG_DATA_SIZE; =20 if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) { + /* + * If getting pending migration size fails, VFIO_MIG_STOP_COPY_SIZE + * is reported so downtime limit won't be violated. + */ + migration->stopcopy_size =3D VFIO_MIG_STOP_COPY_SIZE; return -errno; } =20 - *stop_copy_size =3D mig_data_size->stop_copy_length; + migration->stopcopy_size =3D mig_data_size->stop_copy_length; =20 return 0; } @@ -409,6 +420,16 @@ static void vfio_update_estimated_pending_data(VFIOMig= ration *migration, return; } =20 + /* + * The total size remaining requires separate accounting. Do not trust + * the counter, so what we have read() may be more than what reported. + */ + if (migration->stopcopy_size > data_size) { + migration->stopcopy_size -=3D data_size; + } else { + migration->stopcopy_size =3D 0; + } + if (migration->precopy_init_size) { uint64_t init_size =3D MIN(migration->precopy_init_size, data_size= ); =20 @@ -463,7 +484,6 @@ static int vfio_save_setup(QEMUFile *f, void *opaque, E= rror **errp) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; - uint64_t stop_copy_size =3D VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE; int ret; =20 if (!vfio_multifd_setup(vbasedev, false, errp)) { @@ -472,9 +492,9 @@ static int vfio_save_setup(QEMUFile *f, void *opaque, E= rror **errp) =20 qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE); =20 - vfio_query_stop_copy_size(vbasedev, &stop_copy_size); + vfio_query_stop_copy_size(vbasedev); migration->data_buffer_size =3D MIN(VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE, - stop_copy_size); + migration->stopcopy_size); migration->data_buffer =3D g_try_malloc0(migration->data_buffer_size); if (!migration->data_buffer) { error_setg(errp, "%s: Failed to allocate migration data buffer", @@ -570,32 +590,22 @@ static void vfio_state_pending_estimate(void *opaque,= uint64_t *must_precopy, migration->precopy_dirty_size); } =20 -/* - * Migration size of VFIO devices can be as little as a few KBs or as big = as - * many GBs. This value should be big enough to cover the worst case. - */ -#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB) - static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; - uint64_t stop_copy_size =3D VFIO_MIG_STOP_COPY_SIZE; =20 - /* - * If getting pending migration size fails, VFIO_MIG_STOP_COPY_SIZE is - * reported so downtime limit won't be violated. - */ - vfio_query_stop_copy_size(vbasedev, &stop_copy_size); - *must_precopy +=3D stop_copy_size; + vfio_query_stop_copy_size(vbasedev); + *must_precopy +=3D migration->stopcopy_size; =20 if (vfio_device_state_is_precopy(vbasedev)) { vfio_query_precopy_size(migration); } =20 trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_pos= tcopy, - stop_copy_size, migration->precopy_init= _size, + migration->stopcopy_size, + migration->precopy_init_size, migration->precopy_dirty_size); } =20 --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775673171; cv=none; d=zohomail.com; s=zohoarc; b=Z9qOeWbVGRZjedpd3K66R5h0lTpiRRHMeuo2Pf7K7PmzePbIXr5pzzz+mUUFrIxmRFdaW6Ie43VMsFdxZ22XOCUGuvbPWdKz20LOQDurPnenIw8quGaah4sNbu0q9hNOJ+lcyx4uNMdJIOYF/ymaxRfQA7GapD2P6k/ObMTprCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775673171; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WOqCyr+uacNL0UIuIW1odLrqvT874GQkA9dQ0lHxz1Q=; b=Ii4pxEr3a8VdegrtlnV0iujkPFgdx2llEmShy2hZE/Bns6+bF4i2yWOpJSfXWwuiOsV0LAmJcsqj5Wct+/frYryKcwviXnjfhVJymLuqw/WT0Qdfr7tkKY9OUHo8jB1bJu88wrS0LCq9EUXp5Nq4QfCO9xdieSSwEBasFtRDBJw= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775673171541288.5535623191547; Wed, 8 Apr 2026 11:32:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAXh8-0007vA-Ie; Wed, 08 Apr 2026 14:32:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAXh6-0007go-Vv for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:32:05 -0400 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 1wAWCI-00027d-W2 for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:13 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-Dx_eNlwUN92jTqmh11fxEQ-1; Wed, 08 Apr 2026 12:56:09 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-50b3544bc7bso1160221cf.2 for ; Wed, 08 Apr 2026 09:56:09 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667370; 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=WOqCyr+uacNL0UIuIW1odLrqvT874GQkA9dQ0lHxz1Q=; b=Aw/S1dKnUrFWx+UiYbnxAeheMetBnQVwXJQQaSijhjsHp/l62FUeB/EbdCvQGTBpTqsRMb uCd5RAXKH3jdHYYLvhfp1b5inBp8lYzG8xPl2ku6nbUdxZPnSwEZBoGWLPFAgq7zei37HD FnrtVqvz9yNf6HdN9y8aJc+KUNhn4T0= X-MC-Unique: Dx_eNlwUN92jTqmh11fxEQ-1 X-Mimecast-MFC-AGG-ID: Dx_eNlwUN92jTqmh11fxEQ_1775667369 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667368; x=1776272168; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WOqCyr+uacNL0UIuIW1odLrqvT874GQkA9dQ0lHxz1Q=; b=JM8sXfXEKR5ylJPHZgXzgv7Hui7NhlKHm4ZL+hMQpapy79I/mqli5tX1Y5sYwlo6VZ ZbE6reqyU5L3kQA2jzDfCbMXgy1uOwXmYIvPM374eL1BabR+Jvd+0BS1Ii7exedmOpO+ QDhfIlU1UioIxa8nP7hanqEwe8T55iLKlAhzZ0zKQHGDSJ7waqWeP05A0JBt0bTnt2rP 5RKMQgrbkC0mP4AWlSuGOXjEvkpVJ98CQQlS1OVqx77DLptolOmaHYA96GcSAWTjzTVF 0eR76TgSHi/kycRi30YSSs99HZNPJmb7I5siWWdWgcgoUst6mhcazdV4f01gfFgwjXQm zD0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667368; x=1776272168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WOqCyr+uacNL0UIuIW1odLrqvT874GQkA9dQ0lHxz1Q=; b=nk5d4BG1zwYPNpfEHj9Yuzp0dKC1qPNoEbmsyk5D30tmKsOoxCwUhxaKGbn0wAY8lG LZJQyJxh324Izr9hD6CDvb9V1RF3RPNvS6Rs4lWoeiYj6nGZ0L5gqHplqXzVzn+QHKba VJbVfoYCmCe/p9EgE+TV8AnHB9GfL6tT0qPukBeH0eSfiai4dzR7QytoJWZYPe9xfqMr 4ewZpunivWX7NtcNiYDEvmuxd1gx0ba3pLQ5JMBlPFc0X9+fd9Gk0ZCt70nhh/4CTMvb yF64QrqD1RY1AJUJfXhvsg26d1jI68xbp4UVK9MZYnBiZJlP5uD0e1Q0WXf1O7EIDbME RNkQ== X-Gm-Message-State: AOJu0Yxdcm/fYOjab5PUNAUO0M997Du9p9ABdTq5SCqCXbbQJ4V4/hcz bpNj2v0ZmUhP4ckNe/PCb4ScDt5n3XrQVOMgChEYJ4l8UZE9+DRMgLea946Rex6IcKYvQsuK5Jv 0zaBqxH+Y/RG7ty/ijNfmLtuQieX3mYWhamOfYmXBUYfiOMUpL6fz0Z5Vf3KOa/YdYcxjdzVWs5 KlTg73/4WmIBIctp/vihYLstVw2fW9b5/IusaAqQ== X-Gm-Gg: AeBDietjPSFOMx+qGS/OKfVL619hLWYS6gZkOl/xbyxQwbJE0ttvuspJMjWCXFJV6yD 9otfNcEEsj7krcuWE/2+TFQsAjabohH7mljd4Q4pW9Na3xZCxtCgDxXCvuRX2UrtNcH6xS8qWN5 0il6ks5ZuCQdr93G+kzzZsbpYCvHPgsElSSfhn7WYw5LnYNfEblMJ0+b6snrkbMUNQkX36cciLC A0rw50U9BaLvEE1kXXGI066/NUrfz9eAajVXTHbM+14tlu9PBpfuQ23+DN2aBNnZUPown+wTw9N yeCJKsqn687mjc/0zpjZu06/Xr3Jwt3z04xdTbHR6hYN1LMv1olNsvWC98W07gGbgrLnE08g4bn HFCgHqWpxqpU5LP4XZ4tM4xP77aOVnDYxdrYjLS13GvtT X-Received: by 2002:a05:622a:5a17:b0:509:372e:35f5 with SMTP id d75a77b69052e-50d62b705fcmr315555001cf.55.1775667368206; Wed, 08 Apr 2026 09:56:08 -0700 (PDT) X-Received: by 2002:a05:622a:5a17:b0:509:372e:35f5 with SMTP id d75a77b69052e-50d62b705fcmr315553971cf.55.1775667367348; Wed, 08 Apr 2026 09:56:07 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson , Halil Pasic , Christian Borntraeger , Jason Herne , Eric Farman , Matthew Rosato , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Cornelia Huck , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow Subject: [PATCH 04/14] migration/treewide: Merge @state_pending_{exact|estimate} APIs Date: Wed, 8 Apr 2026 12:55:48 -0400 Message-ID: <20260408165559.157108-5-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775673173890158500 Content-Type: text/plain; charset="utf-8" These two APIs are a slight duplication. For example, there're a few users that directly pass in the same function. It might also be error prone to provide two hooks, so that it's easier to happen one module report different things via the two hooks. In reality, they should always report the same thing, only about whether we should use a fast-path when the slow path might be too slow, as QEMU may query these information quite frequently during migration process. Merge it into one API, provide a bool showing if the query is an exact query or not. No functional change intended. Export qemu_savevm_query_pending(). We should use the new API here provided when there're new users to do the query. This will happen very soon. Cc: Halil Pasic Cc: Christian Borntraeger Cc: Jason Herne Cc: Eric Farman Cc: Matthew Rosato Cc: Richard Henderson Cc: Ilya Leoshkevich Cc: David Hildenbrand Cc: Cornelia Huck Cc: Eric Blake Cc: Vladimir Sementsov-Ogievskiy Cc: John Snow Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin --- docs/devel/migration/main.rst | 9 ++---- docs/devel/migration/vfio.rst | 9 ++---- include/migration/register.h | 52 +++++++++++----------------------- migration/savevm.h | 3 ++ hw/s390x/s390-stattrib.c | 9 +++--- hw/vfio/migration.c | 48 ++++++++++++++----------------- migration/block-dirty-bitmap.c | 10 +++---- migration/ram.c | 33 +++++++-------------- migration/savevm.c | 42 +++++++++++++-------------- hw/vfio/trace-events | 3 +- 10 files changed, 84 insertions(+), 134 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 234d280249..e6a6ca3681 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -515,13 +515,8 @@ An iterative device must provide: - A ``load_setup`` function that initialises the data structures on the destination. =20 - - A ``state_pending_exact`` function that indicates how much more - data we must save. The core migration code will use this to - determine when to pause the CPUs and complete the migration. - - - A ``state_pending_estimate`` function that indicates how much more - data we must save. When the estimated amount is smaller than the - threshold, we call ``state_pending_exact``. + - A ``save_query_pending`` function that indicates how much more + data we must save. =20 - A ``save_live_iterate`` function should send a chunk of data until the point that stream bandwidth limits tell it to stop. Each call diff --git a/docs/devel/migration/vfio.rst b/docs/devel/migration/vfio.rst index 0790e5031d..33768c877c 100644 --- a/docs/devel/migration/vfio.rst +++ b/docs/devel/migration/vfio.rst @@ -50,13 +50,8 @@ VFIO implements the device hooks for the iterative appro= ach as follows: * A ``load_setup`` function that sets the VFIO device on the destination in _RESUMING state. =20 -* A ``state_pending_estimate`` function that reports an estimate of the - remaining pre-copy data that the vendor driver has yet to save for the V= FIO - device. - -* A ``state_pending_exact`` function that reads pending_bytes from the ven= dor - driver, which indicates the amount of data that the vendor driver has ye= t to - save for the VFIO device. +* A ``save_query_pending`` function that reports the remaining pre-copy + data that the vendor driver has yet to save for the VFIO device. =20 * An ``is_active_iterate`` function that indicates ``save_live_iterate`` is active only when the VFIO device is in pre-copy states. diff --git a/include/migration/register.h b/include/migration/register.h index d0f37f5f43..aba3c9af2f 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -16,6 +16,13 @@ =20 #include "hw/core/vmstate-if.h" =20 +typedef struct MigPendingData { + /* Amount of pending bytes can be transferred in precopy or stopcopy */ + uint64_t precopy_bytes; + /* Amount of pending bytes can be transferred in postcopy */ + uint64_t postcopy_bytes; +} MigPendingData; + /** * struct SaveVMHandlers: handler structure to finely control * migration of complex subsystems and devices, such as RAM, block and @@ -197,46 +204,19 @@ typedef struct SaveVMHandlers { bool (*save_postcopy_prepare)(QEMUFile *f, void *opaque, Error **errp); =20 /** - * @state_pending_estimate - * - * This estimates the remaining data to transfer - * - * Sum of @can_postcopy and @must_postcopy is the whole amount of - * pending data. - * - * @opaque: data pointer passed to register_savevm_live() - * @must_precopy: amount of data that must be migrated in precopy - * or in stopped state, i.e. that must be migrated - * before target start. - * @can_postcopy: amount of data that can be migrated in postcopy - * or in stopped state, i.e. after target start. - * Some can also be migrated during precopy (RAM). - * Some must be migrated after source stops - * (block-dirty-bitmap) - */ - void (*state_pending_estimate)(void *opaque, uint64_t *must_precopy, - uint64_t *can_postcopy); - - /** - * @state_pending_exact - * - * This calculates the exact remaining data to transfer + * @save_query_pending * - * Sum of @can_postcopy and @must_postcopy is the whole amount of - * pending data. + * This estimates the remaining data to transfer on the source side. + * It's highly suggested that the module should implement both fastpath + * and slowpath version of it when it can be slow (for more information + * please check pending->fastpath field). * * @opaque: data pointer passed to register_savevm_live() - * @must_precopy: amount of data that must be migrated in precopy - * or in stopped state, i.e. that must be migrated - * before target start. - * @can_postcopy: amount of data that can be migrated in postcopy - * or in stopped state, i.e. after target start. - * Some can also be migrated during precopy (RAM). - * Some must be migrated after source stops - * (block-dirty-bitmap) + * @pending: pointer to a MigPendingData struct + * @exact: set true for an accurate (slow) query */ - void (*state_pending_exact)(void *opaque, uint64_t *must_precopy, - uint64_t *can_postcopy); + void (*save_query_pending)(void *opaque, MigPendingData *pending, + bool exact); =20 /** * @load_state diff --git a/migration/savevm.h b/migration/savevm.h index b3d1e8a13c..e4efd243f3 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -14,6 +14,8 @@ #ifndef MIGRATION_SAVEVM_H #define MIGRATION_SAVEVM_H =20 +#include "migration/register.h" + #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_VM_FILE_VERSION_COMPAT 0x00000002 #define QEMU_VM_FILE_VERSION 0x00000003 @@ -43,6 +45,7 @@ int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(MigrationState *s); +void qemu_savevm_query_pending(MigPendingData *pending, bool exact); void qemu_savevm_state_pending_exact(uint64_t *must_precopy, uint64_t *can_postcopy); void qemu_savevm_state_pending_estimate(uint64_t *must_precopy, diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index d808ece3b9..a22469a9e9 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -187,15 +187,15 @@ static int cmma_save_setup(QEMUFile *f, void *opaque,= Error **errp) return 0; } =20 -static void cmma_state_pending(void *opaque, uint64_t *must_precopy, - uint64_t *can_postcopy) +static void cmma_state_pending(void *opaque, MigPendingData *pending, + bool exact) { S390StAttribState *sas =3D S390_STATTRIB(opaque); S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); long long res =3D sac->get_dirtycount(sas); =20 if (res >=3D 0) { - *must_precopy +=3D res; + pending->precopy_bytes +=3D res; } } =20 @@ -340,8 +340,7 @@ static SaveVMHandlers savevm_s390_stattrib_handlers =3D= { .save_setup =3D cmma_save_setup, .save_live_iterate =3D cmma_save_iterate, .save_complete =3D cmma_save_complete, - .state_pending_exact =3D cmma_state_pending, - .state_pending_estimate =3D cmma_state_pending, + .save_query_pending =3D cmma_state_pending, .save_cleanup =3D cmma_save_cleanup, .load_state =3D cmma_load, .is_active =3D cmma_active, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 5d5fca09bd..1e999f0040 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -571,42 +571,39 @@ static void vfio_save_cleanup(void *opaque) trace_vfio_save_cleanup(vbasedev->name); } =20 -static void vfio_state_pending_estimate(void *opaque, uint64_t *must_preco= py, - uint64_t *can_postcopy) +static void vfio_state_pending_sync(VFIODevice *vbasedev) { - VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; =20 - if (!vfio_device_state_is_precopy(vbasedev)) { - return; - } - - *must_precopy +=3D - migration->precopy_init_size + migration->precopy_dirty_size; + vfio_query_stop_copy_size(vbasedev); =20 - trace_vfio_state_pending_estimate(vbasedev->name, *must_precopy, - *can_postcopy, - migration->precopy_init_size, - migration->precopy_dirty_size); + if (vfio_device_state_is_precopy(vbasedev)) { + vfio_query_precopy_size(migration); + } } =20 -static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy, - uint64_t *can_postcopy) +static void vfio_state_pending(void *opaque, MigPendingData *pending, + bool exact) { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; + uint64_t remain; =20 - vfio_query_stop_copy_size(vbasedev); - *must_precopy +=3D migration->stopcopy_size; - - if (vfio_device_state_is_precopy(vbasedev)) { - vfio_query_precopy_size(migration); + if (exact) { + vfio_state_pending_sync(vbasedev); + remain =3D migration->stopcopy_size; + } else { + if (!vfio_device_state_is_precopy(vbasedev)) { + return; + } + remain =3D migration->precopy_init_size + migration->precopy_dirty= _size; } =20 - trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_pos= tcopy, - migration->stopcopy_size, - migration->precopy_init_size, - migration->precopy_dirty_size); + pending->precopy_bytes +=3D remain; + + trace_vfio_state_pending(vbasedev->name, migration->stopcopy_size, + migration->precopy_init_size, + migration->precopy_dirty_size); } =20 static bool vfio_is_active_iterate(void *opaque) @@ -851,8 +848,7 @@ static const SaveVMHandlers savevm_vfio_handlers =3D { .save_prepare =3D vfio_save_prepare, .save_setup =3D vfio_save_setup, .save_cleanup =3D vfio_save_cleanup, - .state_pending_estimate =3D vfio_state_pending_estimate, - .state_pending_exact =3D vfio_state_pending_exact, + .save_query_pending =3D vfio_state_pending, .is_active_iterate =3D vfio_is_active_iterate, .save_live_iterate =3D vfio_save_iterate, .save_complete =3D vfio_save_complete_precopy, diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index a061aad817..15d417013c 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -766,9 +766,8 @@ static int dirty_bitmap_save_complete(QEMUFile *f, void= *opaque) return 0; } =20 -static void dirty_bitmap_state_pending(void *opaque, - uint64_t *must_precopy, - uint64_t *can_postcopy) +static void dirty_bitmap_state_pending(void *opaque, MigPendingData *data, + bool exact) { DBMSaveState *s =3D &((DBMState *)opaque)->save; SaveBitmapState *dbms; @@ -788,7 +787,7 @@ static void dirty_bitmap_state_pending(void *opaque, =20 trace_dirty_bitmap_state_pending(pending); =20 - *can_postcopy +=3D pending; + data->postcopy_bytes +=3D pending; } =20 /* First occurrence of this bitmap. It should be created if doesn't exist = */ @@ -1250,8 +1249,7 @@ static SaveVMHandlers savevm_dirty_bitmap_handlers = =3D { .save_setup =3D dirty_bitmap_save_setup, .save_complete =3D dirty_bitmap_save_complete, .has_postcopy =3D dirty_bitmap_has_postcopy, - .state_pending_exact =3D dirty_bitmap_state_pending, - .state_pending_estimate =3D dirty_bitmap_state_pending, + .save_query_pending =3D dirty_bitmap_state_pending, .save_live_iterate =3D dirty_bitmap_save_iterate, .is_active_iterate =3D dirty_bitmap_is_active_iterate, .load_state =3D dirty_bitmap_load, diff --git a/migration/ram.c b/migration/ram.c index 979751f61b..e5b7217bf5 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3443,30 +3443,18 @@ static int ram_save_complete(QEMUFile *f, void *opa= que) return qemu_fflush(f); } =20 -static void ram_state_pending_estimate(void *opaque, uint64_t *must_precop= y, - uint64_t *can_postcopy) -{ - RAMState **temp =3D opaque; - RAMState *rs =3D *temp; - - uint64_t remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SI= ZE; - - if (migrate_postcopy_ram()) { - /* We can do postcopy, and all the data is postcopiable */ - *can_postcopy +=3D remaining_size; - } else { - *must_precopy +=3D remaining_size; - } -} - -static void ram_state_pending_exact(void *opaque, uint64_t *must_precopy, - uint64_t *can_postcopy) +static void ram_state_pending(void *opaque, MigPendingData *pending, + bool exact) { RAMState **temp =3D opaque; RAMState *rs =3D *temp; uint64_t remaining_size; =20 - if (!migration_in_postcopy()) { + /* + * Sync is not needed either with: (1) a fast query, or (2) after + * postcopy has started (no new dirty will generate anymore). + */ + if (exact && !migration_in_postcopy()) { bql_lock(); WITH_RCU_READ_LOCK_GUARD() { migration_bitmap_sync_precopy(false); @@ -3478,9 +3466,9 @@ static void ram_state_pending_exact(void *opaque, uin= t64_t *must_precopy, =20 if (migrate_postcopy_ram()) { /* We can do postcopy, and all the data is postcopiable */ - *can_postcopy +=3D remaining_size; + pending->postcopy_bytes +=3D remaining_size; } else { - *must_precopy +=3D remaining_size; + pending->precopy_bytes +=3D remaining_size; } } =20 @@ -4703,8 +4691,7 @@ static SaveVMHandlers savevm_ram_handlers =3D { .save_live_iterate =3D ram_save_iterate, .save_complete =3D ram_save_complete, .has_postcopy =3D ram_has_postcopy, - .state_pending_exact =3D ram_state_pending_exact, - .state_pending_estimate =3D ram_state_pending_estimate, + .save_query_pending =3D ram_state_pending, .load_state =3D ram_load, .save_cleanup =3D ram_save_cleanup, .load_setup =3D ram_load_setup, diff --git a/migration/savevm.c b/migration/savevm.c index dd58f2a705..392d840955 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1762,46 +1762,44 @@ int qemu_savevm_state_complete_precopy(MigrationSta= te *s) return qemu_fflush(f); } =20 -/* Give an estimate of the amount left to be transferred, - * the result is split into the amount for units that can and - * for units that can't do postcopy. - */ -void qemu_savevm_state_pending_estimate(uint64_t *must_precopy, - uint64_t *can_postcopy) +void qemu_savevm_query_pending(MigPendingData *pending, bool exact) { SaveStateEntry *se; =20 - *must_precopy =3D 0; - *can_postcopy =3D 0; + pending->precopy_bytes =3D 0; + pending->postcopy_bytes =3D 0; =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->state_pending_estimate) { + if (!se->ops || !se->ops->save_query_pending) { continue; } if (!qemu_savevm_state_active(se)) { continue; } - se->ops->state_pending_estimate(se->opaque, must_precopy, can_post= copy); + se->ops->save_query_pending(se->opaque, pending, exact); } } =20 +void qemu_savevm_state_pending_estimate(uint64_t *must_precopy, + uint64_t *can_postcopy) +{ + MigPendingData pending; + + qemu_savevm_query_pending(&pending, false); + + *must_precopy =3D pending.precopy_bytes; + *can_postcopy =3D pending.postcopy_bytes; +} + void qemu_savevm_state_pending_exact(uint64_t *must_precopy, uint64_t *can_postcopy) { - SaveStateEntry *se; + MigPendingData pending; =20 - *must_precopy =3D 0; - *can_postcopy =3D 0; + qemu_savevm_query_pending(&pending, true); =20 - QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { - if (!se->ops || !se->ops->state_pending_exact) { - continue; - } - if (!qemu_savevm_state_active(se)) { - continue; - } - se->ops->state_pending_exact(se->opaque, must_precopy, can_postcop= y); - } + *must_precopy =3D pending.precopy_bytes; + *can_postcopy =3D pending.postcopy_bytes; } =20 void qemu_savevm_state_cleanup(void) diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 846e3625c5..7cf5a9eb2d 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -173,8 +173,7 @@ vfio_save_device_config_state(const char *name) " (%s)" vfio_save_iterate(const char *name, uint64_t precopy_init_size, uint64_t p= recopy_dirty_size) " (%s) precopy initial size %"PRIu64" precopy dirty size= %"PRIu64 vfio_save_iterate_start(const char *name) " (%s)" vfio_save_setup(const char *name, uint64_t data_buffer_size) " (%s) data b= uffer size %"PRIu64 -vfio_state_pending_estimate(const char *name, uint64_t precopy, uint64_t p= ostcopy, uint64_t precopy_init_size, uint64_t precopy_dirty_size) " (%s) pr= ecopy %"PRIu64" postcopy %"PRIu64" precopy initial size %"PRIu64" precopy d= irty size %"PRIu64 -vfio_state_pending_exact(const char *name, uint64_t precopy, uint64_t post= copy, uint64_t stopcopy_size, uint64_t precopy_init_size, uint64_t precopy_= dirty_size) " (%s) precopy %"PRIu64" postcopy %"PRIu64" stopcopy size %"PRI= u64" precopy initial size %"PRIu64" precopy dirty size %"PRIu64 +vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size) " (%s) stopcopy size %"PRIu64" = precopy initial size %"PRIu64" precopy dirty size %"PRIu64 vfio_vmstate_change(const char *name, int running, const char *reason, con= st char *dev_state) " (%s) running %d reason %s device state %s" vfio_vmstate_change_prepare(const char *name, int running, const char *rea= son, const char *dev_state) " (%s) running %d reason %s device state %s" =20 --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676409; cv=none; d=zohomail.com; s=zohoarc; b=FQh7fxpZWgKHZ7BX6DJ93FKu1qWC6DghxyqtoUEK+aBCWbOoVgVGNWXj9g42MX+TBmtG6M9Rmwa7aGl5StG6qmI3IVT3xIPIiSvUWlPNSK+iWm32K4wd7Dqnkfn1eoMsskm/CCFJdGAIdAa9YjYnZ0GXA3FNhUKNlCfYGZmsQm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676409; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=; b=QUqKbraAa9av96Lr8Q6eQcPJcyCzK6dBuE5PclVdEwX+4qaPM8GUJWHqRT/J6x4jFSm26a4NE7ntIzx8ce1nbH67ItTWVb/RYy0vKJaP74/4kXOQ9CISLEz2sJI9P9zyUHsZ2aE8TPnQyQlqLDgRf2FCtEDXYxQlqU/E9S5kDx4= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676409188599.87177612951; Wed, 8 Apr 2026 12:26:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYQs-0006nW-A7; Wed, 08 Apr 2026 15:19:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY0I-00052P-9b for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:51:54 -0400 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 1wAWCK-00028B-05 for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:13 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-64-Yqkji9IZO_iUxmYY7dLeyA-1; Wed, 08 Apr 2026 12:56:10 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50d8ed08aa4so3214891cf.3 for ; Wed, 08 Apr 2026 09:56:10 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667371; 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=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=; b=Ctbqi8KaGxfcU511hIcWRx04URdljM5DEFzjVbIHTgAkFKsRFEsbqoGxDT+FNnZC3P+Mig 0jPewPhZjnhdpjzkKhlWN/wo81CvmYGyXdxvpe7YVQIj5lmMd3QXPxRGlBMB+xl2qP9oBd Gg1/CTafo9oZ31jgFhMPRs/rG7UmQjE= X-MC-Unique: Yqkji9IZO_iUxmYY7dLeyA-1 X-Mimecast-MFC-AGG-ID: Yqkji9IZO_iUxmYY7dLeyA_1775667370 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667370; x=1776272170; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=; b=XAmqfikupgATTl82knCH6Rwqo2ftrq4OSOVDxHgBM7PvHKGd1r4+Gw0IJOE6jE/s/e qclweKKVwyeiSboI9TkmlIUO3vg58MEzB+GkGEts0BiEXhVNzvWhN5WCrQY5bSfk/0mN RPqBJ4dTZsu3RtmkmpxFv83lRB5GOjU3tir2sP28i8HjlTsbWYa9vgCse2ciS3egTbLX 5wuICgma0+4NPNO14tqsYg/+9vjiwU0s9557DBK1PyoLDPQiDexNR3f5dG7EKCVcpi1z KpP/JfMbjApal7YHBUYq3ZMAxdX0wzgZfSmyps+ylxDrtoysY4pXYNuduH0C0QfNCfz6 dbmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667370; x=1776272170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=; b=YFe4Ql2Xxy0RpI3F3z0M+2GPT49fZux7fO9mkXhgyDv3f9r7ojbWWjERvX7DEy23GT 2ggeyHyQ1RVHxLxgdRUZ4JM23XdYFnFCziTNkdeLMZe+Oo2Ft+PRQPfyFL11UhJuLbd+ 4CQwUMbDQlt1RCHisaWQDKkZx5ZGqKo7fTVXMhD+RVMxqbwBOKzjNqUKyFr3S+fxXwJ5 LuRgm0w9kPCcGC+Hk5yCGBxepyGrnGMTUM5/BaABZY8p/b0qWP69pEvWsYnlX92MQKWZ a6InE7TJmGOBuFlGl43hqY/MTK3RBVw1VJ0IjJ57zohECG9Nli3RwdYOpBdwmKXvXl3H 7Yug== X-Gm-Message-State: AOJu0Yx2bhVdMUAsJ1MiLM9R5w7i1UbNO+j1jz6RAzu1TAS5vXTYFnpi Q4UUJcpbG71fMVVfGTOspVpLWW9IBZXaOyZpWrHGV0ZFE9hAcgqAI/YrfPFysRZJTW3G44zKkXE HUUFHSKKhm/BbiZS7OPrzEmkamoGoZEsMFVUy3hUPQllE5RBSAWIxTsAuONclJCA9+LYmn+t+hv K/rC7gw31dmGs+0H6xNWl+02lEW6SFvQtlIoueOw== X-Gm-Gg: AeBDieuqVeDV64vyGI43TU2VjSkgQYKvwRKQSSn43Ok3wMl+2MVT+e8BuWioBalSVOw ST+J5v0vFb9C0XV0YenAWY+GCiSQ6Fqo9J94j+aCwQsrrBHzB8lso5sMGfsxK8qQdE5/Xn7eqkg MvTu0qvD+CDfAI5jhuUI8SYvAoUWQ+ex6EXbp8/vNbYJTBw1ZXECp18VXlluWfVLcG3OMl6SiqY RuypcryiCFIXJaFK0jBnwfbcE06DeIkyUpzKeWoC5o4Ul0RhG4lmozsezFL9Qy+A1IvqSPlzw6y q3Dw3McHKJmq+q0HiPdGbi7HRTSzmSKiqcHPF+ZCKDHyM1htiSDDZSl+ncmeMTIvPVbMYVkmQe4 jxXCPeE1dqemYW1AD2hd1cWWMV2fR3p1ggLGMxJBLP9Ga X-Received: by 2002:a05:622a:1aaa:b0:50d:7e1f:9cbd with SMTP id d75a77b69052e-50dc21d7d2cmr1424321cf.25.1775667369466; Wed, 08 Apr 2026 09:56:09 -0700 (PDT) X-Received: by 2002:a05:622a:1aaa:b0:50d:7e1f:9cbd with SMTP id d75a77b69052e-50dc21d7d2cmr1423691cf.25.1775667368648; Wed, 08 Apr 2026 09:56:08 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 05/14] migration: Use the new save_query_pending() API directly Date: Wed, 8 Apr 2026 12:55:49 -0400 Message-ID: <20260408165559.157108-6-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676412436154100 Content-Type: text/plain; charset="utf-8" It's easier to use the new API directly in the migration iterations. This also paves way for follow up patches to add new data to report directly to the iterator function. When at it, merge the tracepoints too into one. No functional change intended. Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu --- migration/savevm.h | 4 ---- migration/migration.c | 16 +++++++--------- migration/savevm.c | 23 ++--------------------- migration/trace-events | 3 +-- 4 files changed, 10 insertions(+), 36 deletions(-) diff --git a/migration/savevm.h b/migration/savevm.h index e4efd243f3..96fdf96d4e 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -46,10 +46,6 @@ void qemu_savevm_state_cleanup(void); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(MigrationState *s); void qemu_savevm_query_pending(MigPendingData *pending, bool exact); -void qemu_savevm_state_pending_exact(uint64_t *must_precopy, - uint64_t *can_postcopy); -void qemu_savevm_state_pending_estimate(uint64_t *must_precopy, - uint64_t *can_postcopy); int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postc= opy); bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp); void qemu_savevm_state_end(QEMUFile *f); diff --git a/migration/migration.c b/migration/migration.c index dfc60372cf..68cfe2d3bf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3204,17 +3204,17 @@ typedef enum { */ static MigIterateState migration_iteration_run(MigrationState *s) { - uint64_t must_precopy, can_postcopy, pending_size; Error *local_err =3D NULL; bool in_postcopy =3D (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_DEVICE= || s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); bool can_switchover =3D migration_can_switchover(s); + MigPendingData pending =3D { }; + uint64_t pending_size; bool complete_ready; =20 /* Fast path - get the estimated amount of pending data */ - qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy); - pending_size =3D must_precopy + can_postcopy; - trace_migrate_pending_estimate(pending_size, must_precopy, can_postcop= y); + qemu_savevm_query_pending(&pending, false); + pending_size =3D pending.precopy_bytes + pending.postcopy_bytes; =20 if (in_postcopy) { /* @@ -3243,14 +3243,12 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) * during postcopy phase. */ if (pending_size <=3D s->threshold_size) { - qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); - pending_size =3D must_precopy + can_postcopy; - trace_migrate_pending_exact(pending_size, must_precopy, - can_postcopy); + qemu_savevm_query_pending(&pending, true); + pending_size =3D pending.precopy_bytes + pending.postcopy_byte= s; } =20 /* Should we switch to postcopy now? */ - if (must_precopy <=3D s->threshold_size && + if (pending.precopy_bytes <=3D s->threshold_size && can_switchover && qatomic_read(&s->start_postcopy)) { if (postcopy_start(s, &local_err)) { migrate_error_propagate(s, error_copy(local_err)); diff --git a/migration/savevm.c b/migration/savevm.c index 392d840955..397f602257 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1778,28 +1778,9 @@ void qemu_savevm_query_pending(MigPendingData *pendi= ng, bool exact) } se->ops->save_query_pending(se->opaque, pending, exact); } -} - -void qemu_savevm_state_pending_estimate(uint64_t *must_precopy, - uint64_t *can_postcopy) -{ - MigPendingData pending; - - qemu_savevm_query_pending(&pending, false); - - *must_precopy =3D pending.precopy_bytes; - *can_postcopy =3D pending.postcopy_bytes; -} - -void qemu_savevm_state_pending_exact(uint64_t *must_precopy, - uint64_t *can_postcopy) -{ - MigPendingData pending; - - qemu_savevm_query_pending(&pending, true); =20 - *must_precopy =3D pending.precopy_bytes; - *can_postcopy =3D pending.postcopy_bytes; + trace_qemu_savevm_query_pending(exact, pending->precopy_bytes, + pending->postcopy_bytes); } =20 void qemu_savevm_state_cleanup(void) diff --git a/migration/trace-events b/migration/trace-events index 60e5087e38..f8995b8d0d 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -7,6 +7,7 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr= , uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" +qemu_savevm_query_pending(bool exact, uint64_t precopy, uint64_t postcopy)= "exact=3D%d, precopy=3D%"PRIu64", postcopy=3D%"PRIu64 loadvm_state_switchover_ack_needed(unsigned int switchover_ack_pending_num= ) "Switchover ack pending num=3D%u" loadvm_state_setup(void) "" loadvm_state_cleanup(void) "" @@ -159,8 +160,6 @@ migration_cleanup(void) "" migrate_error(const char *error_desc) "error=3D%s" migration_cancel(void) "" migrate_handle_rp_req_pages(const char *rbname, size_t start, size_t len) = "in %s at 0x%zx len 0x%zx" -migrate_pending_exact(uint64_t size, uint64_t pre, uint64_t post) "exact p= ending size %" PRIu64 " (pre =3D %" PRIu64 " post=3D%" PRIu64 ")" -migrate_pending_estimate(uint64_t size, uint64_t pre, uint64_t post) "esti= mate pending size %" PRIu64 " (pre =3D %" PRIu64 " post=3D%" PRIu64 ")" migrate_send_rp_message(int msg_type, uint16_t len) "%d: len %d" migrate_send_rp_recv_bitmap(char *name, int64_t size) "block '%s' size 0x%= "PRIi64 migration_completion_file_err(void) "" --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676659; cv=none; d=zohomail.com; s=zohoarc; b=ZF/EkxrETzkD1A1FDR7FofLh01DhVlvSZYj5ilBtjuBkFAVD6O20psDS8TTjMLY8ox8y2lZePvSpRzuvFoa2dZkcb6yjJmctJs4EV4icCllijD31XtD/BVY76obmAOls4zrxQR5YyTV9EWmF1T1HYzsME0NA003UtoW311UMKJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676659; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=; b=YVvNUpocV+RrGBdHGZgB+uk9y/THvclWy096wVwAT8G8HHzLzblyU83IDdaGCxY8BFPtDBjnalQpFbHxbeKhuFKlUdS8kVdwE3UnmA596QzjtLQWsHQ58cq1yDy4GCvhFSf5ENUlx9pE1k26zK8YRKIhsomHUJo9eqGPKi+V4OI= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676659166308.41963054516043; Wed, 8 Apr 2026 12:30:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYVz-0005ff-B4; Wed, 08 Apr 2026 15:24:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY6o-0007AB-9d for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:58:38 -0400 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 1wAWCL-00028T-Kz for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:15 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-0mmlNPhOPf2omk0CpvAyOA-1; Wed, 08 Apr 2026 12:56:11 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-50d8c192b3fso3701361cf.1 for ; Wed, 08 Apr 2026 09:56:11 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667373; 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=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=; b=aTfhsN5vidp+EnI1PgGgNloMwRDYe0L7A3/mO9embGFDfP8gAZP2pLTVi2ensfDILaD16v aITdW1e7Yk/2l0mXSKbnP0c2STTrvga+m3heOUUpXz3CW5YxxFYJ+NT/A9yS4amf+jZIzu QiZ6KvjwvKYVc/jhvl0RBDPTa/gYC3I= X-MC-Unique: 0mmlNPhOPf2omk0CpvAyOA-1 X-Mimecast-MFC-AGG-ID: 0mmlNPhOPf2omk0CpvAyOA_1775667371 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667371; x=1776272171; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=; b=jnQx1ibA7s9H6Bee7rOSt9NL5mVJydGGB3tZJ50Zi6tCmahyhHmoFeEsjfv9kAX5HT l4fadRvM85WBt+MDNfBS3WX4RRujGjIRhtTBp5gwTeDapwpZJBY48aFzd4V3+b48ONMd cm+J7VpylzrUGE1gaQEOl/Me7tFz/RhZdIXVzZDOOex5Ztlw3JGbdKgNqBQqNjj4qZLa tiZyF7D5KTmLokRF2WNNLGW98IpcNt6gqhJwIcUjxZq0esT9a3Ge2vwcb3u54J+0h8Wp FYsNxNlWmxgblOKBiQcoHvPrq6wN1N2FKqHjk32KNQ85LH+W8xTgH8/V7Jk1jdpUbuOQ OOAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667371; x=1776272171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=; b=qt5VLKKS/AjKvH35ebrQezWWYtg0Ua53xz8cfDCvvuEbexsLthwBG7kjlPbmUq/Dlr erJZh9THIymFYuD8vy/rPQldpgvzuICiobjtjepxfkrquMcJkTFb/H4rkGjpWA7rj99F G4KvMKeJvdb/T3OM0OTgUIW9mYegWPtgg/Pis9v0h28xB7wWSvc7eojFEpgKVDdaC2fu njjBGmrCn4ttrWmtVlXzfGALYq23C5OQMl/BzRvgg54C0aUPIE4TCcrr3FJ/KagSM7xF wmhQLg3KwcUzQNyX1dPKBmztRAiP+64kii+Ujm83M/5Mmq1qQJouDTSr+BQIDtaL5sjC sMVw== X-Gm-Message-State: AOJu0YzIEIGOuc5JCyjTVQz+kGJ4GFattKiqW5GjvY2QNLKK6iqhpG/9 rhIOPL8hqTKoz1Q4yhxuCzGtJb9uefT1NSlmelRhlK0N/YSehycL8rBQ0TidIkbEp3nhx35k9zJ QZmki9CRXyLG/vqmi8daJzQBnnukSZve23MNfg7oRMPkp1OSAh5PSrJLS0yRCDiRoxy5/3E4v5A MHC9/AOz6NHaIBpV+Li2ufp4UWSUt/sdDjT2N12g== X-Gm-Gg: AeBDiev1a3AQETaPW9DkhKb9Y1BNinrqnwdPQp+fMy/CbyBqS36Nip4zSqd7TOYA35+ PYi+PXFFrGFpCk0s+Im3bu/WrWtNBeZsLDqhweP7J+zlX8PblOocg8Qwo4k6j5yUPvcYZi/LZu2 C/QZLfzp6dzTzXWir7y+ekibi0xBUgTXAlUAySZnjx9SSdzCsvlyMFpAKhPhy4FGVcNS+Phb4Tc //ZevUZfoBoDx2LGm3eIbyi9DdC2Wku9mmLeUtRffN8Bf3CA09Lb5t49pRG9gYeJwKPrntJLury 4VFsQRyJVOMy/Co1/KDtB3iKmlEIB+muzGBMz/NLxPxl6suzSluLUAjACZjRa7dQyJGlNLb9GOD IY60qhWIl/uPkhs3aJL9/D1WJzW+OfujtLzQEfM6yEyQg X-Received: by 2002:a05:622a:540c:b0:50d:81c4:4c85 with SMTP id d75a77b69052e-50dc224d638mr1233171cf.36.1775667370587; Wed, 08 Apr 2026 09:56:10 -0700 (PDT) X-Received: by 2002:a05:622a:540c:b0:50d:81c4:4c85 with SMTP id d75a77b69052e-50dc224d638mr1232261cf.36.1775667369944; Wed, 08 Apr 2026 09:56:09 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 06/14] migration: Introduce stopcopy_bytes in save_query_pending() Date: Wed, 8 Apr 2026 12:55:50 -0400 Message-ID: <20260408165559.157108-7-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676660590154100 Content-Type: text/plain; charset="utf-8" Allow modules to report data that can only be migrated after VM is stopped. When this concept is introduced, we will need to account stopcopy size to be part of pending_size as before. However, when there're data only can be migrated in stopcopy phase, it means the old "pending_size" may not always be able to reach low enough to kickoff an slow version of query sync. It used to be almost guaranteed to happen as all prior iterative modules doesn't have stopcopy only data. VFIO may change that fact by having some data that must be copied during stop phase. So we need to make sure QEMU will kickoff a synchronized version of query pending when all precopy data is migrated. This might be important to VFIO to keep making progress even if the downtime cannot yet be satisfied. So far, this patch should introduce no functional change, as no module yet report stopcopy size. This paves way for VFIO to properly report its pending data sizes, which will start to include stop-only data. Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin --- include/migration/register.h | 7 +++++ migration/migration.c | 52 ++++++++++++++++++++++++++++++------ migration/savevm.c | 7 +++-- migration/trace-events | 2 +- 4 files changed, 57 insertions(+), 11 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index aba3c9af2f..e822a2a59f 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -21,6 +21,13 @@ typedef struct MigPendingData { uint64_t precopy_bytes; /* Amount of pending bytes can be transferred in postcopy */ uint64_t postcopy_bytes; + /* Amount of pending bytes can be transferred only in stopcopy */ + uint64_t stopcopy_bytes; + /* + * Total pending data, modules do not need to update this field, it + * will be automatically calculated by migration core API. + */ + uint64_t total_bytes; } MigPendingData; =20 /** diff --git a/migration/migration.c b/migration/migration.c index 68cfe2d3bf..bb17bd0e68 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3198,6 +3198,44 @@ typedef enum { MIG_ITERATE_BREAK, /* Break the loop */ } MigIterateState; =20 +/* Are we ready to move to the next iteration phase? */ +static bool migration_iteration_next_ready(MigrationState *s, + MigPendingData *pending) +{ + /* + * If the estimated values already suggest us to switchover, mark this + * iteration finished, time to do a slow sync. + */ + if (pending->total_bytes <=3D s->threshold_size) { + return true; + } + + /* + * Since we may have modules reporting stop-only data, we also want to + * re-query with slow mode if all precopy data is moved over. This + * will also mark the current iteration done. + * + * This could happen when e.g. a module (like, VFIO) reports stopcopy + * size too large so it will never yet satisfy the downtime with the + * current setup (above check). Here, slow version of re-query helps + * because we keep trying the best to move whatever we have. + */ + if (pending->precopy_bytes =3D=3D 0) { + return true; + } + + return false; +} + +static void migration_iteration_go_next(MigPendingData *pending) +{ + /* + * Do a slow sync will achieve this. TODO: move RAM iteration code + * into the core layer. + */ + qemu_savevm_query_pending(pending, true); +} + /* * Return true if continue to the next iteration directly, false * otherwise. @@ -3209,12 +3247,10 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); bool can_switchover =3D migration_can_switchover(s); MigPendingData pending =3D { }; - uint64_t pending_size; bool complete_ready; =20 /* Fast path - get the estimated amount of pending data */ qemu_savevm_query_pending(&pending, false); - pending_size =3D pending.precopy_bytes + pending.postcopy_bytes; =20 if (in_postcopy) { /* @@ -3222,7 +3258,7 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) * postcopy completion doesn't rely on can_switchover, because when * POSTCOPY_ACTIVE it means switchover already happened. */ - complete_ready =3D !pending_size; + complete_ready =3D !pending.total_bytes; if (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_DEVICE && (s->postcopy_package_loaded || complete_ready)) { /* @@ -3242,9 +3278,8 @@ static MigIterateState migration_iteration_run(Migrat= ionState *s) * postcopy started, so ESTIMATE should always match with EXACT * during postcopy phase. */ - if (pending_size <=3D s->threshold_size) { - qemu_savevm_query_pending(&pending, true); - pending_size =3D pending.precopy_bytes + pending.postcopy_byte= s; + if (migration_iteration_next_ready(s, &pending)) { + migration_iteration_go_next(&pending); } =20 /* Should we switch to postcopy now? */ @@ -3264,11 +3299,12 @@ static MigIterateState migration_iteration_run(Migr= ationState *s) * (2) Pending size is no more than the threshold specified * (which was calculated from expected downtime) */ - complete_ready =3D can_switchover && (pending_size <=3D s->thresho= ld_size); + complete_ready =3D can_switchover && + (pending.total_bytes <=3D s->threshold_size); } =20 if (complete_ready) { - trace_migration_thread_low_pending(pending_size); + trace_migration_thread_low_pending(pending.total_bytes); migration_completion(s); return MIG_ITERATE_BREAK; } diff --git a/migration/savevm.c b/migration/savevm.c index 397f602257..b75c311a95 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1766,8 +1766,7 @@ void qemu_savevm_query_pending(MigPendingData *pendin= g, bool exact) { SaveStateEntry *se; =20 - pending->precopy_bytes =3D 0; - pending->postcopy_bytes =3D 0; + memset(pending, 0, sizeof(*pending)); =20 QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || !se->ops->save_query_pending) { @@ -1779,7 +1778,11 @@ void qemu_savevm_query_pending(MigPendingData *pendi= ng, bool exact) se->ops->save_query_pending(se->opaque, pending, exact); } =20 + pending->total_bytes =3D pending->precopy_bytes + + pending->stopcopy_bytes + pending->postcopy_bytes; + trace_qemu_savevm_query_pending(exact, pending->precopy_bytes, + pending->stopcopy_bytes, pending->postcopy_bytes); } =20 diff --git a/migration/trace-events b/migration/trace-events index f8995b8d0d..2f86ad448e 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -7,7 +7,7 @@ qemu_loadvm_state_section_partend(uint32_t section_id) "%u" qemu_loadvm_state_post_main(int ret) "%d" qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr= , uint32_t instance_id, uint32_t version_id) "%u(%s) %u %u" qemu_savevm_send_packaged(void) "" -qemu_savevm_query_pending(bool exact, uint64_t precopy, uint64_t postcopy)= "exact=3D%d, precopy=3D%"PRIu64", postcopy=3D%"PRIu64 +qemu_savevm_query_pending(bool exact, uint64_t precopy, uint64_t stopcopy,= uint64_t postcopy) "exact=3D%d, precopy=3D%"PRIu64", stopcopy=3D%"PRIu64",= postcopy=3D%"PRIu64 loadvm_state_switchover_ack_needed(unsigned int switchover_ack_pending_num= ) "Switchover ack pending num=3D%u" loadvm_state_setup(void) "" loadvm_state_cleanup(void) "" --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676698; cv=none; d=zohomail.com; s=zohoarc; b=Omh681ll5Ze67SjpvMBX2UIUJsM5rJqJB8ZIJgcfjZJ9E/qJeNGSN+CbYsZYyArfjZ2eSbwXLiz0eeJ64TOkMAkbZHhG+K9+dnlXQbZCs2vkk0NHXr18aMF3Bhydr9mwPq7ba7kvDiCTLJDXNpeMufmNre1f83jZS/BnHV8cw7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676698; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=; b=aWg11aJLibag+Z+VmfJ2BjfFLZya2SnTrq+udr6M+lE5TvXh0WqKCNKPPviNYGwEExxv6XRITsliHcq4z7p0EsSIb6KsgNe4AO+H9xL3HKHTWIdaEw63Gu3MgTUnvsQXQFQHKlu3jrzo/cmsKBdAa7odA3yiPxXKbQyUIrkGtQY= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676698211518.8783996070244; Wed, 8 Apr 2026 12:31:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYT1-0006Ki-FO; Wed, 08 Apr 2026 15:21:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY3x-0006DI-1z for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:55:41 -0400 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 1wAWCO-00028m-10 for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:17 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-dXVsTwTdNWKNF-JbTlEzdw-1; Wed, 08 Apr 2026 12:56:14 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50b31cff27fso996151cf.3 for ; Wed, 08 Apr 2026 09:56:13 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667375; 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=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=; b=J1uRNKP2ox37xyMjv2mMxewoFLmpwYSSxI41bNf7OlVMPuN9w1bFutS7KjgyKWYazGrXLs h7mk8xC6BNZjeEWv3rlUPHIhIj9Jj50aBPHkazyXLdZ4dRsiu5nzLJCq4yseKn6+jhjdQR 5l0qs8SktWpzf2YqaVwf/G0iAnu7tV0= X-MC-Unique: dXVsTwTdNWKNF-JbTlEzdw-1 X-Mimecast-MFC-AGG-ID: dXVsTwTdNWKNF-JbTlEzdw_1775667373 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667372; x=1776272172; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=; b=Pa5mFaiEcJUkhajtukqU36QUOsB8NfJKx5t8d2SHOTacWimWC0bRUphCosbP0QfqTA tUSWBA3yqbcOnp1FMuUJhalAQ8bLo1XhEHChSkWHqD/iDmBZFcMgNa7HcoVy2Z9EbY5G 3HOs6Rl9XLb5ByRfmaWbazDMpvrUClwl8uXlASX3Dmb4zfq4y61+505HUG672OpRmIYG kLhgtNwsNFcN/SStNCUoMszciHvqEq7m2tS3otA60b63ledkSTt9vUbywDd+Fx4RExBq z26+yqwJGUTqpaTihVvPJHJtJ4PApGPCZdSvHLRwxZ1GMfNXiH8AVDs31b4OSla29uBX 6JXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667372; x=1776272172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=; b=FO0gvPdcZmN6NqKmcq8cGqHKSpgJPROxYhoesVHdSHlK9lpfKqlgTenAbkmNwGr2cP O82IyE4vxBGRb5fGAwsriEqq2KboE0FaZqW+ZkB83WPkWKPhQLU7kWln/ijr0M6LMLaP TP/q7XDfDbef8lRgDrwKUv3Ofnxw8xQDo9EEs6UOAAUJc2aj0As8FXV9XnjGqv/ZD1S1 5YcfayyLkjlw6KxoE7Ulu7Iag+iIM3YExB86VmdX+zLNZNj+igee1nrBK1kM7vzbDlly HSyq4gEv+Vxm+a0N78GjCmv6ZFFmG/sSL15pn7V7RBfELYLztDlhaLbMFClUoGFX944/ aoPg== X-Gm-Message-State: AOJu0YwJtUfjHI++PRHhqqHJRRn+PbXbQBudrNHf4t0X8zxZVb9zUFSM f+G8OoyKV/U7th9OPYbtduKoBbmogfFqYIeakjnuqg7R1I2XVWN69QHAeZiLrdXggY4ixPdAFkq 7NBZorQPzhtHS89l1xT5SIeuaQyWsxrWJXzvg1eUsbr8mtc91kNDFIGfRLsrqAcrlC20QaLy5JJ /PzpRQwZUFDrwLBYGGBOuxfbFqNohq5QuBkfoTqg== X-Gm-Gg: AeBDiesL9ThOjRAKZTQPrg0eQmhA6vNL72kSrO76+thJe2HDcrfj4sg/myBakjqZ3r6 PGY3LY97Tz6ScEKWadrh6ptkICyNM8sSLkRL1dyNDcEGD6Lj8zkU1oItfvmYZ9HrXc1SDX1DM2x W+ZKgoGvXuE474Esew+Z1NCspOh/aWKlOZYdx8ZYpL4sbJbcRANIa2S9vO7RrRYeCWNiMkPGoZZ O+AYk1J2vUlSUw1Q5+y89/+ddI/DkftSPyWIQz6zr3u9HX6ptuFn5iu9P8V8LrE0MDfpDl66b1F YV2F5SyI1udSYpTV5CCxYrf8pRHrHa+UmkxQbt8UNsEThCzt2x6veVkQYQgh6ulug1dTXwDCoKT p8UIVEpusJWBgSzOJPCRkeucvEZuv7LFuYcid+a5MSkl0 X-Received: by 2002:a05:622a:4cc8:b0:50b:37a6:4f0a with SMTP id d75a77b69052e-50d62b7b3c3mr324406131cf.57.1775667372452; Wed, 08 Apr 2026 09:56:12 -0700 (PDT) X-Received: by 2002:a05:622a:4cc8:b0:50b:37a6:4f0a with SMTP id d75a77b69052e-50d62b7b3c3mr324405301cf.57.1775667371693; Wed, 08 Apr 2026 09:56:11 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 07/14] vfio/migration: Fix incorrect reporting for VFIO pending data Date: Wed, 8 Apr 2026 12:55:51 -0400 Message-ID: <20260408165559.157108-8-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676699622158500 Content-Type: text/plain; charset="utf-8" VFIO reports different things in its fast/slow version of query pending results. It was because it wants to make sure precopy data can reach 0, which is needed to make sure sync queries will happen periodically over time. Now with stopcopy size reporting facility it doesn't need this hack anymore. Fix this by reporting the same values in fast/slow versions of query pending request, except that the slow version will do a slow sync with the hardwares. When at it, removing the special casing for vfio_device_state_is_precopy() which may reporting nothing in a fast query. Then ther reporting will be consistent to VFIO devices that do not support precopy phase. Copy stable might be too much; just skip it and skip the Fixes. Cc: Avihai Horon Signed-off-by: Peter Xu --- hw/vfio/migration.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 1e999f0040..57e88c9dcf 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -587,19 +587,23 @@ static void vfio_state_pending(void *opaque, MigPendi= ngData *pending, { VFIODevice *vbasedev =3D opaque; VFIOMigration *migration =3D vbasedev->migration; - uint64_t remain; + uint64_t precopy_size, stopcopy_size; =20 if (exact) { vfio_state_pending_sync(vbasedev); - remain =3D migration->stopcopy_size; + } + + precopy_size =3D + migration->precopy_init_size + migration->precopy_dirty_size; + + if (migration->stopcopy_size > precopy_size) { + stopcopy_size =3D migration->stopcopy_size - precopy_size; } else { - if (!vfio_device_state_is_precopy(vbasedev)) { - return; - } - remain =3D migration->precopy_init_size + migration->precopy_dirty= _size; + stopcopy_size =3D 0; } =20 - pending->precopy_bytes +=3D remain; + pending->precopy_bytes +=3D precopy_size; + pending->stopcopy_bytes +=3D stopcopy_size; =20 trace_vfio_state_pending(vbasedev->name, migration->stopcopy_size, migration->precopy_init_size, --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676271; cv=none; d=zohomail.com; s=zohoarc; b=hrkSli7GbjmrwuyiOCApt7oXchrwAeF2hf8ZZDsk7T0GDCnLaEy+6o+TbfRst8unv4h5V3pL+y1uxCzoNHyYywuk4dD61p6ZWd20CMZjmjFibhPSBd/XCnHoX4Bn2PM8ZqjNoZZpENmTpffPIJpxkTIcVC/38iLXa8IyTxE0khg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676271; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9pBpMxP6DqkQFj1pPDgFhUWgDgyZXFHvFl5cTHTGA8Q=; b=EfaHqRRMutTyCD3S3DcsEloX7s3zdHA75sQAiGbmRTw+cY0vSARjQaema+wYXfEX4w2N7HRJLNga9dqtWuEHxXkNGk58iTsQigqPAmt0ooHN/g+sh1jCTAs4qdECPJj9DPYhHIzGtC/sLwF596XDdpZsZ5+yzkc4OvkTbgRJS0w= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676271725314.8244274187754; Wed, 8 Apr 2026 12:24:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYSo-0004PM-MK; Wed, 08 Apr 2026 15:21:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY3p-00066S-0S for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:55:33 -0400 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 1wAWCO-00028r-VA for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:18 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-nH0Zvgx6MlmtCQkut6TcMg-1; Wed, 08 Apr 2026 12:56:15 -0400 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-8d411d0c1faso32841385a.0 for ; Wed, 08 Apr 2026 09:56:15 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667376; 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=9pBpMxP6DqkQFj1pPDgFhUWgDgyZXFHvFl5cTHTGA8Q=; b=R/iGrigDDM3J1SigIXBea7EeZNP6Ik0+r7VoswR0FJY0uKPKHKEaPYOSLTl7MlWYeSTTrk 1Mpynh3faTmVbpX3p17AVyqNjaALdZJNzTklNJOjmvteceFXr1dckOidd+0AJm+CY497At BE3uJHNWtFGWejVAk/FQvC1k0VSryyI= X-MC-Unique: nH0Zvgx6MlmtCQkut6TcMg-1 X-Mimecast-MFC-AGG-ID: nH0Zvgx6MlmtCQkut6TcMg_1775667375 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667375; x=1776272175; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9pBpMxP6DqkQFj1pPDgFhUWgDgyZXFHvFl5cTHTGA8Q=; b=ltUE37aQsL1XvzZCFtWckJwIhBDufxfbVSRYplcOeiq/MxHQwrBJlwUwYH5PL5CYrI MWJslWRnkhl33mii6TdW1a4juuM7E6HWLUPUwDtt8g+2PtO5N3pFK3++xHEUfKeJUfXE 3uHeTvcdcmlcZeUa3F2mkOk5Hax9xTq9LoJ9xCNWnB2H2RZZsCq9qoC0g/wBUmDUDuXk LAop7sy/x1ND3fIFoigpjGg2wqUEmOJt0mII8wuDFIQB1L/Q0xWBpKxRFfyhvmyze6mc V/dSXJ8qi+PpoVuJ0GrllWl0Ef1jf5yr1lVHxFwUAR6di5yyrynGZUD0NVxNwJr8Isx2 /Y7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667375; x=1776272175; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9pBpMxP6DqkQFj1pPDgFhUWgDgyZXFHvFl5cTHTGA8Q=; b=Ovzbg631aolq/t8bFqgbRNRa0CuIO4PCOG88JIy46CumI1yQG0mh1OnCvCdNgHhn5t OiF2I3fimwHM8LRT134fK00O8jIGo+eUl6YL3tFTJh0yPDTvkiLDi/PP1yN0HpvVLbnJ 0aIAB3klf81LJCaaS6xu0lQnElvWsX6WpZEiT1+EuENhdBAiO8kqy11+97zt5zloCQHJ LiB2Fs0zbGCr7gN9eQRHnOpNl2R8eafbxRyK64Quj/tCp3z0Jt0MaDsxc+NiuSma0kKR LYEaJ3mPcx+BBs6C8uL/PLFUvZb0FsYBpeXdToORRVunwTeybMhwrZs8u0WcgD3HVxge 3FkQ== X-Gm-Message-State: AOJu0YzryOYzoqCkIrDTlDIaeewVnxa2KFWURFnDYpgxqkwHk/c5gaZl 9d7D2U2qXgP+K45yjo0bqcj6fTNjh6Crx5T4qgVPNWZ6ItEyl9kb6pFKoPU/ZBzdkoqIU39xMjQ DQwSD1PXoszdXTmOqPj9NdDO4Ea7cIBNFHRYijxEL9gj3l3zBOJSAvc3Htl58Bk+NNYWlVzAVlD W9vwh6aNN0+iiymFuC0S8EgfdbPzbgnjJlfwe/AA== X-Gm-Gg: AeBDiesOPtoQAoRlY1qPOeqjJAtVgB7L9ljDan0MBARxMRxSdAqANzENnKQxjAMmwme 9EZn1XGGRty1U0YbAaAoEXiRwf+JS93EeHU5r+/zPDrmnzo2dixkwyLqluGWBIAANWZzHrwtVzK p1WgGzm6TBsGOzRgPUqiAwts0Pz9nbLtFg4xavrt5H9HESudBV9ghSCu7AZ+E4dgwrBmLIG+Zjr kXUCbEx6zhrtgSat4SVLRt+Dj4iUtjXzTONW5sX0qBvBhXJix96huOj1rabLCfyqlgDTqtv1Q1W NfD/GJZgAoPok1fEEf0aB4MAxSOIONCGiRQkKUZFMEp9uNquFpt5YtX0Xm4CXPR+7w7WIxFoeMK 0JrHriXdSCDOGmdhMy7N+CTXxfBJyxJmsxka8y8TiC0Pc X-Received: by 2002:a05:622a:288:b0:50d:ab9d:33bc with SMTP id d75a77b69052e-50dc20d670fmr1801491cf.8.1775667374285; Wed, 08 Apr 2026 09:56:14 -0700 (PDT) X-Received: by 2002:a05:622a:288:b0:50d:ab9d:33bc with SMTP id d75a77b69052e-50dc20d670fmr1800691cf.8.1775667373506; Wed, 08 Apr 2026 09:56:13 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 08/14] migration: Make qemu_savevm_query_pending() available anytime Date: Wed, 8 Apr 2026 12:55:52 -0400 Message-ID: <20260408165559.157108-9-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676274504154100 Content-Type: text/plain; charset="utf-8" After qemu_savevm_query_pending() be exposed to more code paths, it can be used at very early stage when migration started and this may expose some race conditions that we don't use to have. This patch make it prepared for such use cases so this API is fine to be used almost anytime. What matters here is, querying pending for each module normally depends on save_setup() being run first, otherwise modules may not be ready for the query request. Consider an early cancellation of migration after SETUP status but before invocations of save_setup() hooks, source QEMU may fall into CANCELLING stage directly from SETUP (not ACTIVE, which is the normal use case), in which case save_setup() may not have been invoked and modules are not ready. However qemu_savevm_query_pending() may still be used in QMP commands like query-migrate and causing crashes. Guard such use case by introducing a boolean reflecting the availability of vmstate save handlers on correct completions of save_setup()s. So far, only protect qemu_savevm_query_pending() with it. Logically other hooks face similar concern, but most of them shouldn't be reachable from random code path except migration thread so it should be fine. Signed-off-by: Peter Xu --- migration/migration.h | 8 ++++++++ migration/savevm.h | 2 +- migration/migration.c | 2 +- migration/savevm.c | 37 +++++++++++++++++++++++++++++++++---- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index b6888daced..e504df6915 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -522,6 +522,14 @@ struct MigrationState { * anything as input. */ bool has_block_bitmap_mapping; + + /* + * This boolean reflects if the vmstate handlers have been properly + * setup on source side. It is set after vmstate save_setup() hooks + * are successfully invoked, and cleared after save_cleanup()s. It + * reflects a general availability of vmstate hooks on the source side. + */ + bool save_setup_ready; }; =20 void migrate_set_state(MigrationStatus *state, MigrationStatus old_state, diff --git a/migration/savevm.h b/migration/savevm.h index 96fdf96d4e..04ed09cec2 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -42,7 +42,7 @@ int qemu_savevm_state_resume_prepare(MigrationState *s); void qemu_savevm_send_header(QEMUFile *f); void qemu_savevm_state_header(QEMUFile *f); int qemu_savevm_state_iterate(QEMUFile *f, bool postcopy); -void qemu_savevm_state_cleanup(void); +void qemu_savevm_state_cleanup(MigrationState *s); void qemu_savevm_state_complete_postcopy(QEMUFile *f); int qemu_savevm_state_complete_precopy(MigrationState *s); void qemu_savevm_query_pending(MigPendingData *pending, bool exact); diff --git a/migration/migration.c b/migration/migration.c index bb17bd0e68..a9ee3360e1 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1283,7 +1283,7 @@ static void migration_cleanup(MigrationState *s) g_free(s->hostname); s->hostname =3D NULL; =20 - qemu_savevm_state_cleanup(); + qemu_savevm_state_cleanup(s); cpr_state_close(); cpr_transfer_source_destroy(s); =20 diff --git a/migration/savevm.c b/migration/savevm.c index b75c311a95..1d3fce45b9 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1387,7 +1387,8 @@ int qemu_savevm_state_non_iterable_early(QEMUFile *f, return 0; } =20 -static int qemu_savevm_state_setup(QEMUFile *f, Error **errp) +static int qemu_savevm_state_setup(MigrationState *s, QEMUFile *f, + Error **errp) { SaveStateEntry *se; int ret; @@ -1409,6 +1410,13 @@ static int qemu_savevm_state_setup(QEMUFile *f, Erro= r **errp) } } =20 + /* + * Logically, it should be paired with any hook being used who needs to + * load_acquire() the flag first. So far, only save_query_pending() + * uses it. + */ + qatomic_store_release(&s->save_setup_ready, true); + return 0; } =20 @@ -1429,7 +1437,7 @@ int qemu_savevm_state_do_setup(QEMUFile *f, Error **e= rrp) return ret; } =20 - ret =3D qemu_savevm_state_setup(f, errp); + ret =3D qemu_savevm_state_setup(ms, f, errp); if (ret) { return ret; } @@ -1764,10 +1772,23 @@ int qemu_savevm_state_complete_precopy(MigrationSta= te *s) =20 void qemu_savevm_query_pending(MigPendingData *pending, bool exact) { + MigrationState *s =3D migrate_get_current(); SaveStateEntry *se; =20 memset(pending, 0, sizeof(*pending)); =20 + /* + * This API can be invoked very early before SETUP is properly done, in + * that case don't invoke module queries because they're not ready. + * Just report all zeros. + * + * This is paired with save_setup_ready updates on save_setup() and + * save_cleanup(). + */ + if (!s || !qatomic_load_acquire(&s->save_setup_ready)) { + return; + } + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (!se->ops || !se->ops->save_query_pending) { continue; @@ -1786,7 +1807,7 @@ void qemu_savevm_query_pending(MigPendingData *pendin= g, bool exact) pending->postcopy_bytes); } =20 -void qemu_savevm_state_cleanup(void) +void qemu_savevm_state_cleanup(MigrationState *s) { SaveStateEntry *se; Error *local_err =3D NULL; @@ -1795,6 +1816,14 @@ void qemu_savevm_state_cleanup(void) error_report_err(local_err); } =20 + s->save_setup_ready =3D false; + /* + * Make sure we clear the flag before invoking save_cleanup(), so any + * racy QMP query-migrate won't try to invoke any save hooks. Just use + * an explicit barrier to be simple. + */ + smp_mb(); + trace_savevm_state_cleanup(); QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (se->ops && se->ops->save_cleanup) { @@ -1841,7 +1870,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **err= p) error_setg_errno(errp, -ret, "Error while writing VM state"); } cleanup: - qemu_savevm_state_cleanup(); + qemu_savevm_state_cleanup(ms); =20 if (ret !=3D 0) { status =3D MIGRATION_STATUS_FAILED; --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775677085; cv=none; d=zohomail.com; s=zohoarc; b=UfGrryqjHP5lJNbsqauOON2Bb8GTR2HaQyAsQzPWU79KNj4if2RQU+P4II/3Q1m0jxETm3QiKwzL/B1LRC4rfrMlsT4tazcKukz19KPKmVEfWLEyf5H9tJfR1oaU39p50KancTgVOplXvsBdpIZ2Lz2Vq+mzGlJNE9xd8kI6Tho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775677085; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=; b=CsF2ntUTIWsQghB9YrGjwm016dP7uyx56WGO52g+ki1arwVyNk2ZCZd0CQHiE8yUlxm+HijyGUpL9YWcDL7b8OHnyhLwkSnkuCRSqS3du0amNtNZJMM2k1M1alJlq8tOHaju6jEguWzptf4AAIRuxKcO9q/i93ikWKMd4FxACTQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775677085514905.0611408341002; Wed, 8 Apr 2026 12:38:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYSq-0004bx-FM; Wed, 08 Apr 2026 15:21:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY3l-00063V-60 for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:55:29 -0400 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 1wAWCQ-000292-NX for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:20 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-4x2l-3FPNV-p47qJrOZcDA-1; Wed, 08 Apr 2026 12:56:17 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-50b4987c698so2805501cf.0 for ; Wed, 08 Apr 2026 09:56:16 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667378; 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=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=; b=RZh6bLeVQXv3MOxziswUAT/s968LXLq+5h9U0XkYL+TfM1F/L79vv157LTKSVD6/1FU8ED hz8MiNLapkq5Dtzwc3qb2nRo/mGAXY+PG31alFF81GxG7oor8e+/pWRUZlaoPkPmW1O4xH Ag24i2FXwbtOC7r3dfsHnozUMX7lNO4= X-MC-Unique: 4x2l-3FPNV-p47qJrOZcDA-1 X-Mimecast-MFC-AGG-ID: 4x2l-3FPNV-p47qJrOZcDA_1775667376 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667376; x=1776272176; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=; b=MxCI426jDoyLbdOQKgMuAG/PP9y/DgZORY5K/ukK6F/08c2R/xLDcVjPDqQTLrdfik MFMPr7V4RSjNk7OZx18V4HI1B9cl7WLixToHp/3D7/UCxFNhGoMSR4E/jQi3x9KVRsCO DNtZsufLCO/nGxa3Gx3SU3CQg4mZS+R7PLsB9h2L/p+TysDCEEI3j5JMFwabP08NLPEM 9P6Up2wdJSA0ULn6btyqoKiM1foidKQihpqQ4LHbHO2zLaebKYQkImXoxCajsCo2X/+9 cY4IJvxFuNpmQ3pmnAZYzUWxars4OhCoMDEiu9Oaz9m2gkPJNqawfKo/kjvQj1ncpy66 885w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667376; x=1776272176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5hD/iKEkJCQLVYmt/ko9Id263R4U72ejWLOEm2tj8VI=; b=WnLuTE+oTRduMtJXoNkRGLgf95lvmBxdW74DCYgBzAKGxQBA9GdN+FLwqA/osxHe7W 5l0msz5Oz32eqHbZM5ndhb1QXW2zTIgMiHVWQAnQ3mYs0MpNPfi4SNQ5VhHtQq9kS8Lm hUINoB0QLnkG7Ean9/3Gj6FF6O3zJudW0IuBN/atPAaEIMgFCdthH4nUcbANBPmIkhMl gEdo5CH9cQpuFezcdbaYrzQmCcOl1NSBCFSi3cOTv2zAejvm1KNqDMRf2e1dIp0Fzltm KPR/El5HLK1atUPUGDc/DEhwKiiz462CNoHOhv/0WiH8nmNqz2Hbq/ek/munyyAylzHC QMrg== X-Gm-Message-State: AOJu0YzD9oXLQbMMp80j5AMJ6j5jaTqRKRxUFLgqwuZdh3xgB0LxO538 ocMPwlJcRF+262C4wLjgKA7ULgucCJkrqZJZDv11XqO7Bdow7iCzwA+arPDjVfxUyLK49tJVI4D YYBLlLnXPEGMhX4oBgSDc0SZRIyhCcxPOYq7GAgzElcGtl2xpXnVpLkgf6jBgieSuTRiSsMVolU swG6huKqa9elpvoAksmgh97qjh/GAuyMxZXj8vIQ== X-Gm-Gg: AeBDieuh+8oiRFi1KS45S0v4GiXb0nkEWwg4U6BYhJGt/bno/ff0+uFEWwPfktEhNMH JfvtYHvPsmedDBeOFU8xV5erMwx/Qqujp6Hx0RUcXikoentq8bBe3Lv/Hv76A6gnHtGwsVQah0M 9gX/kPzFVL5BUmD9lNS4J02c+v6PNh7RFwb2MzfS/NyMF36xsfuN32R06F1zKoDnU8XfWuWEmKN RUC9pF09KnZJC6y77ATFC4RMPJIOGpzINzkttbSX2ehxb/oBvKMVS88OBK/9G5jltnOsazjrCTE W0pLInSqAgdfzsXo3BOl/oViDPahyUmUDBSnRA8GRvzL556OKj9EC6YYsKlryuOYB2EIzFtqExS 0ei3NCSnf7sDNx46jYgXLrxwAMQQGTCR4DB6viyXoY80q X-Received: by 2002:a05:622a:1207:b0:4ff:b32b:cdf9 with SMTP id d75a77b69052e-50dc1a1b80bmr3300321cf.14.1775667375838; Wed, 08 Apr 2026 09:56:15 -0700 (PDT) X-Received: by 2002:a05:622a:1207:b0:4ff:b32b:cdf9 with SMTP id d75a77b69052e-50dc1a1b80bmr3299731cf.14.1775667375169; Wed, 08 Apr 2026 09:56:15 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson , Hyman Huang , Prasad Pandit Subject: [PATCH 09/14] migration: Move iteration counter out of RAM Date: Wed, 8 Apr 2026 12:55:53 -0400 Message-ID: <20260408165559.157108-10-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775677087257154100 Content-Type: text/plain; charset="utf-8" It used to hide in RAM dirty sync path. Now with more modules being able to slow sync on dirty information, keeping it there may not be good anymore because it's not RAM's own concept for iterations: all modules should follow. More importantly, mgmt may try to query dirty info (to make policy decisions like adjusting downtime) by listening to iteration count changes via QMP events. So we must make sure the boost of iterations only happens _after_ the dirty sync operations with whatever form (RAM's dirty bitmap sync, or VFIO's different ioctls to fetch latest dirty info from kernel). Move this to core migration path to manage, together with the event generation, so that it can be well ordered with the sync operations for all modules. This brings a good side effect that we should have an old issue regarding to cpu_throttle_dirty_sync_timer_tick() which can randomly boost iteration counts (because it invokes sync ops). Now it won't, which is actually the right behavior. Said that, we have code (not only QEMU, but likely mgmt too) assuming the 1st iteration will always shows dirty count to 1. Make it initialized with 1 this time, because we'll miss the dirty sync for setup() on boosting this counter now. Reviewed-by: Hyman Huang Reviewed-by: Prasad Pandit Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu --- migration/migration-stats.h | 3 ++- migration/migration.c | 29 ++++++++++++++++++++++++++--- migration/ram.c | 6 ------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 1153520f7a..326ddb0088 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -43,7 +43,8 @@ typedef struct { */ uint64_t dirty_pages_rate; /* - * Number of times we have synchronized guest bitmaps. + * Number of times we have synchronized guest bitmaps. This always + * starts from 1 for the 1st iteration. */ uint64_t dirty_sync_count; /* diff --git a/migration/migration.c b/migration/migration.c index a9ee3360e1..57d91ad9e3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1654,10 +1654,15 @@ int migrate_init(MigrationState *s, Error **errp) s->threshold_size =3D 0; s->switchover_acked =3D false; s->rdma_migration =3D false; + /* - * set mig_stats memory to zero for a new migration + * set mig_stats memory to zero for a new migration.. except the + * iteration counter, which we want to make sure it returns 1 for the + * first iteration. */ memset(&mig_stats, 0, sizeof(mig_stats)); + mig_stats.dirty_sync_count =3D 1; + migration_reset_vfio_bytes_transferred(); =20 s->postcopy_package_loaded =3D false; @@ -3230,10 +3235,28 @@ static bool migration_iteration_next_ready(Migratio= nState *s, static void migration_iteration_go_next(MigPendingData *pending) { /* - * Do a slow sync will achieve this. TODO: move RAM iteration code - * into the core layer. + * Do a slow sync first before boosting the iteration count. */ qemu_savevm_query_pending(pending, true); + + /* + * Boost dirty sync count to reflect we finished one iteration. + * + * NOTE: we need to make sure when this happens (together with the + * event sent below) all modules have slow-synced the pending data + * above. That means a write mem barrier, but qatomic_add() should be + * enough. + * + * It's because a mgmt could wait on the iteration event to query again + * on pending data for policy changes (e.g. downtime adjustments). The + * ordering will make sure the query will fetch the latest results from + * all the modules. + */ + qatomic_add(&mig_stats.dirty_sync_count, 1); + + if (migrate_events()) { + qapi_event_send_migration_pass(mig_stats.dirty_sync_count); + } } =20 /* diff --git a/migration/ram.c b/migration/ram.c index e5b7217bf5..686162643d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1136,8 +1136,6 @@ static void migration_bitmap_sync(RAMState *rs, bool = last_stage) RAMBlock *block; int64_t end_time; =20 - qatomic_add(&mig_stats.dirty_sync_count, 1); - if (!rs->time_last_bitmap_sync) { rs->time_last_bitmap_sync =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIM= E); } @@ -1172,10 +1170,6 @@ static void migration_bitmap_sync(RAMState *rs, bool= last_stage) rs->num_dirty_pages_period =3D 0; rs->bytes_xfer_prev =3D migration_transferred_bytes(); } - if (migrate_events()) { - uint64_t generation =3D qatomic_read(&mig_stats.dirty_sync_count); - qapi_event_send_migration_pass(generation); - } } =20 void migration_bitmap_sync_precopy(bool last_stage) --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676654; cv=none; d=zohomail.com; s=zohoarc; b=EiAqkdHKhc2Cla2+wuq1/CM+v5v7yny4U7tqG1fv9odD2qCKV6F3gVliMH26OKzZ9OTOgEzc8mGpiLK3rTDLIxXgoaESNnJd939gLrd6V/SEmw8S7TvoOIS8efH7quMDv6A8ZVtW93TU93SQBnYrQsbhjWcvHEU7CTsOGVz/XxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676654; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=; b=D5MOlq22Ny46CTovBf+P4xgVsTYYduEmyvq5i+9Q23sWp+58OxL53T9XcmwXCehJePQltmcxWhq8c5R0Rwigj4Sz/9umeC4rGhJj2+EjM+iLOIQIQDqXqn9pEsDcEfvsxqsnf5JSrllQ9/OCvIeFjMJLyoNC0SSKcYw+/dLTReQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676654006415.63197095082967; Wed, 8 Apr 2026 12:30:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYWU-00073D-KP; Wed, 08 Apr 2026 15:25:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAY6y-0007Ou-HI for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:58:48 -0400 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 1wAWCS-00029E-2f for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:21 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-DLlQR6maOByv-nGFlwDZ9g-1; Wed, 08 Apr 2026 12:56:18 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50d6bf346adso2333351cf.1 for ; Wed, 08 Apr 2026 09:56:18 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667379; 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=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=; b=F8EGtmB8Fd4WtYSXM6Ktiji32yqMDgPfMDoC718kaDFVTYbe3RykzmjIbe7F/5bPVIJoQZ E5y+Mw6Xu31nyNSAKC2VF94L7hP1hUaQlf4ZKas5z0mLdqj3tk3bpSUlQqC7hUe1IMojG1 8j2/dpwjnnFkZjH5xK6ZuIHHoTYASHo= X-MC-Unique: DLlQR6maOByv-nGFlwDZ9g-1 X-Mimecast-MFC-AGG-ID: DLlQR6maOByv-nGFlwDZ9g_1775667378 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667377; x=1776272177; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=; b=NG+0FBbjo0r5wMm7BydRmLKoTG0wbI3hgXzV4E0A/6l9p+lz72gWlyJS89o8BlMfPh 7tgWE5R4WH13EYkVas2g7IdlzNxP1BOT0X5FIGolaPOAbu5Cu/H7eF7I7zGjBWJgKrHQ owYkqrRBwdTMi8J9vb+f06GKFWC/q3pYbC2jFSPIoRsorQSqNGEYGXH1OudSztmSkE0G OjOgX/B08FVTACmUAMJe4zr5NyO++ptODiNl7TfLFIfLZizSevarLaX3xfYwj6E8dOWd 3XVZsGIZ/ssTGmpMqeGtYiqhMXasbjOvSAuVzHvon/scHC/pakMERDaf7y9rzcoX3o3n twZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667377; x=1776272177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=; b=NDrdzEnnSwow5R8k8IoQusrG2aP1aVSlzz84unirONzEHvfrKZqzr0mhphygPY7Wql KAB5UzauxgtBKo33QLTSUpBowPt3cMpYIfgoFQiyuL5Scp6BlHKKBGJ+y6azHBPFuHdV dQd6cfnLob+HLXdoF9D2vtPOfGhdWk/FLxfQUrQGP9YXWnoi6v/7PRdFz6TfVa0++L+W blwbf1bfBaQGYpXC4NmQ+D0dShS9Gw0HAGTZQ0UZBSaDMK0GDV1KUrFByBBJSgGb3fwD DcHH5WqdK4XChw2nXU+OyjYwreJiLeoJwxy8oSVT7wEXoDLUPGwqEEfKVtIYYKHEjRB+ 204g== X-Gm-Message-State: AOJu0YxHrTyENXkjAuUrXhWuZ5mnvVwlDXaPEe6XoPNDXgRn3dbKF9C/ n8psrZikThNGFzE3bx7jy3mK/pQErnvjbIz5EN0DwrDxugP4mGDzYeFadeTJGWYRwOtP88gszjw d28Eoz86fAmhrGIKkecHEr6kJO+LUUZrG6rhVBmTY40vU2K2SWvs9EsZth5kVDKTgX9/WJ0gUs2 c822tfIrMMbXYv2M9GKgde8ZPFx+XerwKhENqmuQ== X-Gm-Gg: AeBDieuEc8fwSrbDFQcC8h8nECkwDupmtqMDghANgyD357/1CEVUMMGRYzPf6G9+BRy uyjiITr7u2Iqr9oNodCkxdkqa98OP5fCnBR13yKjKnLLgHpaQBxvE9ZEqr88N5+/RCglsHzyaFl Czedjm6oUByLNRPD+Hj1Y9NHO6fTGpS7bkkHLfYm36BTia3iPRPxq+PyZBHMDEE6q+9rMaTg4Fa u3BKjcrojyGrJ5rP8QJfnTI8VX/knyKRAqqlV4vSZFEY60JvIljPr0flcYbHmxceoLWEHR5+X3o o5/N0sRvEBbnvQtqB+wRlYKdEZJNwQ+F6Rlkset9U8C7dHxtAyCEP22fWIuqYANBGNC3tn/b8CA gjZCH1LkGU+mIJAysdhjUkiwvUV46/o3VdsS/un2uBwTg X-Received: by 2002:ac8:7d88:0:b0:50d:6acb:42db with SMTP id d75a77b69052e-50d6acb4a89mr300089221cf.23.1775667377350; Wed, 08 Apr 2026 09:56:17 -0700 (PDT) X-Received: by 2002:ac8:7d88:0:b0:50d:6acb:42db with SMTP id d75a77b69052e-50d6acb4a89mr300088321cf.23.1775667376464; Wed, 08 Apr 2026 09:56:16 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 10/14] migration: Introduce a helper to return switchover bw estimate Date: Wed, 8 Apr 2026 12:55:54 -0400 Message-ID: <20260408165559.157108-11-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676656199154100 Content-Type: text/plain; charset="utf-8" Add a helper migration_get_switchover_bw() to return an estimate of switchover bandwidth. Use it to simplify the current code. This will be used in later to remove expected_downtime. When at it, remove two qatomic_read() to shrink the lines because atomic ops are not needed when it's always the same thread who does the updates. Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu --- migration/migration.c | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 57d91ad9e3..a1a02e3a9f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -984,6 +984,21 @@ void migrate_send_rp_resume_ack(MigrationIncomingState= *mis, uint32_t value) migrate_send_rp_message(mis, MIG_RP_MSG_RESUME_ACK, sizeof(buf), &buf); } =20 +/* + * Returns the estimated switchover bandwidth (unit: bytes / seconds) + */ +static double migration_get_switchover_bw(MigrationState *s) +{ + uint64_t switchover_bw =3D migrate_avail_switchover_bandwidth(); + + if (switchover_bw) { + /* If user specified, prioritize this value and don't estimate */ + return (double)switchover_bw; + } + + return s->mbps / 8 * 1000 * 1000; +} + bool migration_is_running(void) { MigrationState *s =3D current_migration; @@ -3126,37 +3141,22 @@ static void migration_update_counters(MigrationStat= e *s, { uint64_t transferred, transferred_pages, time_spent; uint64_t current_bytes; /* bytes transferred since the beginning */ - uint64_t switchover_bw; - /* Expected bandwidth when switching over to destination QEMU */ - double expected_bw_per_ms; - double bandwidth; + double switchover_bw_per_ms; =20 if (current_time < s->iteration_start_time + BUFFER_DELAY) { return; } =20 - switchover_bw =3D migrate_avail_switchover_bandwidth(); current_bytes =3D migration_transferred_bytes(); transferred =3D current_bytes - s->iteration_initial_bytes; time_spent =3D current_time - s->iteration_start_time; - bandwidth =3D (double)transferred / time_spent; - - if (switchover_bw) { - /* - * If the user specified a switchover bandwidth, let's trust the - * user so that can be more accurate than what we estimated. - */ - expected_bw_per_ms =3D (double)switchover_bw / 1000; - } else { - /* If the user doesn't specify bandwidth, we use the estimated */ - expected_bw_per_ms =3D bandwidth; - } - - s->threshold_size =3D expected_bw_per_ms * migrate_downtime_limit(); - s->mbps =3D (((double) transferred * 8.0) / ((double) time_spent / 1000.0)) / 1000.0 / 1000.0; =20 + /* NOTE: only update this after bandwidth (s->mbps) updated */ + switchover_bw_per_ms =3D migration_get_switchover_bw(s) / 1000; + s->threshold_size =3D switchover_bw_per_ms * migrate_downtime_limit(); + transferred_pages =3D ram_get_total_transferred_pages() - s->iteration_initial_pages; s->pages_per_second =3D (double) transferred_pages / @@ -3166,10 +3166,9 @@ static void migration_update_counters(MigrationState= *s, * if we haven't sent anything, we don't want to * recalculate. 10000 is a small enough number for our purposes */ - if (qatomic_read(&mig_stats.dirty_pages_rate) && - transferred > 10000) { + if (mig_stats.dirty_pages_rate && transferred > 10000) { s->expected_downtime =3D - qatomic_read(&mig_stats.dirty_bytes_last_sync) / expected_bw_p= er_ms; + mig_stats.dirty_bytes_last_sync / switchover_bw_per_ms; } =20 migration_rate_reset(); @@ -3178,7 +3177,8 @@ static void migration_update_counters(MigrationState = *s, =20 trace_migrate_transferred(transferred, time_spent, /* Both in unit bytes/ms */ - bandwidth, switchover_bw / 1000, + (uint64_t)s->mbps, + (uint64_t)switchover_bw_per_ms, s->threshold_size); } =20 --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775673026; cv=none; d=zohomail.com; s=zohoarc; b=Jj9u+3S+tXztnYMrmTzWOGTW99d4+h6UIFA74n5opAlBTuxDQja1mCXzccGITRWzFrhhBdyYrxyBVjOysitZSNA8/Xwo8bRrmYycKVrNnD4rBczcmbIh/3rNqNjdC2kYr9/5ygMOf5TY8TxzQeLLzQjuaeraU7BmW7mvIwRDHHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775673026; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=35aD6ayAqevDc5Cl045Lui2nxa5WaJZTNVeaUyAZbPM=; b=YckaM1/lyYe8NKWjQfLUyvXLsDzXMa7APCE63i3qDzkYVky+okUd382mBXk138HKPBVSOKjpGztVvEWw73TKREwWjQi6m23/dPYuZgX7mmb9xfCCo9TB1CJcWz6YeilhtBt1QurMlPErmsa492sJnYS7Hl74MkDNxv2/11OreB4= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 177567302688478.30073229118261; Wed, 8 Apr 2026 11:30:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAXeq-00057d-SE; Wed, 08 Apr 2026 14:29:44 -0400 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 1wAXeo-00055c-Ep for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:29:42 -0400 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 1wAWCT-00029N-I7 for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:22 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-265-qlLnRnFiOZ-h2m5az8N7Pg-1; Wed, 08 Apr 2026 12:56:19 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-50d9a6a853bso3467411cf.0 for ; Wed, 08 Apr 2026 09:56:19 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667381; 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=35aD6ayAqevDc5Cl045Lui2nxa5WaJZTNVeaUyAZbPM=; b=U90wPZhb/Lp9X+QRuoYSWx0hVboxfS8AfPrnspXepUpmsZqSaAFtscsSogPrcElX1PHTXL V5peRqRrGF8maZrmz03p3pWEatKIlrW7yna8I17MERmUq5kcWaoEMDyZ6x8z5NsnF9wZXt iWDa3MaFz0WQYq747exa07kjmpJ2BJY= X-MC-Unique: qlLnRnFiOZ-h2m5az8N7Pg-1 X-Mimecast-MFC-AGG-ID: qlLnRnFiOZ-h2m5az8N7Pg_1775667379 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667379; x=1776272179; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=35aD6ayAqevDc5Cl045Lui2nxa5WaJZTNVeaUyAZbPM=; b=IAqHhfWbObbWPBaN4v2oYeuPnZHWpjIl0Rh+RXuTdFVyNzL/daxHgeGEwnr7O/xsUs NlzjTw/GaAXOTq2dBT00zmIK++xkk47CdSm3CHEXhHrQP7PoP/I7fqjKwG2Gc3Q0JzAb 0G5bZsRnM3b6HgLOJXW8SmoEgCANlRjsDw0ojf/KG+4FNxF0aKJzmjTCBKzIQ7mQks7t I0ORukbAJ7gG/cKdZO6z9iht/xa9U6zTpFyD3mHXBNea3CBOyg11xsezK0qHKyCgkzgW OvRwGkmWN+dXFGGLp3J7eyzUsMW5bZCmrwwQEPUTmw4Muq8pUg9q05s9wPUlTQhw810l D3IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667379; x=1776272179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=35aD6ayAqevDc5Cl045Lui2nxa5WaJZTNVeaUyAZbPM=; b=mdVv09qvLVwgpZc0g3kNB7mHpVoMnacyFXaVvPu+5frTCuJ2ITA4VpuUpQ7DEL4QPh 2PYoyOtgqgKCzMMYlQm0Ddp2lTnkKGfgg6K3/pdZtF2PRhxJbEQEYT63RFCyc+qIOcvu IEuRS4b3EZoy6QOFrcjNeNZH2vVTQKV4OrKvo1bBNdp3pzyL2iLb9OTKGMzDjXkCU4Ay 22kOFK8Xd+qUMimQhTWCv1HiKE8lD/UHZvPFRdhQnh0KjmLuk2sZIjLfLha73hyEoJBM sKmffeLL5CMfWHnYeEdlmOEO4YST5g5hcLGop8jtcHxnlc3eB8vknB/lObdboCvWx6pb 3v+g== X-Gm-Message-State: AOJu0YxkkKy/8nCfYipONB3tVGm6+OilpANBSihn0nB/+3EQmyjY05g5 RyEDstxDqCmN5fq2xoROu9sm0bpr3lR6B1eNYILjgs5gv9ObonY3W0CDAvfsxBstc24pDGOu+c3 rbQ5+bhp3GPC1qV+NJkzwkSMJxyOuuqK0p0bhIUe8aVdJzo9sZL+6d9s9Wu/bqVSbKnUKNay7jZ mrvgJa6mTfEoV/Jh1MbFSDGO8Opq09yHfw/Xez5g== X-Gm-Gg: AeBDietrbi54zcZv5Qihg88Xx7SMwS1EsiFchAZRW6ogXBZUoq75O/nDfgdSOXtb/57 ktf3dE+fREJ6YXUvE/pacJmjKX4hrvofP1NJO0vDz540UZ3ddAs+dyHouE2a3zByam1F5na8AbU 0tkbsht+7JAnRvH5r8u7UQUt91dImV38UcTshfC9f9R9xvSWvTR05xAJvSj9yuZoo7N2rESlkZO xcMnQNzEu1c79j/hKmdvkFespIL9baRk0Sr+lH4nLwnTFtB0wtNA4/2lAgliwT9jz4/jQoNeWnO WDnIk4nQf/sdC6YIShW6A6OXo3hi8PtrYtfK1329RYjyBFHUZGYllWJBZQsJODXl1nyos/dk6sZ ElVIhK9YQ0mXPEyB0iiRaft2nRXiuK1+xEmem4HI/zotu X-Received: by 2002:ac8:5f13:0:b0:50d:6f78:39b2 with SMTP id d75a77b69052e-50d6f7842efmr289883931cf.38.1775667378697; Wed, 08 Apr 2026 09:56:18 -0700 (PDT) X-Received: by 2002:ac8:5f13:0:b0:50d:6f78:39b2 with SMTP id d75a77b69052e-50d6f7842efmr289882911cf.38.1775667377834; Wed, 08 Apr 2026 09:56:17 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 11/14] migration: Calculate expected downtime on demand Date: Wed, 8 Apr 2026 12:55:55 -0400 Message-ID: <20260408165559.157108-12-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775673029751154100 Content-Type: text/plain; charset="utf-8" This value does not need to be calculated as frequent. Only calculate it on demand when query-migrate happened. With that we can remove the variable in MigrationState. This paves way for fixing this value to include all modules (not only RAM but others too). Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin --- migration/migration.h | 2 +- migration/migration.c | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index e504df6915..32543800b6 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -359,7 +359,6 @@ struct MigrationState { /* Timestamp when VM is down (ms) to migrate the last stuff */ int64_t downtime_start; int64_t downtime; - int64_t expected_downtime; bool capabilities[MIGRATION_CAPABILITY__MAX]; int64_t setup_time; =20 @@ -594,6 +593,7 @@ void migration_cancel(void); void migration_populate_vfio_info(MigrationInfo *info); void migration_reset_vfio_bytes_transferred(void); void postcopy_temp_page_reset(PostcopyTmpPage *tmp_page); +int64_t migration_downtime_calc_expected(MigrationState *s); =20 /* * Migration thread waiting for return path thread. Return non-zero if an diff --git a/migration/migration.c b/migration/migration.c index a1a02e3a9f..f12cd9efd3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1041,6 +1041,17 @@ static bool migrate_show_downtime(MigrationState *s) return (s->state =3D=3D MIGRATION_STATUS_COMPLETED) || migration_in_po= stcopy(); } =20 +/* Return expected downtime (unit: milliseconds) */ +int64_t migration_downtime_calc_expected(MigrationState *s) +{ + if (mig_stats.dirty_sync_count <=3D 1) { + return migrate_downtime_limit(); + } + + return mig_stats.dirty_bytes_last_sync / + migration_get_switchover_bw(s) * 1000; +} + static void populate_time_info(MigrationInfo *info, MigrationState *s) { info->has_status =3D true; @@ -1061,7 +1072,7 @@ static void populate_time_info(MigrationInfo *info, M= igrationState *s) info->downtime =3D s->downtime; } else { info->has_expected_downtime =3D true; - info->expected_downtime =3D s->expected_downtime; + info->expected_downtime =3D migration_downtime_calc_expected(s); } } =20 @@ -1649,7 +1660,6 @@ int migrate_init(MigrationState *s, Error **errp) s->mbps =3D 0.0; s->pages_per_second =3D 0.0; s->downtime =3D 0; - s->expected_downtime =3D 0; s->setup_time =3D 0; s->start_postcopy =3D false; s->migration_thread_running =3D false; @@ -3162,15 +3172,6 @@ static void migration_update_counters(MigrationState= *s, s->pages_per_second =3D (double) transferred_pages / (((double) time_spent / 1000.0)); =20 - /* - * if we haven't sent anything, we don't want to - * recalculate. 10000 is a small enough number for our purposes - */ - if (mig_stats.dirty_pages_rate && transferred > 10000) { - s->expected_downtime =3D - mig_stats.dirty_bytes_last_sync / switchover_bw_per_ms; - } - migration_rate_reset(); =20 update_iteration_initial_status(s); @@ -3816,8 +3817,6 @@ void migration_start_outgoing(MigrationState *s) bool resume =3D (s->state =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER_SET= UP); int ret; =20 - s->expected_downtime =3D migrate_downtime_limit(); - if (resume) { /* This is a resumed migration */ rate_limit =3D migrate_max_postcopy_bandwidth(); --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775676074; cv=none; d=zohomail.com; s=zohoarc; b=jUCTbIYpXDaAa1V70JWIWLFxqgXrGsAVWe2HI9MxK5596hfJoh/h+iXa6stmTz/EE3cFW3DfdR1DKKsENZQzLPxWzAWLck4saN7h9p9OHKbtBrPXf2b0FjuGfd4JiJw8raOhRqJizCKCa7UFn6dXDmX3yOROXuTA5u7Rhv4ZHlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775676074; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y3AUfIp5hhwSuzshcuDyBJj3UN6iMbkU2aTwINm6YxQ=; b=X1A5UTAjTjdz6CTOai6akq3Q3Oy3AjRSJ1wUVdRu1IRlI6nacbT0BBZ46CRuyZ7cZz80z1hcbiI3YvioGt9JqAfUsJ6ig3C1aJvh7un1+e+sFH3pzVvP8eSQdyGntqtvAbRW2m7dOk9h3V2CH+KscoS+zTonif0FyxxyqZjOZK4= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775676074372198.41710653907023; Wed, 8 Apr 2026 12:21:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAYJz-0001L4-SX; Wed, 08 Apr 2026 15:12:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAYHL-0005lA-Kq for qemu-devel@nongnu.org; Wed, 08 Apr 2026 15:09:31 -0400 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 1wAWCU-00029W-An for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:23 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-522-TrcK_ewpO_mM-uwv1n1J7g-1; Wed, 08 Apr 2026 12:56:20 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-50d812c898cso3469351cf.1 for ; Wed, 08 Apr 2026 09:56:20 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667382; 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=y3AUfIp5hhwSuzshcuDyBJj3UN6iMbkU2aTwINm6YxQ=; b=W8wjzC1tFbNZnUWzEGHWZ2sjc8Zk4RS+os+5pErowD+WSAtH2S8M/2hf8YegUh35wLueM+ Ih0cFpDN0gkzdAyIZA9ippmYGpGonCYj7fxUZ4oAtDpZ5Z4Ek/4byQixnnn787PMGLnwje RTcRBTvcqCj/LWMNraitsu+hoQeypiY= X-MC-Unique: TrcK_ewpO_mM-uwv1n1J7g-1 X-Mimecast-MFC-AGG-ID: TrcK_ewpO_mM-uwv1n1J7g_1775667380 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667380; x=1776272180; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y3AUfIp5hhwSuzshcuDyBJj3UN6iMbkU2aTwINm6YxQ=; b=Q3fryF58KvtwuXxYSulS37QYyiJzGUWz92WgEHqe/Wl9gp2MPyWAQ3xf4T6mUjf5ie ypXPLgM4ModjThEqy/ygN2y5JvsGEAnwmIjLQimyeDZeDt92UXl6sr423tWD/N7ZGTvu 4u2ecPVQ01LzMOBCoMDBush+9rY1Csjk29pQqaQmwnNI0GRnsSyj+I52REz8NsZixWd1 SIztbqzi3rrxOkQ1SDEbVszJYgQItJYTXvpW3uYB4x5FDBOnvea7UKdxA4z5M4Xnw71h 7ThcBECtzWE84c2n4fuCItGvlPOWM1HYeiC2GNnmBkbs24u6bUO3rhBL6wRw9fVmJvJe ijUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667380; x=1776272180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=y3AUfIp5hhwSuzshcuDyBJj3UN6iMbkU2aTwINm6YxQ=; b=f7lOO062fQzE2BTCm2lKxjXkEyXpwPgFKUanvWAy8HqAC4vWD8gVo6Gu61orIQ9EwT ziJIVhaVsT945GiSB/6p4jS1NuFkQxgc4ODffXGAE8IYSWhxD/Sbt3NZ8k2O8rEH6NB4 UHg5zDdZfwKTVom1FPtdLpbGSqbND/ZCgNmayrO2a4VUnmBRBK74doWXawF+JteGI/SS /+G2QlRGrZocsTJYJG8KU64qsHSqhQl1cGf0iQcKRDFRvpaSh9jJMdWyNzdebDAU2gcw bWoaA9XuEZx+3ix1BYGDoJ4UWi7twjSGgr0jhd3XjnI6zLki1q3fmWo9ipRNTYNYCkw8 FICA== X-Gm-Message-State: AOJu0YyAYBpaUB7Q54ZlMqWc8ngL2sBtBCJm/GW/RLsgvFA0FsyIxNPF L0X3LVZSWp35160MyXdJdR9J/VnqJhxeph6YdKHQTwY0VZLLifryP6hsHwGhUakvReiZ2lXDmTu mG1MtSHME4zpy+dCuyY+aAPDYhm/UhA1+77ooyHM1dirtYVpDt9FCtMLYtkHDvTIIBuUNoIqAJd CBMx9hD5CE3vwnqpzg0iNfQCTQAMRYVm4suu555Q== X-Gm-Gg: AeBDieuZThkbOJyLTR3u3Z8pTF4vr/DBnJEzlJTY8lk2b49Wv0pnXO504jzXPq1QWXP 5cw/xlfxE0F1cJManaXyYfYuPPh/fa/QLuMPGzo/4oWRuISYfU+8rTio+3+dEeUNFvhDSqzKyTG KIx37Cwj7FB8ndijJhxr/mg7QVNg1qvvoA3ye4Dvv0pzM06fU4WF6dWD48J2YP89fkHcAaM7Ldx y7LdFL9YRT7sca53q4doHa+Hld+89s1FHlfyuCLrVG+YDjIToD3gMqig6HK5maDgoRH63SxyWEI 8S3m3MJjo3NWUPPanjsvzO+4Yvjib+I/RADa3vWgQcFIZcjMZ5r5rafORy9sNmp++TYvmsxZevE rvCBilHIihFcYtIBj39mQrl1i+i/5JkHTM78jD70uWVjM X-Received: by 2002:a05:622a:229f:b0:50d:7b0c:35e7 with SMTP id d75a77b69052e-50d7b0c40a9mr260168291cf.43.1775667379767; Wed, 08 Apr 2026 09:56:19 -0700 (PDT) X-Received: by 2002:a05:622a:229f:b0:50d:7b0c:35e7 with SMTP id d75a77b69052e-50d7b0c40a9mr260167531cf.43.1775667379154; Wed, 08 Apr 2026 09:56:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 12/14] migration: Fix calculation of expected_downtime to take VFIO info Date: Wed, 8 Apr 2026 12:55:56 -0400 Message-ID: <20260408165559.157108-13-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775676077107154100 Content-Type: text/plain; charset="utf-8" QEMU will provide an expected downtime for the whole system during migration, by remembering the total dirty RAM that we synced the last time, divides the estimated switchover bandwidth. That was flawed when VFIO is taking into account: consider there is a VFIO GPU device that contains GBs of data to migrate during stop phase. Those will not be accounted in this math. Fix it by updating dirty_bytes_last_sync properly only when we go to the next iteration, rather than hide this update in the RAM code. Meanwhile, fetch the total (rather than RAM-only) portion of dirty bytes, so as to include GPU device states too. Update the comment of the field to reflect its new meaning. Now after this change, the expected-downtime to be read from query-migrate should be very accurate even with VFIO devices involved. Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin --- migration/migration-stats.h | 8 +++----- migration/migration.c | 11 ++++++++--- migration/ram.c | 1 - 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 326ddb0088..1447316802 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -31,11 +31,9 @@ */ typedef struct { /* - * Number of bytes that were dirty last time that we synced with - * the guest memory. We use that to calculate the downtime. As - * the remaining dirty amounts to what we know that is still dirty - * since last iteration, not counting what the guest has dirtied - * since we synchronized bitmaps. + * Number of bytes that were reported dirty after the lastest + * system-wise synchronization on dirty information. It is used to + * do best-effort estimation on expected downtime. */ uint64_t dirty_bytes_last_sync; /* diff --git a/migration/migration.c b/migration/migration.c index f12cd9efd3..4010e5dcf5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3240,18 +3240,23 @@ static void migration_iteration_go_next(MigPendingD= ata *pending) */ qemu_savevm_query_pending(pending, true); =20 + /* + * Update the dirty information for the whole system for this + * iteration. This value is used to calculate expected downtime. + */ + qatomic_set(&mig_stats.dirty_bytes_last_sync, pending->total_bytes); + /* * Boost dirty sync count to reflect we finished one iteration. * * NOTE: we need to make sure when this happens (together with the * event sent below) all modules have slow-synced the pending data - * above. That means a write mem barrier, but qatomic_add() should be - * enough. + * above and updated corresponding fields (e.g. dirty_bytes_last_sync). * * It's because a mgmt could wait on the iteration event to query again * on pending data for policy changes (e.g. downtime adjustments). The * ordering will make sure the query will fetch the latest results from - * all the modules. + * all the modules on everything. */ qatomic_add(&mig_stats.dirty_sync_count, 1); =20 diff --git a/migration/ram.c b/migration/ram.c index 686162643d..d927ad7508 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1148,7 +1148,6 @@ static void migration_bitmap_sync(RAMState *rs, bool = last_stage) RAMBLOCK_FOREACH_NOT_IGNORED(block) { ramblock_sync_dirty_bitmap(rs, block); } - qatomic_set(&mig_stats.dirty_bytes_last_sync, ram_bytes_remain= ing()); } } =20 --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775673133; cv=none; d=zohomail.com; s=zohoarc; b=DgCHpi3HQK1HGj5BlNmUS0avYPI49Djq0j+YZOh9/P0ahDwpCHmWT8Tvtq6wYFl3vulZ5GxfzrKYEWvwlbiw4wAPgZV0OIxIqz2zk/x7CPo0/5FkcuiJnz+KQcT9VE6bU+VupdXtx2N1s2hJKsY2+tu2YyxBSlOPQ1OHEXHs5OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775673133; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gbrwSMWX65NN2qFtsFxD677N8GbRpenQYWl5sMfBjrg=; b=AUo/yqe4SvIAuRM7w86s410U4jNAlw+0MTcepYYQrwRkmomqcg1udxDjOdwjtwB1yjDLr36rgVefTB0R6SxMCaFt/lJ6gx3KUWIVUJecsdu+N7gx/sSeNwqIXEY8jkOaDLal4nkDhzELmb7QvhhA4YYVUzEd2QbKdoi8BBa4A9Q= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775673133845983.6726206903677; Wed, 8 Apr 2026 11:32:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAXh4-0007Jm-F0; Wed, 08 Apr 2026 14:32:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAXgq-00075k-CE for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:31:51 -0400 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 1wAWCW-00029k-LG for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:26 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-168-o24luCgIMiCxOCtsOdYteA-1; Wed, 08 Apr 2026 12:56:22 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-50da31af14cso2649191cf.1 for ; Wed, 08 Apr 2026 09:56:22 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667384; 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=gbrwSMWX65NN2qFtsFxD677N8GbRpenQYWl5sMfBjrg=; b=CZVWN+iKXM0zMljnBtIJpacfAY9v9kMfqe8t3Viww9hrEf8DPbFHz24fTlUIOiifjWEePK /85QzvZVe714kcwPcll8232Ok2pMUQndoaiKMiN61ZrxVhBO1d7k5p62of4Y8amrPkQtdA TTcBvpR1mkfRPOR0Er8uY+VVLKUSlOU= X-MC-Unique: o24luCgIMiCxOCtsOdYteA-1 X-Mimecast-MFC-AGG-ID: o24luCgIMiCxOCtsOdYteA_1775667382 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667382; x=1776272182; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gbrwSMWX65NN2qFtsFxD677N8GbRpenQYWl5sMfBjrg=; b=tXmLDhgU5LT3gMH0iZPzlpfuteFlDjKEzBHSSlX9z380p7pvZuyoyRlkFoadOXZULl B6xxKIFTnWN9T+svvDqUrmc6L7rl/mcHhwaEm4bHT6HBscaYd9x5zyXSWhqJG/duM45S If45oDHPHV/jbcsmxRK05xZVituxUXR1al0UwN/Kcs9R1AT/nUcL9G3tgJfc6IFXuJKY DgkU6VP3Shenl/IdsnVZvJs4qmhI4LaECWbkfkQSpeVdBikzgMgHVHdBvdxgGBjPCTV2 MNEHkqq548q9a/afF3bL+p/hz823veBiou39nOAFe4yC6J7MLXnQVGy4Q5WE76bxxny5 hzgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667382; x=1776272182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gbrwSMWX65NN2qFtsFxD677N8GbRpenQYWl5sMfBjrg=; b=DUVnBAkL6CLVDURKEjJoU17EzQoh8LXzzaxRNlZYqtJ1yvKxDC0yGfO751cYs7om6N q2A/PQKBplAOXuIlViPg2E6GkuxOl8NsHUi8wIVgn3AZbZ+bsjdAsNymQlNPTCU3mvaH 9VGzub+tCAdqrFRm3q2jIBShtD04gmx6WPpcFVs8nS+iN3ErETlfI6yrvALaO2uJd0lS 4irgked5JaqxyG8bRmqj7J8NjfVeoStHMSKieA7/k3J/NiqI+rjbcWKrU4+EHUh691VG NxRGrXnm0JRPDpj3b/4+MSGS6kLhv+edHYDl82NnKfSkfHUY1dBvt1EK8ZI7ac50sRzH 80DA== X-Gm-Message-State: AOJu0YywdTP4axNgJgrqmC0gsW3n2gvqQXeEyq5dk6LQLHy8ihBVCA1H 7MsoQImfKHiPDpNqeU4V1cMBaaxWUCNfF31wwWfigttC0KzRbXQllgjS8xfw6GrGMbX9V1qnc+2 gnlaVpibZg+hDG93r6NIAI5D9bnrGB9nXTAbe7A/dtKfbmdnFaVtgwqcCmfIeSt0rH0eAzP3JcK yh4twNKAAiakXH5CH2RjmQybrYLqkdOXRHkUmRfg== X-Gm-Gg: AeBDieuS8PiDxi/ozdD51Sz7tb3XYj6A99OvO4yK7ozm0E/xzHfpEfmimtM389BNyD8 Vd4jXSlteec1FN1oKKellQifHbwXmI/HbDPbVz26P3lsBEIIkx1I3/F/jOZArbw343m6dw1jUhI hzC9THVxVA2e7dxCEQwEFLMiwYzAGydV3qtauEa8kmTKXxSpTYWQsond7odWFMAbrfCTmCgfwVK fK6Ntz8QhXYljOV/hTWqzPrGio3x7Nx4dVMp9EwffFmZjTvKMHZ5uGxG4uXqrTxQM+RsBvLjvMu 8FPeGS1FWtIIRJvc9km0Pji20OFWYXfYoqv1RHaoSdU2zJRpWIeFLmqgKJWV5lWfKJFYd0ks2sR +e2Tzw6W0yWsZ5GX7U5zQ/11U7EzTOR7c0VdS1rc/5Vzm X-Received: by 2002:a05:622a:124b:b0:50d:83de:4933 with SMTP id d75a77b69052e-50d83de50cfmr229016051cf.20.1775667381673; Wed, 08 Apr 2026 09:56:21 -0700 (PDT) X-Received: by 2002:a05:622a:124b:b0:50d:83de:4933 with SMTP id d75a77b69052e-50d83de50cfmr229015211cf.20.1775667380973; Wed, 08 Apr 2026 09:56:20 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson , "Dr. David Alan Gilbert" Subject: [PATCH 13/14] migration/qapi: Introduce system-wise "remaining" reports Date: Wed, 8 Apr 2026 12:55:57 -0400 Message-ID: <20260408165559.157108-14-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775673136739154100 Content-Type: text/plain; charset="utf-8" Currently, mgmt can only query for remaining RAM, not system-wise remaining data. It was not a problem before, because for a very long time RAM was the only part that matters. After VFIO migrations landed upstream, it may not be true anymore especially considering that there can be GPU devices that contain GBs of device states. Add a new "remaining" field in query-migrate results, reflecting system-wise remaining data, which will include everything (e.g. VFIO). This information will be useful for mgmt to implement generic way of stall detection that covers all system resources. Say, when system remaining data does not decrease anymore for a relatively long period of time, then it may mean that there is a challenge of converging, so mgmt can act based on how this value changes over time (especially if sampled after each migration iteration). Before this patch, "expected_downtime" almost played this role. For example, by monitoring "expected_downtime" at the beginning of each iteration can in most cases also reflect the progress of migration system-wise. Said that, "expected_downtime" was always calculated based on a bandwidth value that can fluctuate a lot if avail-switchover-bandwidth is not used. This new "remaining" field will remove that part of uncertainty for mgmt. With the new field, HMP "info migrate" now reports this: (qemu) info migrate Status: active Time (ms): total=3D12080, setup=3D14, exp_down=3D300 Remaining (bytes): 1.36 GiB <------------------- newline RAM info: Throughput (Mbps): 840.50 Sizes: pagesize=3D4 KiB, total=3D4.02 GiB Transfers: transferred=3D1.18 GiB, remain=3D1.36 GiB Channels: precopy=3D1.18 GiB, multifd=3D0 B, postcopy=3D0 B Page Types: normal=3D307923, zero=3D388148 Page Rates (pps): transfer=3D25660 Others: dirty_syncs=3D1 It should be the same value as RAM's remaining report when VFIO is not involved, and it should report more than that when VFIO is involved. Cc: Markus Armbruster Cc: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juraj Marcin --- qapi/migration.json | 4 ++++ migration/migration-hmp-cmds.c | 5 +++++ migration/migration.c | 11 +++++++++++ 3 files changed, 20 insertions(+) diff --git a/qapi/migration.json b/qapi/migration.json index e3ad3f0604..a6e24b5685 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -300,6 +300,9 @@ # average memory load of the virtual CPU indirectly. Note that # zero means guest doesn't dirty memory. (Since 8.1) # +# @remaining: amount of bytes remaining to be migrated system-wise, +# includes both RAM and all devices (like VFIO). (Since 11.1) +# # Features: # # @unstable: Members @postcopy-latency, @postcopy-vcpu-latency, @@ -310,6 +313,7 @@ ## { 'struct': 'MigrationInfo', 'data': {'*status': 'MigrationStatus', '*ram': 'MigrationRAMStats', + '*remaining': 'uint64', '*vfio': 'VfioStats', '*xbzrle-cache': 'XBZRLECacheStats', '*total-time': 'int', diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 0a193b8f54..721c211086 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -178,6 +178,11 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict) } } =20 + if (info->has_remaining) { + g_autofree char *remaining =3D size_to_str(info->remaining); + monitor_printf(mon, "Remaining (bytes): \t%s\n", remaining); + } + if (info->has_socket_address) { SocketAddressList *addr; =20 diff --git a/migration/migration.c b/migration/migration.c index 4010e5dcf5..c2aa145106 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1076,6 +1076,16 @@ static void populate_time_info(MigrationInfo *info, = MigrationState *s) } } =20 +static void populate_global_info(MigrationInfo *info, MigrationState *s) +{ + MigPendingData data =3D { }; + + qemu_savevm_query_pending(&data, false); + + info->has_remaining =3D true; + info->remaining =3D data.total_bytes; +} + static void populate_ram_info(MigrationInfo *info, MigrationState *s) { size_t page_size =3D qemu_target_page_size(); @@ -1177,6 +1187,7 @@ static void fill_source_migration_info(MigrationInfo = *info) /* TODO add some postcopy stats */ populate_time_info(info, s); populate_ram_info(info, s); + populate_global_info(info, s); migration_populate_vfio_info(info); break; case MIGRATION_STATUS_COLO: --=20 2.53.0 From nobody Sat Apr 11 17:07:32 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1775674023; cv=none; d=zohomail.com; s=zohoarc; b=oEiNaI1dDBq50VnehL9ZViiWVZRX5QDnreoIjCK26O1hleYG49bH14XWDxIbwr4tMsFYbrWuQ9IxthFqdkpT4Dq1NsauVk+BhUpbeCya1E+z24LiY5m336KFYWXon7R3ABqh2dhM/rxkvBxFM3MdAaerBR89sH9TIeM7G+PTWxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775674023; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aOg6aB8+NOKrpHZmrJdjsj4iQJGYpx+Cn+FtttlNL1I=; b=Z1QTVHkB4V7Eta4t+2JmWfLX67z6bFVw9f5t8LpKHGhF1X58TkGZCsESawMISIp2jNVV946c3JRgaiROGD/I84VqvFEWZKixTCRzmerTmBMta8wYfQkdNMcmaw2kUhsnEr3aMsBg6o0TsC6l/sG0cEYx240o4jzF62Vf7ac0Yhc= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775674023507342.3131792672133; Wed, 8 Apr 2026 11:47:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wAXsN-0007Ul-PW; Wed, 08 Apr 2026 14:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wAXsG-0006NN-8h for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:43:36 -0400 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 1wAWCW-00029o-VR for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:26 -0400 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-m6ebftIJOPGXzPBz1k9L2w-1; Wed, 08 Apr 2026 12:56:24 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50b44f7b7bbso60841cf.3 for ; Wed, 08 Apr 2026 09:56:23 -0700 (PDT) Received: from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 09:56:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775667384; 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=aOg6aB8+NOKrpHZmrJdjsj4iQJGYpx+Cn+FtttlNL1I=; b=aRbHaTK87O62HdD8jlN79/+OZRund2tQpW1qPTfGz+coq5jrccvlIf4irNsAOROOswZQVm iVrkpbVcQYlMxIdlmXB4FQ/z3/ItvXSAqYS9kXltcird0WlXxCPUNtVcdVU3F1YFrtojzY W/q96d1xKZ4bVGvy14Kr2oHNdtTrnoY= X-MC-Unique: m6ebftIJOPGXzPBz1k9L2w-1 X-Mimecast-MFC-AGG-ID: m6ebftIJOPGXzPBz1k9L2w_1775667383 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1775667383; x=1776272183; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aOg6aB8+NOKrpHZmrJdjsj4iQJGYpx+Cn+FtttlNL1I=; b=n9x/CSxAgGVrUxBaFx9J1jIu882Qnq/O46KKBjeG5+Lv9/ztwaajCjku4G20YQLHuY xQOQ+QIL5bBlo4luGnZUV3zE3meliFsp3+3XD13rilCDBAo2FlVEEdlOH20B9cypPbuO uTUuW+z+hnZPsbIcO3xCng5ssUM3QQ1JOIP7YooM9DDOIJ+yqnBokPzKQZ56AFYXBbAw v+L0szfK+1JgNoDMMBLuInnCWJ5m9H+PXl+V2okpxQoG6tZ/ZVKLZNm1cv+VR8oXGe5/ FgQWHr1Sao0k+ZCyOdKb1yMzKmMUS0N3Tk5UzLQOyU/D5OrJhfnM0sMSZ2FVGhA2803Z qLTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775667383; x=1776272183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aOg6aB8+NOKrpHZmrJdjsj4iQJGYpx+Cn+FtttlNL1I=; b=hkj4hgUweMnVBs3ABzSL3VX0na5rs04kX5um70Ri1AuvbWQcPBWGT5v1aPda3t4xuN wRVlAgIpmoBGbRyPMrxc/Cg+SYffkYn3OyIOyHcUWrGL6dGjXWEJ/n2OZKEe57lCFfOc MkzCuPMrfWqYPL7qtpHxjOz4eSPa5ctxFx/vVpvpRePHC9P3lVFumsFR95+Nt9EMiie2 hmBZE7DXflYXk/s3jaE+rIXO2LGGBALhLld3V+W4YeSUcRvw+ZQMHQ7LLGtxFAB1q/V5 7KM4/IWY5M3/kr67teB6sfRdL5B0jTQArX+hrtO4pwuOL1OTbp8PRAtc2HbK5Ly34vAr fAjw== X-Gm-Message-State: AOJu0YzfmuTdX7Ik/Cp3hD6Ta2PrV8oe6TQCkI/SiD9YE7lFcTQuSMH7 VByZyVYEpKNlfzbxju0bUqrFjnjXx59RyOWK711mHY4ugiB9CZlC9L+fC+E1XrO7BzTLjx03AC3 zl9/7C7pvQwyhzNXwRCr+nuSY5i5YU4Rxnzo1D4wsuxRX493CGpMpIjX8JOuHYkEMHBph7yVT18 xroGFs8HvivLExlk0N1VilnuTbBqduAJ0MoV9Iig== X-Gm-Gg: AeBDievByWr6q7Em9ROupOoma4ADNcMNh3uxBqLvWa2qQ794kBDg3bLIHarTivnJKmW 8gTwFJKAg6vL742vAETIjOcvCavVEVDKxbcxjc2K9yqcqG4mTdcdpuVLWN6tCu34yThXcVloxEv tD0Y05zGnVPcPabNqVDOTKPmJSlqtY+uQ2D/4cT6IEeU7IVlnm2Z7fxvPt6FebjtjPW5zn8R8GI ndBYVHBoHFAol+mxXNM+13NsUh3X4ppSBE2bjheiMCPJ1vBL+wmJjEqeKYtiZRL98yGnc7srDMq VtqF8Ydf6W9rDg8NwGTMDU/0HILfVUZv1ZvjgSUq2OHN2a9pBJrsZce0VEFVaBV1CLbYMDCkpkF hBTaxiPh3n0dvFOvpdM7idsxqtDDU2dPLEYkRNr4D4t1S X-Received: by 2002:a05:622a:250b:b0:50d:7d8a:5d45 with SMTP id d75a77b69052e-50dc2218241mr1272841cf.36.1775667382945; Wed, 08 Apr 2026 09:56:22 -0700 (PDT) X-Received: by 2002:a05:622a:250b:b0:50d:7d8a:5d45 with SMTP id d75a77b69052e-50dc2218241mr1272401cf.36.1775667382336; Wed, 08 Apr 2026 09:56:22 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: "Maciej S . Szmigiero" , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Zhiyi Guo , Juraj Marcin , Peter Xu , Prasad Pandit , Avihai Horon , Kirti Wankhede , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Fabiano Rosas , Joao Martins , Markus Armbruster , Alex Williamson Subject: [PATCH 14/14] migration/qapi: Update unit for avail-switchover-bandwidth Date: Wed, 8 Apr 2026 12:55:58 -0400 Message-ID: <20260408165559.157108-15-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408165559.157108-1-peterx@redhat.com> References: <20260408165559.157108-1-peterx@redhat.com> 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54, 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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: qemu development 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: 1775674026450154100 Content-Type: text/plain; charset="utf-8" Add ", in bytes per second". Unfortunately indentations need to be updated completely, but no change on the rest. Cc: Markus Armbruster Suggested-by: Juraj Marcin Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin --- qapi/migration.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index a6e24b5685..b7518b29c6 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -921,15 +921,15 @@ # (Since 2.8) # # @avail-switchover-bandwidth: to set the available bandwidth that -# migration can use during switchover phase. **Note:** this does -# not limit the bandwidth during switchover, but only for -# calculations when making decisions to switchover. By default, -# this value is zero, which means QEMU will estimate the bandwidth -# automatically. This can be set when the estimated value is not -# accurate, while the user is able to guarantee such bandwidth is -# available when switching over. When specified correctly, this -# can make the switchover decision much more accurate. -# (Since 8.2) +# migration can use during switchover phase, in bytes per +# second. **Note:** this does not limit the bandwidth during +# switchover, but only for calculations when making decisions to +# switchover. By default, this value is zero, which means QEMU +# will estimate the bandwidth automatically. This can be set +# when the estimated value is not accurate, while the user is +# able to guarantee such bandwidth is available when switching +# over. When specified correctly, this can make the switchover +# decision much more accurate. (Since 8.2) # # @downtime-limit: set maximum tolerated downtime for migration. # maximum downtime in milliseconds (Since 2.8) --=20 2.53.0