From nobody Sat May 30 20:11:55 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=1776802904; cv=none; d=zohomail.com; s=zohoarc; b=E6/GGqLYQEDu8B8fTggjAUq8q6f6ohhHm9xsniiIE+HshdlJBEl/yx16XAPVv8930VRdnSRB4uBL6nYaueH/GKxMM6mz6JRnE8O4dUk9KT1JsdLFCeckATzdy6JNIj6Trgk0nSFMngScy7O0k/Hv+oZuI1oEnPMvJJyhgw7wjD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802904; 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=UOUGF+QQnpU6zuXw4cpQjrOpyCI1FWQp+UCrmmzO7fY=; b=cdpgFRBO+WVlTQsiZrSupQtuO/bXkvjIuC2DpXh5DWH8THVwT2RxJyf5bzMnUQQ7zlBC2GMJI+VoE0vUdoYF/x6L2AhrrnXNvPKUwhtjbR763bmFfUOa7ddi2HagYwnIfoIkYwAdYPkWzUUGk9B+AhxgYnAYbRT+2a0ux7iMuNs= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802904690939.4732328203602; Tue, 21 Apr 2026 13:21:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHb0-0000vL-48; Tue, 21 Apr 2026 16: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 1wFHax-0000uO-57 for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:19 -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 1wFHav-0008Ea-O8 for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:18 -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-672-rMp3wfI4OUGSJi_-dTljew-1; Tue, 21 Apr 2026 16:21:15 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-50b220c72bbso121111691cf.1 for ; Tue, 21 Apr 2026 13:21:15 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802877; 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=UOUGF+QQnpU6zuXw4cpQjrOpyCI1FWQp+UCrmmzO7fY=; b=gZqbwQ8fbI+QiIH6w1LaADuMx6iumg5xw5Qxi8gJeTF5yP0qHsmjp70WlQ8Snt9H3gcgq4 kqTM0MucCqSJToapQPEa6bo2ZAtvPumyckisRn2abk+YtPrp/PobhmiKMF6nGFaw5D4s4y AgkZTnK33EHv7YW4K5I20u1K3hAShj4= X-MC-Unique: rMp3wfI4OUGSJi_-dTljew-1 X-Mimecast-MFC-AGG-ID: rMp3wfI4OUGSJi_-dTljew_1776802875 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802875; x=1777407675; 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=UOUGF+QQnpU6zuXw4cpQjrOpyCI1FWQp+UCrmmzO7fY=; b=frH0k11zEaHOarOqx173vSfbXFoPPjx7bQ0skYN/DhlsUmNUKkx5mKEy5ZcZ6ZOkfp ydGH0ZvSLuGV9TB8k8h8Xe83A53IsPYZXYVUi3vj3jadZleRlXuSwxKVyiK/OBhQQI8/ 425k4ztIx94HXm3ytFPQkgwZPhCrgpjldIYGpFkiFO+N0WL7LDDaeiopFgG2Enw8PRdN j4mEogzENc14EskHcf2KyLoScvt2DjzAv9dBWWiNuqudXn/WwMG+YY6kL7qF7vVBJQGD 5SXGTYMLiGI4kNgKrOgdDEHUb0K3b4fzpdkEvraysM7qbWFMKia7NC7VXyXUEPFU3PFj Z00Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802875; x=1777407675; 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=UOUGF+QQnpU6zuXw4cpQjrOpyCI1FWQp+UCrmmzO7fY=; b=gH9pWq6bq/ufaEbln7S2XdNYisELDSbwxR1zFe9NYVQnCXpR+xBJYKbwzW1xmb3Ci6 g1AD5BWqnHyqqe/vLQX8rFrrcIGYmn6qkJ58xTfcvZ6tKiks/spJC7vRNpGw3LqlNJEG trnff06qKL6MAKPtGbIgNysYcY2CWqIynduMrsYR5q/fewFgJ2bFY1nW24tBnQEUdG9v vTQM2of3qxjug3wickDP/dXJYMjrfcLopbfkSD3JKy/ysX3sdeSzsWewZ6i4HTOBqA30 1GvIp4WUX5gTksjmLawoNXimEjy8jRr2qp+xkc5IFWeLJuJnREc503CfhP0oHmrVTrp7 9XFw== X-Gm-Message-State: AOJu0YwzI4ht9lQlCtrno/8g0JWMEQfcrTlJ93aOjLS3OwxPnUUyF56Z TNtGLcfbwPPif2EgI0T2mQJGxUqAHkf/sJo+ueZ0QEKbPl/du9FQYwOgtij+yPZjv8RVq4Gf0qC w3GxA2QfEHtcAUxImE3trEjHxwckaJY4P0+9n0WZywzJ0PjmYCJdAtLB5xaClMa7o0NUDxjDyBW dB0BLYv+LJIrr/8PbqS4jlG4Fh5MzoX3qAxRfm1g== X-Gm-Gg: AeBDieuZSZSH6VE+zYBlgHOeIQO5VdfPZ0Fo6WBH0Zg5Ed6fJFyCtcH7pnCcCd+dOku 0hnIRS3h14nkvOWfloToC4ZTjEwfCuOOKXODzKOf/Dl5lntdmMaRCaK9O9q4WWtqncPH7lW7BTY z+a4jMyRHA1LlwBkDDzjZsQjbd+L3q8TTDCQ+pwwPes6vMKpA5shaZRiDLh4Jx4hpJB5BKpuuj4 wKw0IRUjyLh+qSowvaHzAB4aGdTNaWtjlrGddDEp9fDF+en1tLArfO8caB++NHY7HxRgNhemF7e MZpWYUfAeQX9d1DinNnUQQ57l0srBoMFpw3eBBIodHlHRbFnQc+NVtBzdrua5YhqH7yzvHG+jT6 c0+Cq+oWR7Y+2XFrkPj9Jjt9Gz16ovIkmYhT/49krcY85QX1dWRiq2GC/Pg== X-Received: by 2002:a05:622a:1e12:b0:509:4198:5468 with SMTP id d75a77b69052e-50e36823a7dmr302362301cf.8.1776802875047; Tue, 21 Apr 2026 13:21:15 -0700 (PDT) X-Received: by 2002:a05:622a:1e12:b0:509:4198:5468 with SMTP id d75a77b69052e-50e36823a7dmr302361691cf.8.1776802874558; Tue, 21 Apr 2026 13:21:14 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin , Vladimir Sementsov-Ogievskiy , Eric Blake Subject: [PATCH v2 01/16] qemu-iotests: Add query-migrate test for dirty-bitmap Date: Tue, 21 Apr 2026 16:20:55 -0400 Message-ID: <20260421202110.306051-2-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802907716154100 Content-Type: text/plain; charset="utf-8" This helps me to identify a hang issue with some recent change in migration. Add this into the test suite. Cc: Vladimir Sementsov-Ogievskiy Cc: Eric Blake Signed-off-by: Peter Xu Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test b/tests= /qemu-iotests/tests/migrate-bitmaps-postcopy-test index c519e6db8c..67d69d9d1e 100755 --- a/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test +++ b/tests/qemu-iotests/tests/migrate-bitmaps-postcopy-test @@ -162,8 +162,14 @@ class TestDirtyBitmapPostcopyMigration(iotests.QMPTest= Case): =20 self.vm_a.cmd('migrate', uri=3D'exec:cat>' + fifo) =20 + # Verify query-migrate working with dirty-bitmaps in precopy mode + self.vm_a.qmp('query-migrate') + self.vm_a.cmd('migrate-start-postcopy') =20 + # Verify query-migrate working with dirty-bitmaps in postcopy mode + self.vm_a.qmp('query-migrate') + event_resume =3D self.vm_b.event_wait('RESUME') self.vm_b_events.append(event_resume) return (event_resume, discards1_sha256, all_discards_sha256) --=20 2.53.0 From nobody Sat May 30 20:11:55 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=1776802940; cv=none; d=zohomail.com; s=zohoarc; b=lHrwWkiEugDmERxoi3h/MBUmWSv54z1t4R1QeL8bccK8qV07KnCiIRMQiuFNTCK3r7HYveK4Fy6ShBV0QecInJVSXsPVloDJyrjhTIQqZkro5A1agTG1OU2/mfYFfNV1amdxnli3gTBosiUj6oLzRnHicoF/8MD3A3YuyDoGW4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802940; 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=IJCAfq6l7HHeAJH8BY9sx4qX9Q2bgzNmAacMqGvPwYBdXr+WlN9VBytcG0ZCkUk2bMHdAJKyEJKk76Sxm9yZPB5yOpFUeR3Kk7A2HNgjQ3vMtVb42Rd9k6i9B3mBxlyjQAq+IXOHaumlpD7nuvg310pYSZ7jj5tQm7tAs4gpcMA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802940197836.0816225584227; Tue, 21 Apr 2026 13:22:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHb9-0000x0-4F; Tue, 21 Apr 2026 16:21:31 -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 1wFHb0-0000vW-Bh for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:23 -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 1wFHay-0008IH-N7 for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:22 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-381-Zn9IZhzwOb6zkH5X5QCoeQ-1; Tue, 21 Apr 2026 16:21:17 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8aca154e2b5so18593926d6.2 for ; Tue, 21 Apr 2026 13:21:17 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802879; 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=I64mFfm2NhYimuit7PBty3Yux1CmDXyjbf3OfZWdfK1axQFh2134m4NXDRVLa1sADE8iy8 Meuo7FUjlaVkZ/4H7tvuSE5mXzzX4ju9ZW2tKTRnVQFWYUIIpngQC4OF0p24TOQPzN+k4o +7KepSYETuv3QSK34Qstuny7YSraknc= X-MC-Unique: Zn9IZhzwOb6zkH5X5QCoeQ-1 X-Mimecast-MFC-AGG-ID: Zn9IZhzwOb6zkH5X5QCoeQ_1776802877 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802877; x=1777407677; 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=gTimU4MTOAK1KNjU+wq6P8yYCt7XWcoPFwJG+IC0oBMFoQvJ/3ERbKgguByB6QTVzZ DMRxMXhQ2Vqq9bvr6YFDh0LnMQNBbE/cLjCEtP0NsW19G2O+xR7RgxhzjIXoPNuBI3T3 iOCgenPa3SBxozWx72idLFwtdNRwUlElWVtg0aM+SCgvwCs/rRzZn6e5R5p2EopPzkt1 UApQ0xVXmTuHbjeMIOrEjydOx6nti0Slpnlw/eXpVQj9meDV7DcvP1hVooJ3/iz/3irv 9id7RPoca0UTcuiaWF11S9/W6gZp+6I/PSkhm91lEISC/M8VagJbwbQGLC+M7qIl5jBD 5/WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802877; x=1777407677; 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=BCRdIDxgc2Kl7SLxIEpTKw0dwdj3j89HmM/axqQ5vPM7M8YZ5awqBwOFx5HPtxYnf5 tvCvv6NDqoyv1b7hJ0YfcVGMdQNm4oaM2/FvF9GSajO1FRWn4czhyjav08SfmqAuSMXY oadzvDQgW1nVfcoBgObTVAVxtaPHB3xQiu7jhI7Q/yvumVNpDWo+82QV8n0SGo4PiyBB 1NH/BtnbCBCziw6ZXmMo1W0FeD1mw4GfUYORmGBHG8R5G+3Xh7ZgVd4cVU3ADiSoT20W PChcUi0aTKG/wuv2rWstV9PMqCQC5Ac+oSiUYYewu4nPt24EQYbN15/88fDOhuuLOPhs uiwg== X-Gm-Message-State: AOJu0YzzZXE8epNQe/aKeJwQYwWPIscLVVoX7or6i3usj9vHY49e5zvv KWOe0fb5Zc/dKD75LEl2Ev2oI7sA7inD8wrjtqApgJQKScBN7iv7X6VbDuZmVodo6hKdEpOnlUN tDpMCeZ5rYD2ZX/eB6GBUmiQyaM/8Jase72HgbBuSFUui/gDyqmTzWO3OgLQkKqmlYqIiDEROt9 xlfFK7OBESXPTmppoVmKLPaWtMKXdBXNUizQUZLQ== X-Gm-Gg: AeBDiesCEvvlHRQVF3tvGi2uD/vM6xZNWl1TVIx/hojaRkyhtw2DzrKrTxzDr/ZOBGv gg2gry/UembiqbfeQGYeuukXZyg5N9rw/puEqaR2T/73pQjSIU7ri0aQ1B2VpaVh9aYtJ3BRW20 m9HD6wJ47kpHLCzLXY9QVeyfSvufGRlitELccACg1Egfd1Jua9HULOXqN0GgvtcRuPdsKyPYazi 2nMWV4Rdv0zAh4j6b4RMc2wnVjGnKMXmB/cvVKvQEd8uGJr4/34W1ZJylyWJe+1nzZN5/IJf2XL z2uupCLSO6FkK9sY1JWUfkqvx8wCN+xqMyRuzR9ekbFn++RgWSUlR0RwHxqrogfMl/Pgc3bC0sh j6rnRJ86nppmXiBYtQ749sW6yDl0218lr5boSO/gZ8ljc66yl9Ib24j80mg== X-Received: by 2002:a05:6214:19e7:b0:8b0:2dc3:31a7 with SMTP id 6a1803df08f44-8b02dc3346emr327435866d6.30.1776802876839; Tue, 21 Apr 2026 13:21:16 -0700 (PDT) X-Received: by 2002:a05:6214:19e7:b0:8b0:2dc3:31a7 with SMTP id 6a1803df08f44-8b02dc3346emr327434886d6.30.1776802876061; Tue, 21 Apr 2026 13:21:16 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin , qemu-stable@nongnu.org Subject: [PATCH v2 02/16] migration: Fix low possibility downtime violation Date: Tue, 21 Apr 2026 16:20:56 -0400 Message-ID: <20260421202110.306051-3-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1776802943217154100 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 May 30 20:11:55 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=1776802938; cv=none; d=zohomail.com; s=zohoarc; b=Zq31oOgwmp2TpSbxxZ00jhbgg8lON/ZzLqbzMgciKU2Wb1lKONUeMQRtpwfDD+5WhUbV7pnxSsDhwTMvZqdNI0VIVvNl4kPpKqAfgISyZtDxeUV8e0vHwqCnNlanwNaXB61Z7rLIaMw8yIi18KVp9zeKV0Xz1uTzyT5IQ0g9wa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802938; h=Content-Type: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=HK7r5yJsLvsvHCj6ZvcZQApu1fAXI4xH5O+3Iw5fIBI=; b=ktmZALPmm8/mURBRkblg9+0vRbFPl9mgLadGJ8FexqRP09MqMrayg2Nnl58XGM6LLdRpfk02KXSzUMcWHOi4l5fs4NbNEjUb7U1BwvfTwEAoKyCz7NFRTNJPIgwy4BwQYo93M+d3VmRke3+1yfuLY8iA4I1W5+5KihRxlT1Qfbg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802938599138.54137906675157; Tue, 21 Apr 2026 13:22:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbC-0000yA-Pz; Tue, 21 Apr 2026 16:21:34 -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 1wFHb1-0000ve-Lk for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:24 -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 1wFHaz-0008KU-Ol for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:23 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-VcVydcd8PIWiwwOmTPCRoQ-1; Tue, 21 Apr 2026 16:21:19 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-8a275472d89so69875956d6.1 for ; Tue, 21 Apr 2026 13:21:19 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802881; 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=HK7r5yJsLvsvHCj6ZvcZQApu1fAXI4xH5O+3Iw5fIBI=; b=gLCfylLtYiqOlw5C1U0Dtcd+R+srCl0Q0xCX5VNWXl4NHalZ6bx9ZtRl/cNy+WPyoYhC6W sOqzpZhBBUts2soEFyWmQ9EqxNg/GC8dWbjBY6+4Q2bmt+HR06xbTPddRTCf7RshjByo/V EUWr7aLfGTaEaDM6ZVAekzONIu60nzA= X-MC-Unique: VcVydcd8PIWiwwOmTPCRoQ-1 X-Mimecast-MFC-AGG-ID: VcVydcd8PIWiwwOmTPCRoQ_1776802879 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802879; x=1777407679; 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=HK7r5yJsLvsvHCj6ZvcZQApu1fAXI4xH5O+3Iw5fIBI=; b=mZ7CvudRDgZAyWn5yo3gJqwJ+1kYCv492T+AgmW6jBmRG5vRmJL4JPQe77MCU5flba y9umrPXEsJa373ar9Ul+0KdJvPJnHcAOpDrweneY5TQ/qXpPw8ADfUYBADiXYNzYfp+J 3sboQpQUg21jwp0zV1ICGu+e2CL3q+jlGYkSjpa0F6SeT0GKZJKabgVXsjZJDvEbwyDV J8fWyVQkBLQw1XvIspZobpcekHfwMI7rtOq7qT5h5EaSOxOnOMOqeXTpTFZjEO3/ZREv hymvRT4SiuUCbm4eTMnycJHdvciVYRfz8+eFzhxh37tCwoG/QadEV4fPd3po9BJbokMQ aUWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802879; x=1777407679; 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=HK7r5yJsLvsvHCj6ZvcZQApu1fAXI4xH5O+3Iw5fIBI=; b=h3juv0XuX2mpdsnltSAEbZANsWd0TetdXfZGgDttxZmQiN3Raz7zHgHdY56OBCmkNm QUqUUbryBfiMDbLVBtBLNa3ldKuEcuNCYPWoigLpn2enDDC81+8/cGzRDp8a0CChZcke GBjor4tV55VoNXUFcJbKLil+iGrmmZez4iPJMmhBa5PU6AHive9+kJk03DpVf0+7FObE DM8QFU6b575A5CSS09v3jR7sl+iMqgZpPw71ogc/MHd79lI1WrRn/Uyeqdz5IJrOXrBy ICp79U6ddoyzQ/NXbyR5mZZFvK21fgl+Ag8UplZxvJE15L4x4iDNGEKrvZRFPEUH1Jm6 XRZw== X-Gm-Message-State: AOJu0YyT3i7UZhEHaL+O/T9ToxS6xVLrMt6lwnsG8r+VOuGA146ZFzKx BzPKZ1xs0bI91vyGnkiI7mwEjBgcZCpdJhYk2f1clcgAQMv0xo6tWXfl45lVdFLG00LSmU2hgUw +E+njD62/QKMht1AqEruMiC7m22hfeWoP8fjhA52C945urXkm7WPyz2FlBCrPhpkgT/WspNPq/L 7ZrA4xKevb0N7D9KQEXWcZE/JB5IDjWtUu5Dygbg== X-Gm-Gg: AeBDieu/9qXOFKzz/4q4N2UHcK4Lnk3FdAVgnI0gyBpfxF4N/K4bmNxey/JOWU26Ws1 BtLXaPnYxDtebUEcjaBg3G5DHM3U693QtXOoS8GrwOEWViY+XzqdVa5+AmrQ6sSrv/cLyqsUhn4 0umPDjTy/Xf9hnPhh7yOvbtHlWyNkQwLcmDuFuOnINaGR3xkPG9atnmWVCv+FZQ3zvCv9NxAeRW GZzcK+FUK2O0EgaDZlfc4BhBQJzoZ9rCjEwkxl3FcdX97AuFpO5bZf26C88qNFl2k1wC1DHOZKZ FeBL0NM3HD2H0FELVX9aqruLJtZqHWIO1QyHtwxs5iWNPZ8oyMGMimlgXkuy6DX5LQFHzSyZQVZ JInKG+0ncHIsNPJZKXybWdlGoP3jz3+fL0Bay4rgpuvoehyJH0FBVW3wnrQ== X-Received: by 2002:a05:620a:4589:b0:8cd:827a:2ab3 with SMTP id af79cd13be357-8e792758976mr2733896485a.55.1776802878558; Tue, 21 Apr 2026 13:21:18 -0700 (PDT) X-Received: by 2002:a05:620a:4589:b0:8cd:827a:2ab3 with SMTP id af79cd13be357-8e792758976mr2733888685a.55.1776802877831; Tue, 21 Apr 2026 13:21:17 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin , devel@lists.libvirt.org, Michal Privoznik Subject: [PATCH v2 03/16] migration/qapi: Rename MigrationStats to MigrationRAMStats Date: Tue, 21 Apr 2026 16:20:57 -0400 Message-ID: <20260421202110.306051-4-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802939906158500 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 Reviewed-by: Juraj Marcin Reviewed-by: Michal Privoznik Signed-off-by: Peter Xu --- 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 e75db08410..626162022a 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 May 30 20:11:55 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=1776802927; cv=none; d=zohomail.com; s=zohoarc; b=PqrjKAm8d+G3/cHkwy00RvTDGGF9XsQkiRlwF1xaCFWMnexAiZOkoMH1DWUpSWaA3m1I5w/opzF7PuanrliLZQ2biKFM2QJMclIDPiDgDyZDuS5uFgcg5x7+axmvNorXXN5+9hGBUUbb1GQdgRVsjxS6DDaq/yG8/ppiwNhbBrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802927; 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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=; b=QF+3ClMzX6ejLMxzdaoh1yG7eGhLCihl+wWFRNSvtY4kTvZQVdZ7Q4b3c3bNr9QBzqJfs1OEvuIDmmLYtH6vWuOmejJ94QCd4T5Egop+Lr5/Zgt1VR6jG+9heXS5/FkdUHfslHA7M+wFhkano5Bk+vQvO3r2UpRty8k5QfLxCa8= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802927529321.89343986994413; Tue, 21 Apr 2026 13:22:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbC-0000yE-QX; Tue, 21 Apr 2026 16: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 1wFHb3-0000wR-Fd for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:26 -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 1wFHb1-0008M3-3l for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:24 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-280-qgbagd24OwCFHrYoiY79lQ-1; Tue, 21 Apr 2026 16:21:21 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8ac9609d3d6so123117436d6.0 for ; Tue, 21 Apr 2026 13:21:21 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802882; 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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=; b=AGZv7/xvKsSGsMKKvV3wgfPJj6ALuqXRMIKbGlqCn2tA6n0E0orHKsq0n2H/Fyz/IiU7mJ do9ooaLEHDmCnRYvIyU30cKwSjZdprmb5+IyFETIoY0l1doxxbTF/mXibpDjKFxJTHq4Be P/9dL24DDP4czrpUNKnYDzAY6jAP9zc= X-MC-Unique: qgbagd24OwCFHrYoiY79lQ-1 X-Mimecast-MFC-AGG-ID: qgbagd24OwCFHrYoiY79lQ_1776802881 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802880; x=1777407680; 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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=; b=NcjKn/ITK6k1XdFp+U/VdSl9W7IwwmjJKCYGSvTCdfT+tpe1B3GRVM+3+LtbuADgEw AtHvIPBaceU+Nffau9orxVjgb5HseNjymryaEjLrUgAr7nut3PHkLxBkJFlvm6CFyhNv x90iLiMtgaqowmXTblq3DDBSxccHNxU4HCgQPTsrzJhkwnzA4tBNPfVbxwK5dQXltOye rnvcQh5bUZUiJ1PpMFjk3joTLNKX4KIMvL+vn4at2nB8MQZLeHtpuXDcdkTVQbnYS0qn 8gmix8cwkQhS9KJxhwC3q2szSw7ZPLlx2gFk4MOoW3r2Xy8KRkE5xUA765ANZQsOeWgs szDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802880; x=1777407680; 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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=; b=bGPvRmW02NyD1/jJnmPS0BRLh3tvyZpd+8Hzy7iDx9uNoKmDNwBbjMo+/nkjTelG/9 PetrqoMwLkOjkNT6TgAyrSX8WaSriLPCvFidSfJWFaVwfTVOyDLcLhapTdk/moj+2Kof 8dAED5Wgc5DhAQmAwq5xZBIOoNljBW05fuqIT7+A35r7M0YEg2TMOJrdY0ZZYha6yf0G DIxg2XCjm1vmPMfbpHY9e6ygG9UQXnS7k0P9ZwMHcsefL/LKALJDPAo24IEKmwLcIMr6 iyQwDjH7o+besi1GRyhw8FobhczWhAc7ck/REV1MBA/Ywk0mrRlje/JGFFhyDp0yGnvf K0Yw== X-Gm-Message-State: AOJu0YyMyn9SK3NrARsrQgiFPfHgU2wNCFtcedRKOYnvlWDTgurj28Pn e/FePyOH73WYJVIK3geW0gHWdu2C6h5NZg5beaZl6G+NpZ9D7wClVtgk9/jewmH5gGBKMff2LMi YHrQMUoulj5/ARWd+SdGJJ017uPEs3sSPjDZWO5/sATQK4edPtKe23o48NUggIAbGfN0t8X2W+v dyb3w806d237S+vH0P3A2r48z0K9DUipaqKEICvA== X-Gm-Gg: AeBDieuYfGSRvmwNCRIedepyDfF48Eg0cteQ6evtyAm2Upg98lsOt2YNfPYydcEB7HP bToIHgEFtPSyYipmwcPywz+rVVqaPNXRAglBHiyPiEqWzSM9tWvNZUWCReuxuKBtNKVCDY2h7TU k5NGEAm1DaU2NgoFkGcYhftSSPq7Yf7nj3zTiemUdDye2qFQjLyno5w/CpgIHM0cGcO25dBi1OO wpuFcy29kCikmmivKJGuUsEQdBRnf5ao5j8O71hIxF4O3sBmsicMKCaOwIwqx275oD7rdu/Ij34 qIeQIIXK6l5tZmmB8C8CVi0sttFVAhnv0wA0dGyMjhW6wx4nPctLOaYYg70fE2gM+qDkVwbdIgj cd1+3gJibdBwS9C1MVRQsd4DfmKlvZbKIeIG4rLMQNVrBEzmwxfS98U1doA== X-Received: by 2002:a05:6214:cc1:b0:8ac:af40:53d5 with SMTP id 6a1803df08f44-8b02810fc05mr298319026d6.34.1776802879974; Tue, 21 Apr 2026 13:21:19 -0700 (PDT) X-Received: by 2002:a05:6214:cc1:b0:8ac:af40:53d5 with SMTP id 6a1803df08f44-8b02810fc05mr298318086d6.34.1776802879194; Tue, 21 Apr 2026 13:21:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 04/16] vfio/migration: Cache stop size in VFIOMigration Date: Tue, 21 Apr 2026 16:20:58 -0400 Message-ID: <20260421202110.306051-5-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802929849158500 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. Reviewed-by: Avihai Horon 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 May 30 20:11:55 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=1776802989; cv=none; d=zohomail.com; s=zohoarc; b=bQkInhNQXBmaqQLS3GxkFHct5VYQzKUcKjI6BB4m1Jz/brJpYFeq5AVWUhxuZCbfmyluPex2ZZ+ooKW7Rcinnez0I4HrfPaN86vO6yJx2hu2w5gF2wWBFT4ZBqSVtrwtQu4/Tu6s2eCk2QlTxAMoN/yKuTtvloePi+easMAjaEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802989; 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=DL2qnbA9IqENDBtthFbQ2rEXlgTK6uX9yJOp2U+0EAo=; b=gYmej2YoowmbUmwYkKitron5sUGbw9rsgnuBHzLtkb31GSTU3te9W5ohY4RmIWBPS2Qkf6S7kEOBBzYN6STH3/DwmMMDpavnzKn20HNZTAFQ8LvJ7HoguuBrCx6qkTAR/9hzWS+vSFluEjj1BrJjLnTz97gGo/FsmN/RvmcvA7Q= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802989139170.4352787816324; Tue, 21 Apr 2026 13:23:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbD-0000yX-7x; Tue, 21 Apr 2026 16: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 1wFHb8-0000xG-2T for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:30 -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 1wFHb5-0008QU-5A for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:29 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-157-iNXdY0gWNsePvNRd4S2wgQ-1; Tue, 21 Apr 2026 16:21:23 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8a16036c90eso117703196d6.2 for ; Tue, 21 Apr 2026 13:21:23 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802884; 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=DL2qnbA9IqENDBtthFbQ2rEXlgTK6uX9yJOp2U+0EAo=; b=CSr0twybRX0NUE3VgS9rmxpIW/xUrdR0U2nRpOcnSmYvAQUR/0MlpKJwtL40p0DhBdLE8L VmTOOYnnV9pl9jowlCKYHbSuJSTbRPYUbShmxMH8Rgr5+AMRuIaOSktiTnhTlH1uUhphbr RQY9eVPcHiGP2P3mQnxRxP4guhXRwVY= X-MC-Unique: iNXdY0gWNsePvNRd4S2wgQ-1 X-Mimecast-MFC-AGG-ID: iNXdY0gWNsePvNRd4S2wgQ_1776802883 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802882; x=1777407682; 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=DL2qnbA9IqENDBtthFbQ2rEXlgTK6uX9yJOp2U+0EAo=; b=EfxXDgq0sUcT7ABkdTExtmIJB7In6KHuAI9KcPYNiGNpYXMjWcOv2WrYXvsu/h0wCW ye4E5BGozxYrdSAjFj0yFZrSYjsfq2YtHrytdB33EASWXxH05OBs4tHL1QDYlcbCH4mR T9xxrMhBeE0A08d16TRcYA3e6lGZ+ITX9r80wJyYDs0H7X5bhsXQeKQq12L8acz3ifhJ jLtKez1K+uesNkn39GA0XVUEdMb/lOegru1nCLy2oDIbxoZ8Dd2SWy+SbcLNd+aRIWAr eCpu6YPWhf4xg2i9QfEF3QcN2eMAfZubo2cCX8Hm1YQ6stMt0h9vU+uR1njLOqa28q0Y uj3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802882; x=1777407682; 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=DL2qnbA9IqENDBtthFbQ2rEXlgTK6uX9yJOp2U+0EAo=; b=l55bgUQ3EWJNLFFgmnECgU72yNtp93om0tv4oc0JAZS7NRDMAfUTN9UJ6byFQrRARr hNOH73PL9SYX99Rf8dEglmspUMHIENsS10EHdYISRlJ560Gl2xCxA7Epv5DQ58NBnKX3 NPTYupOil2DjiqliMoJz1j+X2wnORWCzm2L+KAiGbX3z+kbL4QWRYj1Mef00sp2ocf56 uhkPUmkn2TvajY03C0FZh2Z4o7becL10tFH07GQtRzBoJEbVZ574NI15EEi6blGPxlNa 7M3o/ehMZAza2FjYq5WcaWXs1mmY/X32glZR6EvV+osI+/T9MTDgD2AAzwsqy6pU+FUd Y63Q== X-Gm-Message-State: AOJu0YzjYumXNgPb4RxSKXy5vMo4yNIeD17/fXKUVLoxLY576qdOk3+g dpTC1wKM7p6Mnl5i8iryybsl+AfwZ1rDm7DHi80uirk8nFQjT1pCY+Y2vyF/rJDNrLP0xMf5cf6 Afv9U49cC3fZZBjIsfoc8+ssfXSGpswyWY+wGcV3konvjLT8L0y+UkhrUBDo7fcn5ptuxLA3Etu hvigX7E/F5MXHBeWw2056JuuVEc8PPFRLiEINp5g== X-Gm-Gg: AeBDieubxMH/ajHVpjyqFgL15KCnZ9fjEz7XzS60ppvM38Cf5xk5bcKMnTNCLapqiCZ YdJMIHuIM3T0fD+BjPTC5T0wXf7qJnkxaJh0cqom7ioSa0Aq7J8kNuW3UbWKQE4Yea8HUb4VCLl fVHL7H7X34Vao34BfZaoCc/8pU2cDqzuQ+9Pws2LgXaX75LN5fqgt/RJ0qSRR9GDuaoxy1JE87I VLFGIynOOU7nY0KsJ1DPR8HoSIowq6zKf6scbvDZ6TANYP/uxG3Mj3ON06gnklO/U9xwIp0nPsF vV61pUR1Pks9xrgBAdvBNcf0Im2Be5HvKXuUe1rRyvzGpXkoT3kgNfvKwzDV2goajLP5UbIABoU SKUw8NsvpHt3rEJU42OOze6HM0prbtllQX4uMnJkcK1gNyMWHJslYL6vaCw== X-Received: by 2002:a05:6214:8085:b0:8ac:a2f6:fbf7 with SMTP id 6a1803df08f44-8b02812ba4amr262990746d6.40.1776802882087; Tue, 21 Apr 2026 13:21:22 -0700 (PDT) X-Received: by 2002:a05:6214:8085:b0:8ac:a2f6:fbf7 with SMTP id 6a1803df08f44-8b02812ba4amr262989836d6.40.1776802881278; Tue, 21 Apr 2026 13:21:21 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin , Halil Pasic , Christian Borntraeger , Eric Farman , Matthew Rosato , Richard Henderson , Ilya Leoshkevich , David Hildenbrand , Cornelia Huck , Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , "Jason J. Herne" Subject: [PATCH v2 05/16] migration/treewide: Merge @state_pending_{exact|estimate} APIs Date: Tue, 21 Apr 2026 16:20:59 -0400 Message-ID: <20260421202110.306051-6-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1776802992020154100 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: 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 Reviewed-by: Jason J. Herne Reviewed-by: Juraj Marcin Reviewed-by: Avihai Horon Signed-off-by: Peter Xu Acked-by: Vladimir Sementsov-Ogievskiy --- 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, 86 insertions(+), 132 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..691061d182 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 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..e2117e8dd4 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,23 @@ typedef struct SaveVMHandlers { bool (*save_postcopy_prepare)(QEMUFile *f, void *opaque, Error **errp); =20 /** - * @state_pending_estimate - * - * This estimates the remaining data to transfer + * @save_query_pending * - * 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 estimates the remaining data to transfer on the source side. * - * This calculates the exact remaining data to transfer + * When @exact is true, a module must report accurate results. When + * @exact is false, a module may report estimates. * - * Sum of @can_postcopy and @must_postcopy is the whole amount of - * pending data. + * It's highly recommended that modules implement a faster version of + * the query path (for example, by proper caching on the counters) if + * an accurate query will be time-consuming. * * @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 to 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..e965ba51fb 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, exact); } =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..287df0b8cb 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, bool exact) " (%s) stopcopy siz= e %"PRIu64" precopy initial size %"PRIu64" precopy dirty size %"PRIu64 " ex= act %d" 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 May 30 20:11:55 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=1776802976; cv=none; d=zohomail.com; s=zohoarc; b=dB0ZOpbwljnIe/HAG6ZrpOPCKSPGDUwxUVqmjMf5zIGNXRo5/YZYywDTJW21tXXR2OK3adRnqmmaJ/BEB7JvdpgJakpPtDKfdTjBs/e8t/4RHbzy4G771WXfuSVJoDy6NNNGvd5zFRvXriMVH0LhmvVF+Zn0sPKWPcHPC9/ZATM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802976; 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=aXWd2xheC1/z+v9Law34/KvsAvj1ejFluJIlYRzmNs4=; b=itzL+B4+e6hXbj6ebg1hka2+5qN6yG07umrKw5+v4xFSqWkCIPzhG9v9SCwhhMZ7iLBTrddaA8Myo73utju9rM5ywG82b+yE4WCUuTEDoBc5SSx/+m26n8bJbeYuqTjKCyV9i6XyxTa4MKxDI4Up8Oo/HCViUVqvQZ+5F3RvIlQ= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802976828627.3692251900767; Tue, 21 Apr 2026 13:22:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbI-00010z-Uh; Tue, 21 Apr 2026 16:21:40 -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 1wFHb7-0000x8-2U for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:30 -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 1wFHb5-0008Qg-5M for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:28 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-247-z636bWEuPiegWh0oc0GkHA-1; Tue, 21 Apr 2026 16:21:24 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-8aca154e2b5so18598166d6.2 for ; Tue, 21 Apr 2026 13:21:24 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802886; 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=aXWd2xheC1/z+v9Law34/KvsAvj1ejFluJIlYRzmNs4=; b=Slh5Exd59MHcJXu6QD3NqbJTHhbrsITtF6zcVd9M2CxeSv9elrUZTfHdgjaQsERc1xc4Ng BUAGbOL64rHn/V+tHuRmbF/onTYBb1Kqobtw8y+1Zyzva5kcUG+0k9R1LuqC88Ad+n8uw2 sZsRjgu1nYku93fqrq41wCQTumUnz2s= X-MC-Unique: z636bWEuPiegWh0oc0GkHA-1 X-Mimecast-MFC-AGG-ID: z636bWEuPiegWh0oc0GkHA_1776802884 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802883; x=1777407683; 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=aXWd2xheC1/z+v9Law34/KvsAvj1ejFluJIlYRzmNs4=; b=DMK/LoR5qNDm5T3yDxBTHsvTCQzl3FZVHmn1zAs8M7KzJOpQiht11EPXdHPJVMhBO6 FO5WmDq3jVdaUhz0L7gOeQw6qRuWT/J+K5OoBdTXnElmj4+Va8Is+B56TdXYB4AfPgIm eyLftYcZwRUp4FQBvWF7ZUQTHHQTlBb7nbg5RRtbzNlpgZjI0xUy9UuWOrpzSR5GCH9z 2OClUMQcn/JrPfopOaCojauQwIAjA93HPr7gh2CW/QIXwUeF7mhtNWo6IzmRMqNjSBsB 9/qE9KVMwcu5aWwitdyp+j/V7PY+z98PHRTN34ngGzde6dTaJ+MAjkmLycdwmACg8Crz lZJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802883; x=1777407683; 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=aXWd2xheC1/z+v9Law34/KvsAvj1ejFluJIlYRzmNs4=; b=tPJc78gO+JbWFSBV6UBAp/tsI4DYmzIb4Ouii24e+/Elc8AHv9+bRKJxtd4T7MSZ2P 4WYquCrpZ736tw8saPOsn2ct7OE/gYrLb7z+p7yOwqEhVM9Ebk5OXPaTz6ISpnMgUkTR 2EvUW7W3sKt8jy6hJfMzH6R7jDWQGfaocj5f9yRHeNBRBDfSpLch26ZU+i+JBRE85kJS n1GgSCpD1DcD40zM/vz/tihuJypZSOYaB6fYyVwbNzN94aXH9gSsNQfO3vp0w8RQm8GQ kMkBULLpWe1KeHpJ+3hu10HeOYDqg4tF/tbftbCAoyEgCsu3P9W/anchFW69VC3l7e2E 8XVg== X-Gm-Message-State: AOJu0Yzt7tgFwFCSUft8v5C/220GtymJ5JRXgGF/lDU+02gcj2gXbrc4 YG2LL41o7F5cTKpOo8WZ66+boJ6MO+U20gcWznzU5Q6J5hebuxa9zltQFJeQxPB0qFPt2k+QfVI IoFJkqftGdgVuj36D7lu68+Q63mha7CdD8Twhpzf4hTiIFssdF04s1C1LScqMFgLU1oqSLbm0bZ L/AnE2ZHK9qG7LkDXwY5QGiF050LfIrjtMZST0LQ== X-Gm-Gg: AeBDiev4Qx6N2f8KVpwgAmwmuLKx9d1hOpy/wLnLTCR838MvrylQ7tYvRe4sr2UYjG3 dCyI7hVe94Y9EUQzwMjph/K7T4gYf4aSFFfhSc5cHdMFxH5mCph7S59LnZewEW/5ut0zbPa6+LL m+6phDfTFG4Y6CxbpaRMDRfUYJWV5A1IwcAafcQPNE9hIL4zx7DfPhZS8Dtg/WtR0+GJZX2h2+N H8txGmJlBZp0hPk7lSkRytSuDtJOl2VU9iWZlEZz17v7vljTtgm7ZC5qJvtnH1Zmh4dTCf5YpMy 3E7Tge7gviplaxEKtNbOAYG+PIQ7M2apifAey9b0kUbloW5COsD02diaH/uDyzT2a2vS/0loCb3 5lipbBWt/eTeovrZbx/jrsWwbxa1qIqTKj/o9gmHdn/B8XFhbLGURYVXjFA== X-Received: by 2002:a05:6214:598c:b0:8ac:b6d7:e60e with SMTP id 6a1803df08f44-8b027fd9d4amr316352556d6.7.1776802883390; Tue, 21 Apr 2026 13:21:23 -0700 (PDT) X-Received: by 2002:a05:6214:598c:b0:8ac:b6d7:e60e with SMTP id 6a1803df08f44-8b027fd9d4amr316351876d6.7.1776802882837; Tue, 21 Apr 2026 13:21:22 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 06/16] migration: Use the new save_query_pending() API directly Date: Tue, 21 Apr 2026 16:21:00 -0400 Message-ID: <20260421202110.306051-7-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1776802978027158500 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 Reviewed-by: Avihai Horon 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 May 30 20:11:55 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=1776802964; cv=none; d=zohomail.com; s=zohoarc; b=bsd8qOYgZx3toaotT2sweX+5W2RBQd83XEXuXJwG1EaoSE8Mx52gPZdaCEXjcvN3Rf0lPjCT5hjjpI8UFeIQfdic3gBwnepLzxEDVsk/cU1uLKUBzNK+JSyz9p6IBFXurn2pytWxwA91Clx8pIGo7214/lWhtQFmaxsgvAyraVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802963; 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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=; b=CcWPOkxcXvxMNKGQHZJTOJTFkoqCU5JW5VDV8Idzqz1E4EjnATaC58KZlQtZz5SUIF6UER4AloZVU00Z1zwm4+W537B2khPzjI/KIu0vKM/fhino2dMBUXz6YBArKOls53EOPB/BxA1RJ5CrPhJGoXasGbycyWMXZuXuA3k8lIE= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177680296399073.46367883947585; Tue, 21 Apr 2026 13:22:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbE-0000yq-F6; Tue, 21 Apr 2026 16:21:36 -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 1wFHb8-0000xM-Sp for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21: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 1wFHb6-0008Qt-DX for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:30 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-340-GYCqj8JLMpiQdSr7yrD_Og-1; Tue, 21 Apr 2026 16:21:26 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-8ae752c5273so86571906d6.2 for ; Tue, 21 Apr 2026 13:21:26 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802887; 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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=; b=YhStOHSQlN9vY7UL0GH8CPDPkd7GeCKRlT6VV73x7dUIr2xxlNqcMCz7GzTFozCBC+eAxL eglNitEP30JUD8SIYQ7KzWjLI9E5KUUQ0leYHIj1vPHvv6CMnFJPDasrKJIeXfG7joaIlH /Bb0SZDO2+CkWhXNROynPN8rjJlLhWM= X-MC-Unique: GYCqj8JLMpiQdSr7yrD_Og-1 X-Mimecast-MFC-AGG-ID: GYCqj8JLMpiQdSr7yrD_Og_1776802886 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802885; x=1777407685; 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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=; b=Mq9cjpQ4jqZpIUFvb/dn8E/L6eskXKKmvqIXYU9RvW1GkSU+LZRR7XrUkLBvpMuvAR 3YCz0aUiPveWPLrzYtzS5sHTgcNRVMmcTwPWtdfNvgygU1B2+TxMbGIPZdTdVpM0H5th rih7FaGENpOzK5ZL1gzxsi+kTXU12BtB8E6r+JVt6PidQu4xS05I9fW5uld2DmYKf7Yq sqrbiu4pxP6PPJiJAaRGEacE3suOZLaoIu/VL6mnZUVXkdfdLmTLV8i8e/TgRJRHv4tL NX1wwbQziRbTV2FvpKinZf4iFkRQA9G5mpj28Vb3dNSpGbAuQjdcXlQOwc2V8JSQYMN3 /vqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802885; x=1777407685; 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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=; b=VX1ObUbum5CzWcG8oThw6IJ8QbQAspiJcBzr68dvbkr55eXLwzfv20iGfSJuM23g2C 2P5z74IGL0S9ZohgjsJfFHZHUCD6LPrpAXGydhFP/xUlOR8u49KJ6O4jvJ7BCXpVppbp gtAygfJ/0DCCN3O1Grfp/eE8kb94wPaEc6KUY84ITq9B1qGwIMWQDtKZ0kVZMHSMT2C4 MCvm/2TmByZIV2D9mRDJAkQqVYf1VPgaKcJwK6CrNq+3ZeLd35RoHgGt9SvxhW/SDGCM pbk2n/6ZJhPAOE1ROBMVChBY9oC41n6aGh3z66MI+/AoQZncOvpGwZXzI+lNC68F7pYf 4l6A== X-Gm-Message-State: AOJu0YyKiCkjvMxLZ3V0PE4kWpOppHjOtub9D1ZOMWt52h5c0ja2APPj C6kAS5ZPQ1fcnYBdxBdcJm498WJA+l8yyt7LQcek0wBPE/AEgtSJeHbfBRHUbW/B6ssHDqi+Jp2 vt61mvlqW/notrhuyYAIylRh6i18nHK9s+Mbvc/YHotHkEndDBJwWAnTjd4nnEdkoh92kMsBWcS 54MShdbi1iVkISzh3fMQ9ennyIUAYfIYpkj4eFDA== X-Gm-Gg: AeBDietBpZ9hz5EtCyFHFfLtsOxPfG9fEkrUPNPY6j6m3pcle3tfKTOMayzHUaMNssd 0/FBkqVHR8bZ4juWLN47gjtE76HHmCJ36mqsg6kphBMgaWQGFzAw59GTFy4teeBLJtmop/tjat0 xSQzRU6/6m16jyuEvC3oTZ7MGP7zEO91F18aNdnopaFDOvi5vD1S8HVeMpuaoMx2M9Q6UFliTHT RL60IuncJw3tCM1gu5PnSt2ftmoYx4+Ihhdy7JYjF4SRNJIpVikLr7x+wHV8xtqszlqYnOtMc+F MfdMaxMqUGQo0FENFWvvH2ncDbzYMKLPgXH09rXw6lI5MYAfdXNhmoiF0Wb4xcENwfZplAGTDng 1Dq9+NT3vhNQPhTZjGW0yJOO8Uj0PQfkQZLU/FXcyqPlrHKzp23rsVDD6RA== X-Received: by 2002:a05:6214:4e08:b0:89c:d886:c022 with SMTP id 6a1803df08f44-8b027ff9304mr273283706d6.1.1776802885368; Tue, 21 Apr 2026 13:21:25 -0700 (PDT) X-Received: by 2002:a05:6214:4e08:b0:89c:d886:c022 with SMTP id 6a1803df08f44-8b027ff9304mr273283066d6.1.1776802884724; Tue, 21 Apr 2026 13:21:24 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 07/16] migration: Introduce stopcopy_bytes in save_query_pending() Date: Tue, 21 Apr 2026 16:21:01 -0400 Message-ID: <20260421202110.306051-8-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802965485154100 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: Avihai Horon Reviewed-by: Juraj Marcin --- include/migration/register.h | 7 ++++ migration/migration.c | 65 ++++++++++++++++++++++++++++++------ migration/savevm.c | 10 ++++-- migration/trace-events | 2 +- 4 files changed, 70 insertions(+), 14 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index e2117e8dd4..5e5e0ee432 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..4b54fda4d7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3198,6 +3198,54 @@ 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); +} + +static bool postcopy_should_start(MigrationState *s, MigPendingData *pendi= ng) +{ + /* If postcopy's switchver will violate user specified downtime, stop = */ + if (pending->precopy_bytes + pending->stopcopy_bytes > s->threshold_si= ze) { + return false; + } + + return qatomic_read(&s->start_postcopy); +} + /* * Return true if continue to the next iteration directly, false * otherwise. @@ -3209,12 +3257,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 +3268,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,14 +3288,12 @@ static MigIterateState migration_iteration_run(Migr= ationState *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? */ - if (pending.precopy_bytes <=3D s->threshold_size && - can_switchover && qatomic_read(&s->start_postcopy)) { + if (can_switchover && postcopy_should_start(s, &pending)) { if (postcopy_start(s, &local_err)) { migrate_error_propagate(s, error_copy(local_err)); error_report_err(local_err); @@ -3264,11 +3308,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..d221e2961b 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,8 +1778,13 @@ 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->postcopy_bytes); + pending->stopcopy_bytes, + pending->postcopy_bytes, + pending->total_bytes); } =20 void qemu_savevm_state_cleanup(void) diff --git a/migration/trace-events b/migration/trace-events index f8995b8d0d..d2134af862 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, uint64_t total) "exact=3D%d, precopy=3D%"PRIu64", stopc= opy=3D%"PRIu64", postcopy=3D%"PRIu64", total=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 May 30 20:11:55 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=1776803001; cv=none; d=zohomail.com; s=zohoarc; b=W8NWryfdfF0wkt36cfQVkPnyP2CVEqhJlIpqv/vfUy3SxGzL5cM6h0M7e5iLmAYLBYDoB8ub4JldnmY6ZacZh2SlNQBkdd/rcIzHNkgZyznq2YKdQBwzDZHK5su4FBkjdPhNpj0XcSZt85C3Xag4i8yHWSfZ22fqZENnXT8Dg+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776803001; 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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=; b=WtNo67v+hvsXV6UJMmaCeqyKRNSHwTdtOF9uQxLhN4AW5VrosR7vq3skKZF5Z/In5AhjXZEh9muucZ5xNvSfqDxbwUd/p8f3Zv8e3RUMerd0voFre63eKbGqVlXCtZe0DIJkh0fz676LXKVwRZ+4OQa2TuWAZ0DFqKuFTVnG10Y= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776803001574374.8301444247628; Tue, 21 Apr 2026 13:23:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbD-0000yk-Nt; Tue, 21 Apr 2026 16: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 1wFHb9-0000xr-Kd for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:33 -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 1wFHb7-0008R9-PR for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:31 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-170-_SuEQvpmOZemoCx2UR7ZLQ-1; Tue, 21 Apr 2026 16:21:27 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8a275472d89so69877266d6.1 for ; Tue, 21 Apr 2026 13:21:27 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802889; 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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=; b=cYBTGFVd/JA7IdrN4APu8XKu3V4b5UTwzTFpT7SzVSV09vgiAJPk7Yp2Kd61sZtu0jMriG B3QrHGTrwCcJEIAR5JjcMPzxLD9/VswL/6zCYIbzkaSMGl2NI9iFR359GWWBlsi8nFyL4L ZQODVC6cmdHxlJ+0qers3wez8S8I7Xw= X-MC-Unique: _SuEQvpmOZemoCx2UR7ZLQ-1 X-Mimecast-MFC-AGG-ID: _SuEQvpmOZemoCx2UR7ZLQ_1776802887 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802887; x=1777407687; 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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=; b=CDgyMvHGmbr49Za/wCmF9F201qEfau+WHSFueiRFF0K/8t53VQmSa4Vi7SxsGpIl2X KnsaNHaEnKuJX/2iKsBNSrm8Pr0WrK9Y5HBbTTpsI8FVtcroe1OIezY6rsDyP2ORNvif 6e5bfBcu0FYfXt4Q0UraMK30SMUya/4k+0H/Qr/fwlNGbOcSqDs+UdtJ8D/MpgBy0HvA aCAUe6ty8dM9PvT2e6vBYqJrzHeHVDtx9vetQ70vhqLA8N+PBfsxI6AHHloQLRmYJuuA 0a/y1rfsOuwCB1Lt07vtFRx0Amf9LRC1np42akgFQ59XSGAwft9+o4pCWnkT9k8mUpfD GWUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802887; x=1777407687; 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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=; b=gu2orQ4LuAyk5ykNkfiV9/UBL0EcLGLbcl4rh91ZF37cgF+CnrEeHuA+IJX0NtA/74 JUYmCj4xFINneHThYuMppvM6isVipJ+BT0gg43zATIZubhE4tV5PdDR8prG/OB0KNb47 mKu+hyFLPcaLRxEqtcv7ckZMRZGvjleni8FJgd4MTITa+mW8JtavV4dsRPNcV9G79bCH aMSfsg4f3rdR/QUlduGLaFVYNqRzGFIkhpX4IORyxePZ3NoGEbwBNrLw8F+zsXTFyf8c IuKMTEgNwqnxEiQpVs8IKiTW7Giw5PEymBdG2Wgrv2Q4VNjiCFixIA8Bhq3OqAJY0hcq vQbw== X-Gm-Message-State: AOJu0YwT/zouZI0hCGfwu+jw+V5J5nwoW4UaiWLx2xgoAs60yQkrM3Xh aVgXoGHVOgbUD9Fg/U5LTp+dFJ5r86qkrxEhdmbMGtiIrdYXYxZ8Zmu+qwC3ZLRL5sW+ikPfLPE ziMbh0+501727xQNCx7i/D2EVTSDoRE9kBCGgmQCCayQ10b18YYB0LYiBfbt+NzxAYGa7B7bgdM KDWakel6PbNywPHEKF7co1EAgZv/tUN+TNUmNoJQ== X-Gm-Gg: AeBDievtd3DMdhfE00939w5W2otk05jSwp/t9f/q0BTbbtQZpN0oUwybMFeABvVQHsb Pwy1wToe/cYUV9i70YhvsWTErJZGmKMiMHLbUvDGSOUUV+Pt2QTlcnC5fGhmR++FZai6cnhrh8F vXxsvHMVL0MepROlsPpzdT07JPhXsltwD1oSi4xR96daKz27jzb4YSZp+ipy9saF0ZBzv0JKqGp SEKVzbcj8Tc/O4RBMuLm1vaD7X+UEo7AEsAjmxEvGD8mKBWK+2gG40oM2F19jUIlARVSX+wHIIF Gih62G+tnOU6N7FGWan+TAcZ8KWRmO7dvwz8ySRN577g3aZnn2lM6FN1z52H4zY6JS7LWPQZBdj fhDXUS+fLV4Yy9qis/zHVNToFcWq/yqUK3ikBvDyPt0Xg9/hGnRhMupN6DQ== X-Received: by 2002:a05:6214:2521:b0:8ac:b6d7:e60b with SMTP id 6a1803df08f44-8b028013c49mr316275196d6.1.1776802886735; Tue, 21 Apr 2026 13:21:26 -0700 (PDT) X-Received: by 2002:a05:6214:2521:b0:8ac:b6d7:e60b with SMTP id 6a1803df08f44-8b028013c49mr316274406d6.1.1776802886015; Tue, 21 Apr 2026 13:21:26 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 08/16] vfio/migration: Fix incorrect reporting for VFIO pending data Date: Tue, 21 Apr 2026 16:21:02 -0400 Message-ID: <20260421202110.306051-9-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776803002050158500 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. Reviewed-by: Avihai Horon Tested-by: 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 e965ba51fb..e6e6a0d53d 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 May 30 20:11:55 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=1776802978; cv=none; d=zohomail.com; s=zohoarc; b=ElOy4wOwslwFfgkKnJBb1JBRnzfCMOcy4dQUXMIV5wDD295T4WU8JntEqs6M0krW1LDsNqoCVLmEnyC3VuFp6UykCpfXoen+AR/6hnfeH7pRW79M4snnpqKMxe64V5eQo/V8kTHzHOQIohIwcNwqAWEzo6W4NibkUdMPfHPwd94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802978; 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=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=; b=Tva/CzS6Mf0zZ1wDx47sGZIJ019Kvb2PVuSDwHfHjTDVlh9Aj1+1d8pMNM7pKK4G2CgkrMia0jVfCJTGnLixXp9cQSuiNlb5OPujUfBNGhJICHIPNnRPvizmb9tmWM0UCMOvTO07QzgxeNG/ZBuCGZJW/zh5MDSNwdleeG1C2Zg= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802978530482.147715823637; Tue, 21 Apr 2026 13:22:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbI-00010y-N4; Tue, 21 Apr 2026 16:21:40 -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 1wFHbB-0000xt-6h for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:33 -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 1wFHb9-0008Rb-DR for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:32 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-jexQ8lLwPkuCz7eSybJSuA-1; Tue, 21 Apr 2026 16:21:29 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8aca6f796d5so78637766d6.0 for ; Tue, 21 Apr 2026 13:21:29 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802890; 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=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=; b=KQ8DF3R/IEKf8XwXg+0n8Rm0QdN0nHfSb2VYnVOwBsn694pISZuSNYEcFeGd3N/rtZnRvB 9eL2FG29ZnHBlHU+onF1fzdTRDr2K+H8CfVje7PHnX+i7UmD0f0bn/TJ4m9mF5p0lBh1Sx aaRAPHkfFhURr5MaIQEj0BRstp2LVyk= X-MC-Unique: jexQ8lLwPkuCz7eSybJSuA-1 X-Mimecast-MFC-AGG-ID: jexQ8lLwPkuCz7eSybJSuA_1776802889 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802888; x=1777407688; 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=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=; b=nYLQ90EBhYSbSvUkcfq/KLtwRF8jBhalbwe8xgMXWPTIL66mwJ8HGehKIPWwJ8NkKE JxsvpSTOsp/b3esGCVDL60+gHOIJAnNytknNEaLREs0U7PeHxU3SVJb6CK3ur8Aovfp4 eWDIQJ/PxoJ40HAoio9CgyzMIMhwuuSRX5mX/apIkUGlD+E4KIUQhX6pjfz+j/JEMdbm rJxATpKcqkTnUXbgQ0gXII3yqp/CJagLYTYHiSwkgCme0m3TXyHQlq7zztDOqG/C5ub1 1bSS/KjXrfUodIPSuXFytOHPpBPn9vbI1Je0EuD5kK1N6fvi8RvqGN3hskJmTA5j0nnD /UyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802888; x=1777407688; 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=zyCQ0G6YIo2w22cNA+aGKrtBN8bxCdOvHJsgQDrXsUI=; b=MVN1wICCpsHlbaCEodk5B506m2DlZe4Yk23XXTGNtedIpl5dyKZxrZUdtzvNlCwi2f iSVh7cNvzveaB11zQbIbLSMcUfYbPFRwZao9Pe5LhbkSuDN2ncK2MKW3mm9H1w42XLFq KmakjSn9BjHJL4PNJ7bEX9pHqUbTPFGnyzQpWZW8c9u7eqnHpMAtOewHBSvdhPNUr3qX H0WaTRi0wHjo0xvW4f4SfNPD6w0moBo8w4VztE1p54PXmRhdhURV8xVAFypEJnhKUd0G RAqndTeQNZtd4slzOc40z5JztT4cSylI/t0cw+Go33/9KHFSfKOYuO/5bjfw3KOJHPBa EDUw== X-Gm-Message-State: AOJu0YwY9liU+dA9wvtcIHPKLzaPdYsJ/+ZDjlxbcJN+eTDWGQr7C/JP LYcmEzgUOgTjbT0U1BAox3EYizHHkBAGFA3pnRBE6C0etPxTEbHDB9Ry3RU4dve0AdofmbJDqCA pBZ6Qc+2KhL1i7PK/ASZtXDeZq0m6Jlh+7tiJc5paVAStFoknNmtg51A06LAVVS6xA2H6q/QdFV yIatpFZH6biAlHFcfoY6eBvPRM9AmH4oR/X2gKQw== X-Gm-Gg: AeBDiesksd/3oaoYPsHorLRU7SMcSdGPd6qjB12VPiLp8udBgoBw4iT+LK9WtjKAkpc MiwB2jmFOyFFU2pWo0ZPC4i2kvoyJU0qufhiqEn1SFs+m3sr1A9ScTMGWwfavfQUuAj7FJcbOvN B8uwo1nSwW9fHjbhDuBEzXQ6/EvxNZFNeqRijNhDxphXct9y7BAGoncDIR5n+62MbXZDszYKGgm W1Yc5J+GzyBBoauouHB4loaWfgnnODVCujc6FaQMDmWaef0a9cSvrZXa11Vz6r6WgAqv1e6zhNt YFFCV8bE/ZxhC+TxuUYxeQjvLiO5nYLbu8SH6bY7gNMwBESvCY+p585IrZgCHM/pGQKfC1dqycT quYosyFU/OXGxlRT9PVmO855ximiF84gBRECFg+e2rqR/vAr0DRS7/OkM3w== X-Received: by 2002:a05:6214:d47:b0:89c:8a0f:55a0 with SMTP id 6a1803df08f44-8b0280923demr315154236d6.16.1776802888418; Tue, 21 Apr 2026 13:21:28 -0700 (PDT) X-Received: by 2002:a05:6214:d47:b0:89c:8a0f:55a0 with SMTP id 6a1803df08f44-8b0280923demr315153596d6.16.1776802887829; Tue, 21 Apr 2026 13:21:27 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin , Hyman Huang , Prasad Pandit Subject: [PATCH v2 09/16] migration: Move iteration counter out of RAM Date: Tue, 21 Apr 2026 16:21:03 -0400 Message-ID: <20260421202110.306051-10-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802980211158501 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 4b54fda4d7..e3f82baaac 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 static bool postcopy_should_start(MigrationState *s, MigPendingData *pendi= ng) 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 May 30 20:11:55 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=1776802921; cv=none; d=zohomail.com; s=zohoarc; b=YIWZHLbK9HBjTRFY8GFzZE36L3po6HFWd+Q39c9Vc85bSePzoFn3Kt+9MIhXUYjc9R0Rz/rGXMlNpRHsK4OK9bHk1Ff6StEUwfba0nNxv2cNpStgK9fr9ZukZbXFSE/y9hjE9FUqwCRijDprBGHuPXk4/4ipoGlNHJFl96f8/KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802921; 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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=; b=JkD7v/di6MDoR7KsaK+GKdF6ceZ2NXHv71XV25BsPYpKfnub3rVJ0brJAwaaFcZ5JKKxujTy9FJFZ+qV8bu6uEersyWDWMx8jbr5ncx1GAAesKbfhlkyfl1P7IKYjSRxJUu6B/OA1Pw+v8wbfXvHdGH8FaIUEGZ2dv7sJXag/Ac= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802921118702.2983730986132; Tue, 21 Apr 2026 13:22:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbF-0000zK-6M; Tue, 21 Apr 2026 16:21:37 -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 1wFHbC-0000yW-Ui for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:35 -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 1wFHbB-0008S4-Bs for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:34 -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-297-oSm0CgqPMOWHfxh8k-Mx4w-1; Tue, 21 Apr 2026 16:21:31 -0400 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50edf0245b0so54171811cf.1 for ; Tue, 21 Apr 2026 13:21:31 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802892; 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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=; b=h6iok2/vP2KYlrKShfUcINuQX+jMQTk2Z9Ygm22ncSo/hnUxZ1PiLvSwbQl8XNXO3G6/jv k95QWOOVD1csZAQfPYo9ds4eA4TJA8YtAoZP4My865P3Eceu3DYAzKKxam6E1pdYk2kFcG 991p9mYTPRr+06PlX+joWAvSXYdrBhY= X-MC-Unique: oSm0CgqPMOWHfxh8k-Mx4w-1 X-Mimecast-MFC-AGG-ID: oSm0CgqPMOWHfxh8k-Mx4w_1776802891 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802890; x=1777407690; 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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=; b=kNofL9P3mc1ff3iR0ggIgFliJ8YDa6RERSkPQhJ1v6LyGLVEvzs+O1yER5X7A1wlk+ dSlO5pe9okSgIjC28rXRIebzv31JE4j67oJwvfwM646x+Sz9DWCmCZ1lX6JBSr6BfGfF yE3Pzr0tVeF59e6a5QbwEubATmnINJP0trvl2J7LA8mcAcx9vVVXExzPbyGFxjeO3NkD 6pnwLM8ht4ZbxZ9qiuLfl5tdUNmhO9J2oB8AqJNAacfBmVCU5o72bzTjApo9kwStY/X0 GP9JwbD5RBBqaTF5baaSuMYBcHfsPT6/E4eh30W3LbfLAV9LKhOsg76sj9Vav5q3Sps3 WFqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802890; x=1777407690; 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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=; b=kf/gfpf7HM4xtAxOaoD7IWLdfWX1gsnLQp798cr1h5qbImHDCleeCX6yFEF4HpPZFL WC5YUBoFrDPjKg6C3ajkFHRmn52Xav8uHPlbMmawWjsMoLv0QNo6uNJcsdDDBMOLANSQ UJ+TkYYaz2gg4puTJns0njBZc2zft9uhBq9F3g3Px9C5SjnDP7wdEI/RwZ4OnIvBRquV Ds30LO1ypYhMRLsVDQwhrKgsCAi35TMXuRdZG+jXlR1jVFL69n8IkfJx5Laiq8B+DiZY APam6fFiGZ8gzeH+hVLPGaN1Mz8EPl1PTVxEXrOp23lW6wvEjGRrBAAAS9Bt2MYI+s37 CrZg== X-Gm-Message-State: AOJu0YwvuAUIa4oGwvGvGa/YHiL9MDQhUGivhptWUIBz6V+WFGdALeeG 6hPZ/R5fQPcjPc/52/kNcZVRw79JJdb3ErNXDyF4zzRoC+kTIB9hGCnRWVKjVlp8kRAcbwZ42rK TRKHVkuRNy0uwdPqfYmaRvtZTxYWgcxFhnYgS1Wxc1JLt9ZiYIPdAR6yudkp17tw7ym2shAVPpN tHBZgjItKlnJPH3s2jkuTcRthWWjsXBj1OZi3+Bg== X-Gm-Gg: AeBDiesymm8nNgG2H4CjG9mtUeBhk67FdrB7/y2SJ+kizpKnxyJbF7kKT2qO0wrHr2Z UuGjjwxytLKhciOTwcCOo2TbIwq91ZNF9UbWPMmBPdPz2K94qFPx4XNaDizS9PyyfjSK964QWGg lT+VjivvzSFrDXed0Lgq2kp17YpApbmzSR6DBrx0lZldZYVPF8nfO8fLPSJYtpsVs9uBYOSj/Jj rloP2rsRUbUdj+V71NClb+AZE6ADLCjYTmQz7/Cf/+PfguJ25G4SoYA/CYJLz1FyKCrZy09YeaY kUZ2d2V4eSqLuXEW4EQyZ2gskJrwhUMqj7mZW9acmE7w1MAvn4PnGmQ2iUxqGneG7HfK1rldwll SBcaw/O+ySxzPa3lfz738SuWDgKGAaTG8RpIx8qkO995LH8TasqIsZUhiOQ== X-Received: by 2002:a05:622a:17c7:b0:50e:89e9:271c with SMTP id d75a77b69052e-50e89e92b67mr120918351cf.17.1776802890325; Tue, 21 Apr 2026 13:21:30 -0700 (PDT) X-Received: by 2002:a05:622a:17c7:b0:50e:89e9:271c with SMTP id d75a77b69052e-50e89e92b67mr120917561cf.17.1776802889606; Tue, 21 Apr 2026 13:21:29 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 10/16] migration: Introduce a helper to return switchover bw estimate Date: Tue, 21 Apr 2026 16:21:04 -0400 Message-ID: <20260421202110.306051-11-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1776802923928158500 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 e3f82baaac..caa1d13130 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 May 30 20:11:55 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=1776802938; cv=none; d=zohomail.com; s=zohoarc; b=dj/V02WkSRQUqQXDP46t5Vg2Hgd91PTP3uc7Q4gay/crYFCkQD2vSOiWPOdrfs+bzaeuGev2bN9+WEcvL7rSL2nEc7OD1uiJggC28yOReD5o6RHfxLAXu9N3S5mw/BTuV+YCLNN10HZSrjN427bV6ypCEsNaZ6DMz2k95E3A1tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802938; 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=0sY03HVswRoPMa35yJ23Zli6bfmgoUXGAl+akL2zYOk=; b=ZRO1SWEw6MLy/0EGdeu8wE8W3tv2q7p3A20biVY8KPpQg05Ktysll6jjD8+ycTAmnc3gjl36DCuZNd9hJ6BO7JL5BbQUhutPoeszx5bPAMhY2NiCebcMUA31ODZr4aj5c8lDA87EHz5gMNWOhr4fwPY2NC98+4Gb1NG6fdw3Jr0= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177680293828315.648101333269665; Tue, 21 Apr 2026 13:22:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbJ-000110-8g; Tue, 21 Apr 2026 16:21:41 -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 1wFHbD-0000ye-FZ for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:35 -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 1wFHbB-0008SG-VV for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:35 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-yV2umeW8PXSyO-bnNpiLtA-1; Tue, 21 Apr 2026 16:21:32 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8acaea1ffe7so122340746d6.2 for ; Tue, 21 Apr 2026 13:21:32 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802893; 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=0sY03HVswRoPMa35yJ23Zli6bfmgoUXGAl+akL2zYOk=; b=TRYleeQBxzLnxCWByB3ggMkdrrmeh+8DCnP7pKZ08tDIpEhqcAkOw4bOAtqEX8Xdi6p+mX NC6j7ewr30EIsFY9OjowMF9wqzXbkHo/q8+2BA0x+f8b1wfHIBSIP5iIt4r/4d2JIE+mDK 4h4VJE5azOFLkOZLT301/xdkFlSFkI0= X-MC-Unique: yV2umeW8PXSyO-bnNpiLtA-1 X-Mimecast-MFC-AGG-ID: yV2umeW8PXSyO-bnNpiLtA_1776802892 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802891; x=1777407691; 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=0sY03HVswRoPMa35yJ23Zli6bfmgoUXGAl+akL2zYOk=; b=eF9oV35ck3/9uFmrp4vUro3sD06Ba1kwQLf4t6WKS3HTug4QKc27inCKC6c8sPBW0h kWJZMBAXAUW+tG/1apBMR01hADeNbbCgURCup38Ra4tjpS9ip3LmBI7zE5eEflLPFDFi JJ0OGw3BT+cDSUub6Qk+rIDXiEpVeW3kkcki18yfB2auYex+QmjjoxIA1EApO4vn2pVX R/e0Tsf7uKeBIszUmxj0LITf38VE+SMVehSic4TLigApcpUPtXU4bjR+vdUsng1fE4sv c9M3JHVaeUZT34ILBbzzryRHsnSzswvlgwkTCstAEGyY/BSv80UX863678x+pluDBlHL W+Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802891; x=1777407691; 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=0sY03HVswRoPMa35yJ23Zli6bfmgoUXGAl+akL2zYOk=; b=KDsPKIH4mMsk8KG1IBFhzejILt1G3Cy/P3fCheBfKyFxXkj6bBNinojKFzb7/NSgi6 zPtN7f3MaLqKqli8GAliS8n/DljUOLRraJPd0S7jZT+7KFF7MS3URMp3Bp3o4tjS2M6G 7nV3W2ddXYMWIFK04mVDmNFClLzAuKRCoqBzbgDESSsfcGi3ejrKvA4r4iJ2ZtjnJjd9 ufh2AQQRs5iRJyAuR2w+V5WwGpNWQeSpAHy0BRrUC+n+Mg/rIRUc5uVdfh5/SPbfCVVa d0cqET7upJCz+85gylNtONbOtBE1++2DOnPreCpUc+BINRaRaZIlftWktK26wMzRYUaR 5yfw== X-Gm-Message-State: AOJu0Yw+SVrcFEHB5a+l9gA8W7e0/ajmJ+qDAkK2w/5MT+km5M+3juwY c73EU98509exDvTI74usQD3TANkngRwloCOdHUwdRvjvK8i8S+ofIBXAiqPcKKyO8Z+c9iQ8xiL kvFhjUiIUsqJZvddP6epy0FGjD812R/M0ASNzAK3afx5kll5udmxvQv3rVW/fjWdf+rgJUJ++ua jvIYEMCpKGvwRDWFCP5Bc4rQyg64pYKb1aoamq2g== X-Gm-Gg: AeBDieuJUrK4XjEACP3AYMGa6H7nf+c3T2BWaOdu4Yjw26navDs/n3guu2wIlbBu1v/ zIPIiZ3fpZPo1cJEG22qiOTvfexT0Fzj/pWflliLWqfW84l8TpSigZ14bjETF49cAIi6h3P+LcO JsWO9L9FIQnXVn5Qa/sjQLZ/XDIha4Tc54d+Ozc41K4fSvDsIkxkCe90V0z8XF+1NFv2Wmp/EQe dyLEnMtpVSQP/mxrCwIxgB9l18kA4w3UBYzrykMGP+8mBcz3HCDnhWCIF2j0mMZYGJCdfj3z24a xZXQ9JXcBcgZwrILehFll9+bzdfSHFPWM0yhbPbY5sDU0kArkGzB9fLv6jKcWR27wB35Px4sSj6 AZn5IEn9zsFringNN/fIOK5dhn6c18VE/t49Y1NUNkq93jP/WFN6k+TTmvA== X-Received: by 2002:a05:6214:451a:b0:8aa:a025:78e3 with SMTP id 6a1803df08f44-8b027fd1cc8mr339146546d6.6.1776802891291; Tue, 21 Apr 2026 13:21:31 -0700 (PDT) X-Received: by 2002:a05:6214:451a:b0:8aa:a025:78e3 with SMTP id 6a1803df08f44-8b027fd1cc8mr339145756d6.6.1776802890789; Tue, 21 Apr 2026 13:21:30 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 11/16] migration: Calculate expected downtime on demand Date: Tue, 21 Apr 2026 16:21:05 -0400 Message-ID: <20260421202110.306051-12-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802939848158500 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). Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu --- 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 b6888daced..ba0f9e0f9c 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 @@ -586,6 +585,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 caa1d13130..d4d3534cf1 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); @@ -3825,8 +3826,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 May 30 20:11:55 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=1776802936; cv=none; d=zohomail.com; s=zohoarc; b=CzTGEF7I/t6nQHB2TdoQtrHS4PTzqZ2tsCj21esnXWLEAToIppGuwu69FkOSRSqQxYwWLNs/1eb4pPqPHKzynb4hUen+YoLXaZS+ZEh8nOqdLGgwpJ2OsWZjxpKwT1Z7u3qlhW1CAKNpYrxGUx1OUI2ebADW1zVI76+blSdD8n8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802936; h=Content-Type: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=+iUFIFI91U4R0IIvcJAwRQAFhDDvnp8eZiPU+UOGonU=; b=c9tcte7guA3GFrQbHWCGZjW/CxUO16bLWsPFQLGOMuUm0i/Taxu5ZQqO3b9qwAVkeWUranmYbcwtR4BSr58xbB2t9k892G9SVjt92zCBtrAeoYRTmrMWIEwZp+X0YE8E/kmTJfm0lDgJEhH8At4aDTg/l1yT4q4mZ+Tv9jiF6rY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802936113444.5060890165246; Tue, 21 Apr 2026 13:22:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbJ-000111-Ci; Tue, 21 Apr 2026 16:21:41 -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 1wFHbG-0000zi-0I for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:38 -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 1wFHbE-0008Sh-0G for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:37 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-fBzbHEnEOW6g4QxErzBJww-1; Tue, 21 Apr 2026 16:21:34 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-8ac04b2fc4eso112819216d6.0 for ; Tue, 21 Apr 2026 13:21:34 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802895; 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=+iUFIFI91U4R0IIvcJAwRQAFhDDvnp8eZiPU+UOGonU=; b=f/E3Kv3dIiJJPHS/ZzcaTJ3mi/7bo8Ua+gTe5KU+HmJhs1ntNqcoKQj5SBQ8jxOqJz6VlU WinctXOthyF4jB3zp5+aqmWs3kxnBzalBz+ot/O2IEOqiAPzSQqJmE9eiRfo8IR30b2YP9 vsAOHFcPJqXHSNh5MHHGyZ1LSkswsYo= X-MC-Unique: fBzbHEnEOW6g4QxErzBJww-1 X-Mimecast-MFC-AGG-ID: fBzbHEnEOW6g4QxErzBJww_1776802893 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802893; x=1777407693; 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=+iUFIFI91U4R0IIvcJAwRQAFhDDvnp8eZiPU+UOGonU=; b=KctlUYtGW4Ed9ldJbsLvfP3MBYss83hNRN8Isk4A7b9AQXhGz2vnTb0W8gZHVTlvEF 4AeNlMTUMgSdd72HyOyNSNa8VbVllJjr6Y3Inmzi3BC+XnRtISw5G7ijKADecfw0QpDx bfy/TWpTVD9lmz5r+nCh7/LH18jg7htxoeDRLnr6NgmEpb98jr5JKpDumjiLmipqVI/a oL43BHnjRkBTuDbZYRSd9EqUheam8Wf8scO/pwbBtmabs88ILyr5xd69TSJXm5h2Z+HJ XVheXUuDCKLMWjSZpCUhrZAkAQjXbaHF02v/d/DNxszzF4tVoMdsECT1kwVXrc0e+JM8 FpVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802893; x=1777407693; 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=+iUFIFI91U4R0IIvcJAwRQAFhDDvnp8eZiPU+UOGonU=; b=kP4TvJP0x+e7bZY+DSKfNslS2mIMSeSkGPmgNmjQeetw3SQWYLd7+EHypJpI48F5j7 gDyhiFiuXnCFh9uiXRDZLyuRlKdGONhGvSyh2UL92O3fNUoxBjD3IMu1lpoyRRvaMmfb ZMu2VLEdiaHGzqJ5bKSDyRnZY1L5KdGWnzfVBbmmt9OTZ4DH84F6Jgr4WJsT6QPC9Ebe sVM2ygckkRmwpv+cxNckuzLjCuGxhg+Z+ED4GbRCiJywRd9M/7RZsi+zq8yHRQgtt2hd V+P9H9O5Vrf2ZUou53p6OXIPse+CrE4Ui5E1naiWdg+ab6iwuKWfJWxBwJ3Dr76Dh1h6 N5dQ== X-Gm-Message-State: AOJu0YxWuOi1g25WmhwGFOlLjDh8Hdl4XwDH2GnCSsxb8BNBqEFF8ZF4 LUlt1LB3sr9fU8pTARwSGICWs+dCwCle+rTKOZc6BsL5yJYSOb2D22YVLnpQI6Gd/Wu0umMQEdH mA2CKPh7hBP3uN89sCchboNV13CDj+pzHMUpu4g3wOqX4KW35aJiJ42Il4Ki7AN8p8T06SPo7V9 JkCtyZkCwTXViodyjKaQgmsKOuM3KeqNBkRx02Bw== X-Gm-Gg: AeBDieuhM255/n/Oth78spUBjXRjnQnymBhBQq+dNVUZvalRONRJGhSFgvr9KY7NUfq NDmSnRbuc6508z8WYJnktE1FfqzAaXcyMGxq4Ee0OlmM9HvjV26HXKN2SLRTOGE+gdAIi0RbYdE A2GDaJ+uGJbLtZsxURmg8sy7v3d6y8YqI+YWceNfuwZyPNJ+o9FH+jy2SNHQlYKD4uX+pwg8p1l 5vxAIm7zaUOtoagd5M0y2esQ55UZXGWw7KkBEnP25vuq7jIpC05Iesy9ImDI7P6kUpYz1kT+nNT RQU+c8HO78IPJ780l6lgIjdnHdrLSn9TKQY/YyCnR9lLkxKAA4lfoQF05q2NFMrFQu5cKwW0yV0 LzOj1rusv3/Ck6nHr44m9B0UILHqp/o6WIImqDaSOjsylose4NBPqyHXT9Q== X-Received: by 2002:a05:6214:260f:b0:89c:5e33:2cc5 with SMTP id 6a1803df08f44-8b02812918cmr327405566d6.20.1776802893125; Tue, 21 Apr 2026 13:21:33 -0700 (PDT) X-Received: by 2002:a05:6214:260f:b0:89c:5e33:2cc5 with SMTP id 6a1803df08f44-8b02812918cmr327404866d6.20.1776802892443; Tue, 21 Apr 2026 13:21:32 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 12/16] migration: Fix calculation of expected_downtime to take VFIO info Date: Tue, 21 Apr 2026 16:21:06 -0400 Message-ID: <20260421202110.306051-13-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802938884154100 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. Tested-by: C=C3=A9dric Le Goater Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu --- 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..1775b916df 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 latest + * system-wise synchronization of 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 d4d3534cf1..5d68591215 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 May 30 20:11:55 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=1776802954; cv=none; d=zohomail.com; s=zohoarc; b=LEwO+tzAzE14dmL7+0S4sSKOXLlN7SvdOYWIGw6geYGX06YT2lD2IgSzNPfJaptM1Rsv72woynciNe7tlRmKKE9/vakmDjFRq9KYUNYifHqg4Y0j27vLTnLumIyVqcOzwQPHKaV9iXJ5EWj5kus5jZyS2yAD7YdKIXRagfloj38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802954; 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=Af9JljxWi70ez3woHKeuds1zCU/ND/L9uxolesYJp+k=; b=lPdJa5GDYJ9KpOFMZeLeldNFpMOVxH9Zp8xlhJQTtmQwnq5RLU+jyow3Z52CB0vTPysPdiJUhQFLqj60tZo8tBAJFWd3YheRAlrfiE3q6kb/iP8F2c7wQPk0jOLKoT5O3M0dFOQSngrbNNSrOOaZ1Nzczg8QI3ArbiooP2jqpdY= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802954037574.6726336082583; Tue, 21 Apr 2026 13:22:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbJ-000112-MM; Tue, 21 Apr 2026 16:21:41 -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 1wFHbH-00010q-LB for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:39 -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 1wFHbF-0008Sv-St for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:39 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-uvcKwInBO4OJaqQGzsai3A-1; Tue, 21 Apr 2026 16:21:35 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8acdd800537so96006106d6.1 for ; Tue, 21 Apr 2026 13:21:35 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802897; 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=Af9JljxWi70ez3woHKeuds1zCU/ND/L9uxolesYJp+k=; b=XDXX8K8WY4l2YW45wcL2weFVrtwGBM9bXI+Mm85ZJRebOtmf4PQwqE20gi/oBbpSj2mHho xjGi4+Rlb+PDOphK5ITpwrZHS+1DK9HhOqOw3Il3xYqwwk7OBz8fLUEq+GinGZEeQz1MoF QAnqz35EQ/zFdzqd1ap+XukdbNujym4= X-MC-Unique: uvcKwInBO4OJaqQGzsai3A-1 X-Mimecast-MFC-AGG-ID: uvcKwInBO4OJaqQGzsai3A_1776802895 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802895; x=1777407695; 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=Af9JljxWi70ez3woHKeuds1zCU/ND/L9uxolesYJp+k=; b=Mbl90EQbQ00AU1rBmNPUn0xB2phP3VT1xj3CYHPpzUsUwK9q4teBzeCbd/ayjMgfqv ToWETRo8ozQL8z5Z1MKKXDrTozz54iqp3c0JeuRAEOI2/Yw8Tk4lberFcD3+I02tnWN3 E8CXn5s7bhBSCu4T2+5sTMDdut5Ren5CvUKEGRKK7q5K1LMXTS/9ifL/uYwbCxuX1Qn9 9J6NwLZTm3U/1VLdZdRQaA5nUdt/8erUCAky+RUVazglmJYwNa4Ezg114BrpA4KPOWYX 5WIadpnz13CarzJZuIeuFLfS1YNaCcwFid6piNbJslP0iZ/OKzMNbTp7y+5+z4TwhXJR jimg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802895; x=1777407695; 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=Af9JljxWi70ez3woHKeuds1zCU/ND/L9uxolesYJp+k=; b=EeVQINiu36gVZbvvG9jKjd2UuLgxDc8wLKOC1RnznmiUfCobLX1tAZD3i/hGHKCBFj h8bYMjnlzXFcDEXm43QU+9RRH6V4wlH/oa4gG9+X2BgozXlPKp7rI9+J109HleiHWJNr qAHau9a0K0xfh7MGk/VQsMXGyF+gqfo4NDPbb5ewehdlcfbJ6UIDB5kvvwQfFTCUP01I jp1xzUtD1hQQ7iA/xwDet2DCrmrpMWvcQBI+OlfXnnI5myq+DItkK4FCb2pKOUTNgda+ +600TWLnzAg7qhUbo9fiCcHF8oHMz+PzffSVPGWjzSW/2Cuxmr/hsD4mVgG1hbdj5UMT U6sw== X-Gm-Message-State: AOJu0YwKdhjSN0iP9MzNhZBW6mh1voGwxN0tgnu1+q9mi5KtcCNVF2WB GC2UOAhy0RlAJLT2RFQMtyvbHGKq8lCdqBM6Y6DRYe+7zOw+IX2dXopN32QrIjiSz/rG6ZdEXIn XsHpDDMbsMJlkrIHutwx9QLiWPLNEpoZQ2ExUOA9UDlMmbjsDDcLJKt0PjeV/XXccyDi2FLpgrt 2VpcMeKctKWerJPneiNkXTgf0HIoum1snLPobP4A== X-Gm-Gg: AeBDieuF0Kgz+DLeoMkfcMOBSJ7o9qYfDSWfwZIRLWhlucZeFhgj2tJ+Hl5XOuWHIF5 p5OGTQZ3q2GUyMY+1oDjhjCuVutl71nrX7U3Vz+p7GoOO+arqSnCOx6TxostDY4EJ/j+wuUMXKe p7CkKllTsiaNoWPLgQFj/WdIiX7SCFhcabcuhDfZR0iUn49T7c9k4N+zjxc2zI8TaEimx3eR0Sl NmqpgJSvzClcTLiq+bDpiZk039u9onv76OClfa1e23LYmF6FwuRBt1Tyqf5e9DRiEjtxM0+FzpO EzXx/A2HgMW1Rew/eD+DPgbSYgkg1+WaMjYvQtIbkg/vEMvCygNZ86L9fOQ02itW+IzNkxnynv7 VwJBT/y9zCV7y9wu0wAvOhSUdSM4j99hbiutJvqTtLHxOqp23l593dTP5WA== X-Received: by 2002:a05:6214:21e6:b0:8a1:88f7:d292 with SMTP id 6a1803df08f44-8b0280135dbmr332386396d6.13.1776802894725; Tue, 21 Apr 2026 13:21:34 -0700 (PDT) X-Received: by 2002:a05:6214:21e6:b0:8a1:88f7:d292 with SMTP id 6a1803df08f44-8b0280135dbmr332385816d6.13.1776802894193; Tue, 21 Apr 2026 13:21:34 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 13/16] migration: Remember total dirty bytes in mig_stats Date: Tue, 21 Apr 2026 16:21:07 -0400 Message-ID: <20260421202110.306051-14-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1776802956176158500 Content-Type: text/plain; charset="utf-8" Introduce this new counter to remember the total dirty bytes for the whole system. It will be used for query-migrate command to fetch system-wise remaining data. A prior attempt was made to not use this counter but query directly from all the modules in a QMP handler, but it exposed some complexity not only on migration state machine race conditions (where the query may be invoked anytime of the state machine), or on locking implications (where some of the query hooks may take BQL, which is illegal at least in a QMP handler). For more information, see: https://lore.kernel.org/r/aeZMtxqrKWAMKzdN@x1.local This oneliner will resolve everything, except that it is not as accurate. The hope is it is a worthwhile trade-off solution, after knowing above challenges. Now, there is one more reason we should make each invocation of save_live_iterate() to be lightweight, because this counter will only get updated once for each loop over all save_live_iterate() hooks when present. But that's always the goal. Signed-off-by: Peter Xu Reviewed-by: Juraj Marcin --- migration/migration-stats.h | 7 +++++++ migration/savevm.c | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/migration/migration-stats.h b/migration/migration-stats.h index 1775b916df..9f9a8eb9eb 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -36,6 +36,13 @@ typedef struct { * best-effort estimation on expected downtime. */ uint64_t dirty_bytes_last_sync; + /* + * Number of bytes that were reported dirty now. This is an estimate + * value and will be updated every time migration thread queries from + * modules in an iteration loop. It is used to provide best-effort + * estimation on total remaining data. + */ + uint64_t dirty_bytes_total; /* * Number of pages dirtied per second. */ diff --git a/migration/savevm.c b/migration/savevm.c index d221e2961b..b49a80f574 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1781,6 +1781,13 @@ void qemu_savevm_query_pending(MigPendingData *pendi= ng, bool exact) pending->total_bytes =3D pending->precopy_bytes + pending->stopcopy_bytes + pending->postcopy_bytes; =20 + /* + * Update system remaining dirty bytes whenever QEMU queries. It will + * make the value to be not as accurate, but should still be pretty + * close to reality when this got invoked frequently while iterating. + */ + mig_stats.dirty_bytes_total =3D pending->total_bytes; + trace_qemu_savevm_query_pending(exact, pending->precopy_bytes, pending->stopcopy_bytes, pending->postcopy_bytes, --=20 2.53.0 From nobody Sat May 30 20:11:55 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=1776802992; cv=none; d=zohomail.com; s=zohoarc; b=ZyARybmVM1L5MPyrWzKJ8tQmT5KwqbjUW7lDLUzwgOtvG4W0ZsIGxO3MxSm40XlLu5FRacJcpFmk9m/e7SkF0TwtC0l7aHFjJSKjbDtuIIRji+fe7KdO+YNJoY1WT1Gx5jgNWE0BIEFv9sAXphtNURDhNSm6oZeT3O7CEZNoBy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802992; 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=6X7sRtkFTct671p0HhVn2KGYiMkJ+R0TAaNfCYnI75E=; b=EW7SKOUrJjBW4wF4KFkwNh5JzJ85fyNVmL8wBy2fQak9rUuk75zwxyAFhbVOqtA/aP/2hLCk7euAgFkQdIm1Z+HCUNrMFyFw+sWd1/bhSOj1ovJXSR8DSgGCoPQK+zXqK7lJ6S3XeNgWSAdanEL3TwLTdtTrBSNQNiuWzvlKYOA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802992065301.0241608296866; Tue, 21 Apr 2026 13:23:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbT-0001At-Dw; Tue, 21 Apr 2026 16:21:51 -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 1wFHbK-000119-6A for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:42 -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 1wFHbI-0008TK-AH for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:41 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-FI7HZMVxONWS69-7DRJKHA-1; Tue, 21 Apr 2026 16:21:38 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-8acdd800537so96006526d6.1 for ; Tue, 21 Apr 2026 13:21:37 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802899; 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=6X7sRtkFTct671p0HhVn2KGYiMkJ+R0TAaNfCYnI75E=; b=d5I0eX0LTfKFCbsPjoYdThmAnpF8gOeMXQdm6meLJqqojtwEjnNr7I+lOz0Ex7F91GPhQ/ nK/x50FpQooZjJzxkD0LuQheUG8ZDN7iKkdlLsOtzY0jjTXIykElkJabB9ssXEbdPAK8oW c12gmosTj/CrnEbqsaB1RVctNlWtfOc= X-MC-Unique: FI7HZMVxONWS69-7DRJKHA-1 X-Mimecast-MFC-AGG-ID: FI7HZMVxONWS69-7DRJKHA_1776802897 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802897; x=1777407697; 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=6X7sRtkFTct671p0HhVn2KGYiMkJ+R0TAaNfCYnI75E=; b=iHeF0YMqF8yBcB/orwIE14EfXTl3KCc19SSNi0YAh8gPKqu98JpJO+RmULw+t7HpFI eMw2UQkUmEweKa/yyDq5r57xgMdAwrofr0EKVs9kc7FRXN++RBkBKNJ7bijWqo3kSfWw Woa7w9uoAntDAGD+Es44wFe2e4XSRM/pCdJS9Vlj3pGroJYszOEwuGfPf4xgHpQ8SPqF mpHuFsy/n6Sqk6VCpv3KMVMPHZHTa0KASolAKqP8vcp2EUEPNTyH9xRgVTa5uFRG9N4P H2P9oztqPCkXLkUtP7ZPTtkL8gIqjGWp12Gh1nUtcXl/wzJZj8R1K+FBNatHK5Ai8GLb 9sWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802897; x=1777407697; 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=6X7sRtkFTct671p0HhVn2KGYiMkJ+R0TAaNfCYnI75E=; b=LovB7Q1BZtyTjyrn4L3QUM5jbI2HqVWcG4hY7SpAmZN8N17ETDVhVLBJlmngJCdZKg 6SIEICkgAngo08sMsgj+TvFO2rLAgJ1oez/qg+kRdo55FB2kicsJEdFwf2dIjpz6G5dT hG3OSzyBoihccZDzsJJadXlaoeHLjDD1sY5pF04+s5IBaXm9fEKTwxTRN4hem4ebuVie vYH8ccZsnMgYlpT/TpO3AIeD4kkHPk+qoyxtODP/BrIdFfoQYfeAvKoMEC9WEIh/H8EI Bm+zQmiEUqOq5OigGB8U/jj/Zl4v2/Ki+y4KTEaYlXifbmiJbAZlb8w4IrPpsvpAGlL6 55IA== X-Gm-Message-State: AOJu0YxkchpjIv7iV9pBB/LB1NCQw6ZYfd7AU7LHtXr5nP+oc7vjyk+o VqSH40DBdMrH/fZcExgYAOyVj6Vf5TE3sLBKzcc3S2EFaIaJjAmNNEVMc2cIf4txDZVLSXv6Epm eUn3UWqJVnHFdET3TwN1CmvnRpAGid+aJQKssifw4JEdZeuFvCJxlj+SqT59aIN8qvDnesEyhn8 Dd2nPPDTCTMJKSiLGO/utNTxOdNXOTI1XBJv0P0w== X-Gm-Gg: AeBDietR6bjGKmCFqb7DcTVxbMH+mm4AcAkoODT+hrhvfbFwHtRXozo6fHOZv/lKvO/ 1ikpdYaFbcVbPYXLDqbhK2PpG7rQLY5vRV1KDYknVhIaFfVVJMXYMzm3fV4ISi4ztHCKYoWLqEa Xt97xeVdihW4PTRuW8CwHyiHiihk5CriCH3J13VmVUnf4vQcNT+xW0Z4Wo17ygatcUdMeozGKOt kG23jfl8G6Aj2f4inB9cQCFGCwQDSeDwnRJu3BJOwIdx82MhBcKj2f1Lpheu0SltQX3T5ruykG8 a6MFTedDf9nbLjA3mUJezRk1e3eGv6xKHECf5906b9ztWwPTuka3rI20+1Iqrjna2MbI6+MP9l/ WohiBWciAWi0xM6EQjnXu3oMS66TW8I77HxOULu9e6kMCaIV032M7EbyKyg== X-Received: by 2002:a05:6214:f25:b0:8ac:a6c5:c7d1 with SMTP id 6a1803df08f44-8b027fd26a4mr319397866d6.8.1776802896536; Tue, 21 Apr 2026 13:21:36 -0700 (PDT) X-Received: by 2002:a05:6214:f25:b0:8ac:a6c5:c7d1 with SMTP id 6a1803df08f44-8b027fd26a4mr319397056d6.8.1776802895949; Tue, 21 Apr 2026 13:21:35 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin , "Dr. David Alan Gilbert" Subject: [PATCH v2 14/16] migration/qapi: Introduce system-wise "remaining" reports Date: Tue, 21 Apr 2026 16:21:08 -0400 Message-ID: <20260421202110.306051-15-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802994060158500 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: 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 Reviewed-by: Juraj Marcin Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Acked-by: Markus Armbruster --- qapi/migration.json | 4 ++++ migration/migration-hmp-cmds.c | 5 +++++ migration/migration.c | 7 +++++++ 3 files changed, 16 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..a3887cc0d7 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: \t\t%s\n", remaining); + } + if (info->has_socket_address) { SocketAddressList *addr; =20 diff --git a/migration/migration.c b/migration/migration.c index 5d68591215..6fd89995a2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1076,6 +1076,12 @@ static void populate_time_info(MigrationInfo *info, = MigrationState *s) } } =20 +static void populate_global_info(MigrationInfo *info, MigrationState *s) +{ + info->has_remaining =3D true; + info->remaining =3D qatomic_read(&mig_stats.dirty_bytes_total); +} + static void populate_ram_info(MigrationInfo *info, MigrationState *s) { size_t page_size =3D qemu_target_page_size(); @@ -1177,6 +1183,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 May 30 20:11:55 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=1776802952; cv=none; d=zohomail.com; s=zohoarc; b=Xq+ExaxcGZ7rnsooUKKNf3zMHTq+1tPzYUk5e+g4F4Fg3iEzpqHFFcIoUTRGtwWele/D+Tk1jVVYjlwYhigoT+Z1mE3gXCFI4C8lt+J8t0UlhHrMwiD2KPg0OfvrOH05lRa8qG+rMeijVHBeQo7v1LNlQPXaqkmJkPouCgYx4Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802952; 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=2hINx3Pl7mMgpNmHdkNkzZeehT6CitLSjSALu0u8E0o=; b=We03qAA3DMs4F5T7KUU2fqqUymSih4SsAan7Nnf0O6dWazGF9QJrqF32O8UFaBhJhfOu3+5CaScMhJPzD3X92ZAa2r5pASKG5Yn+j5B2ZLK1TobXen9lueLXEY7qWxmmR0J4W6kVVrWDncCpRjbQ65YV/QzhkSHWzhqS0eXDMD4= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802952780664.2487887411446; Tue, 21 Apr 2026 13:22:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbN-00015k-TK; Tue, 21 Apr 2026 16:21:45 -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 1wFHbK-00011X-Lq for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:43 -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 1wFHbJ-0008Th-41 for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:42 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-eGE0dn9OM_KWDoy7HoIH5A-1; Tue, 21 Apr 2026 16:21:39 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8a5f6110c1cso116742626d6.0 for ; Tue, 21 Apr 2026 13:21:39 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802900; 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=2hINx3Pl7mMgpNmHdkNkzZeehT6CitLSjSALu0u8E0o=; b=YQ/gljPaOVKyh4ZTwkDhWm+Zo+uv0fTpp4WAUBey6QybkUX6LQAiG14a725dRcB4PMNDxR RD2brSD7lYzT2gbNpcEmYLK8Bk4dWXNHo4cLwc2bRW2LIVtw8Vfaa7pwrurjNaJS1U/AgR sd0hLbR6L48B2T+Et88+ySyu3/XIXXY= X-MC-Unique: eGE0dn9OM_KWDoy7HoIH5A-1 X-Mimecast-MFC-AGG-ID: eGE0dn9OM_KWDoy7HoIH5A_1776802898 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802898; x=1777407698; 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=2hINx3Pl7mMgpNmHdkNkzZeehT6CitLSjSALu0u8E0o=; b=oeH/eo+AOSrF61qPlJ166uWV6huSsNw5pdYkNetwhJdK+IY54hjwoMEGro9nI0BZKo My2n03XsvqiSFua7HcTxw1k02DkxPtEGJJMJ7RomJwPYau32Bv3PGNsikTksSXHyzbY/ 9VjGBEmocD3g/Nn9V+uqj4KsaE2daH/TWaHCQqQ+4qH5vgkc6xdirp0z4zEneNidJzbQ Ix7cXgkqQq4+mzZlP6bMroMLZBb//Hg+QejI6RXrbEqkLpKNe67r3iD/ZcGwaRtY1Kjj COFVagJzgoq3O+aa9NywkHhzN2h3dh1eW6BK7jBfSLqUT37jWC7tqztpeU2BwDfqSRcI 2OzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802898; x=1777407698; 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=2hINx3Pl7mMgpNmHdkNkzZeehT6CitLSjSALu0u8E0o=; b=ftVO28XHYOWfHqS9EksW5XUedYzqcaTCVf+1k25TCeZ6i/Q1ovRZChhahT7tofIdW9 JdCAYZHnd/K0jM0aH5Pj6RxFt3J8kJcpSke/RTJjbeo4nLeLaiTHTNkjnPZlDw6zivCf AhoqV+QjLu4RAmtYvmKOItX1+3zfd5p9LnfSG1F9TnRdItnI/1ORyCeuJsLAI6c6p26x 7f48HPIy5aIBOx9B8YsY5Q0gKnct//1VwA2zIqhJKqmRqG+wA7ytPeSsx1YO15rLbuVV D0HXH2P/3kpINSUFOFOk8RcDZwuNjzqJJzJY6iWmLepaMsK1zGnmHisGQsuOO4YiO94y z9Fg== X-Gm-Message-State: AOJu0YyDRLsD4yxgY5IDpgD2Bhv6VAWPU5uX76+2Z0FLjCyVN9b2htNQ vw5QV9W7C0mGVYOl5xqznbuK9Tw/Ihn60cYURA5sk8viKqMDHMaJ1Vy5o1cru1561QGOHedYvvW G8VcqrzoDE+jaPc/6MA/PlgY6PcSpTbOxUonzPEfEM6po0d1VkjkEA5x238II5uAbIjNRIK8k22 PNLfm5yDUETnNdd1BikqWasqRoQN+oSW8zhVmJuA== X-Gm-Gg: AeBDieuyDpQWXydlWXJvXnXo/9/VzjIGt6ve6/KB/OxSx48+C666kTxLjXtDhVGsvw/ KWYlgJs1d+C1y1xAbmRAL1bBcjyL8xaPzdVUAwsfW77RETgXad18jQwMJobmSwm9vaZcIlvLCSp CJitrIzy3dO9CeazAXSTkpE0fy2a7D746CPgiIxkqnj9Tp4QRTuwjN2UU4jcEoiY/BTGIvQXQbm 5m6RJx5wa6/64jux5/24w7MzuqfTpeOUNKL0lvk5ua9WjeuDZreIYKmWXW3Eh70LWWhRSh8W9yt dASsrGbza4691ljLD3VWo8+82gl8ce/HTuNATKO/HUk8PJMlNh/AxtdlZQjw5kw8KXjFvo/X2Ei cywsqarvUdyQBqxBjgx7F/KUTtG92ir7KI9ssul73UGq9V4op3Oi7sd6/Yg== X-Received: by 2002:a05:6214:4588:b0:8ac:a154:e156 with SMTP id 6a1803df08f44-8b0280cc08cmr327337456d6.29.1776802898141; Tue, 21 Apr 2026 13:21:38 -0700 (PDT) X-Received: by 2002:a05:6214:4588:b0:8ac:a154:e156 with SMTP id 6a1803df08f44-8b0280cc08cmr327336806d6.29.1776802897575; Tue, 21 Apr 2026 13:21:37 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 15/16] migration/qapi: Update unit for avail-switchover-bandwidth Date: Tue, 21 Apr 2026 16:21:09 -0400 Message-ID: <20260421202110.306051-16-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1776802955037154100 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 Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Acked-by: Markus Armbruster --- 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 From nobody Sat May 30 20:11:55 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=1776802990; cv=none; d=zohomail.com; s=zohoarc; b=d2Ih0BR4ZEthvlWFE7k/KJoKFxuSq5VS66N0S9KTH5ygHbBtCV0mqqv9kvEe62TEAgipmxOaN/QryY8wZN6n0mo2EnGMYXISI0t84XFj3o2T8jmZvxKCNkQX1XGGUnwEAPpW3q61hUtsBx3JXAO6VOoqV6f90Qw09FFQIS5kEd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776802990; 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=Z3YojhZNR/NVuUisrNqEPFb2MauGl3eXRbOu4+fMvCA=; b=lQeAfNZ1IQ+5Xe7dDzNLrX03QncdUmIwI3e214xgQSBU78SZzhXCA6YQSMN+LjR1IAfgIMoOt17XyzD4vDU9n+uBWRJhcqRcZMLSt9ZaHH51HxDVKUHjkheO7Ebw/SNWmZp7rS51wD9+ihSHcQKow+RRACFftgeNSbnHQFAJlhA= 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 lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1776802990358502.44363853295977; Tue, 21 Apr 2026 13:23:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wFHbO-00017p-Mk; Tue, 21 Apr 2026 16:21:48 -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 1wFHbM-00014U-UT for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:44 -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 1wFHbL-0008UI-9i for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:44 -0400 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-172--xusRwE7Nxa80_PQyywIMw-1; Tue, 21 Apr 2026 16:21:41 -0400 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-8ee454b1b8cso144981785a.0 for ; Tue, 21 Apr 2026 13:21:41 -0700 (PDT) Received: from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 13:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776802902; 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=Z3YojhZNR/NVuUisrNqEPFb2MauGl3eXRbOu4+fMvCA=; b=GH4ibqgRV0Rnunv3B+P7DzgP4cu+xh3cgCRVLxwGoLI2sfinNQfzT5xB2CrtehMqcJQhFh 5zHuxKGcJ2ehykMDQnIFuAsZPHiYQVd7ZyZewT9FRT62m9l5tWna/JYF2LyP0bN6Pq5DvR i5qCgGwDJ5nauB5ZwAcVDpdYdYFHVqs= X-MC-Unique: -xusRwE7Nxa80_PQyywIMw-1 X-Mimecast-MFC-AGG-ID: -xusRwE7Nxa80_PQyywIMw_1776802901 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776802900; x=1777407700; 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=Z3YojhZNR/NVuUisrNqEPFb2MauGl3eXRbOu4+fMvCA=; b=A64XHWaXUKUk0+6SoxhymE8ri9Jcd3Bf2kWaTrSPjubEx/qHjrgnCkTUnP/pu/7/F/ o+2Df4e0UIOIhuoDleYgEP3IT7B4fMkTD9PNzxh5iI+vtEK1ZR87qz2vU8T+7Voc3RNf /Xbr9f+RY1RCyDAz6VlLRnXKo+I6v3DRQjXoaCz1OhTv2c4i7luCIIhWHBqGqPpOe7lB frDT7TdP5S7KMEo3MC0D+1t/K8Twupr37e7jLOefnfV9oxizZEaOuI6NW9aYnixnMFab i86w+ndoX9JHGn0i2104wp0skVn9Y+gBi3BVY/9O0hz3BEHooUl0wfdw2FFgMTQKHkOg kt9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776802900; x=1777407700; 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=Z3YojhZNR/NVuUisrNqEPFb2MauGl3eXRbOu4+fMvCA=; b=YdexGFJaedQM9y+Uk0J0lnRpz985a5RhXfeHvNi0PE0MWtKrrwUQQ71UybhZuKHv8Y S7xfd5g6o88GaHje4Kow+7CEkcTLAM/AAnEmZp3KwzrmC/Op+VNswPZ/ZN547miH/5i8 ccL8vxgtomRgwmj9i1M8u19eR+5+w25+iN2Rf9I4nkUAAVixTiBmz0L+eCZmIDAlHM1F FW4nciG1yGaIxRn0iCwrr8cRhEt8LfqwnUxZF+xdbvtMJSYn7LvG/3ywF/O1JZ0ks7jT 1Ok19QzVkXR3Tqi0eRHdKef7PVi0wvum2P6rQfYtf/ujbwBYI/rDxUb+NN9UVGvp42QZ /3Kg== X-Gm-Message-State: AOJu0Yxdxb2r7iq8jvC2HxbJUg6bnFgwKwZQS0NT62JznQHrSegJ1puJ iAlecBiYhVsyxi/b3MeNyt0A0tzGkvTUntZ68Rz8lSLTHhCtF5FJaVNIxm7BrZWZDlmreProC6J ss+vX0OaGEodX/w2DiXI1iWG9nhSYJ2vC5/Jt70ehRtOr7txefGXe15xd5YIPZuZ8UHdd62xFAs k5xVar8667fCN8zODBqUtMjcIeGaKazKBIGnmpvA== X-Gm-Gg: AeBDietK2Lvmmr98i7YtnqCgKzzeE1vMfSj9NjloY/K4MvGovuh69EjphsAbylh5mpz fVKPZjGuXvwBounDtqjTc9A9P6P2wfbmZJM1YGNeyXnRM2UGSyT0Nip09RqoXodYIpfEBO9hQgf 3BYRIPASeD5Z9s3U25F+11zfcbc9ck5GXtymxYGwpdajSNr8yy1ov+rnaC1CkE8D1iIfFkXWsgS qvp7kSq/QAtF1GDDgbLQl24ZP71Bqbc6QLc2KSOZFf7KnsESVO9iJOMt+EPGosuWG/FiekxwDsi M+tjSOieHN+FjeXm9zZjCk6mH1KfboZ3+RVQINLXGyMGHeq7Pkm7ZpWy8kvy+4l3RDMSJ0QAy5E 1yJmQE8Rv6MePIyrKiZWUiEEfqnK/gvTPmyOaC4Q9bI/XOk4cZiMGnna3Rw== X-Received: by 2002:a05:6214:4345:b0:8ac:adbe:fc8d with SMTP id 6a1803df08f44-8b028015007mr303162626d6.8.1776802900470; Tue, 21 Apr 2026 13:21:40 -0700 (PDT) X-Received: by 2002:a05:6214:4345:b0:8ac:adbe:fc8d with SMTP id 6a1803df08f44-8b028015007mr303161776d6.8.1776802899631; Tue, 21 Apr 2026 13:21:39 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Joao Martins , Markus Armbruster , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Avihai Horon , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Fabiano Rosas , Prasad Pandit , Alex Williamson , Kirti Wankhede , Zhiyi Guo , Peter Xu , "Maciej S . Szmigiero" , Juraj Marcin Subject: [PATCH v2 16/16] vfio/migration: Add tracepoints for precopy/stopcopy query ioctls Date: Tue, 21 Apr 2026 16:21:10 -0400 Message-ID: <20260421202110.306051-17-peterx@redhat.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260421202110.306051-1-peterx@redhat.com> References: <20260421202110.306051-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=lists1p.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1776802991608154100 Content-Type: text/plain; charset="utf-8" Add two tracepoints for both precopy and stopcopy query ioctls. When at it, add one warn_report_once() for each of them when it fails. Signed-off-by: Peter Xu Reviewed-by: Avihai Horon Reviewed-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater --- hw/vfio/migration.c | 33 +++++++++++++++++++++++---------- hw/vfio/trace-events | 2 ++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index e6e6a0d53d..04d9f94edb 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -329,6 +329,7 @@ static int vfio_query_stop_copy_size(VFIODevice *vbased= ev) 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; + int ret; =20 feature->argsz =3D sizeof(buf); feature->flags =3D @@ -340,12 +341,18 @@ static int vfio_query_stop_copy_size(VFIODevice *vbas= edev) * is reported so downtime limit won't be violated. */ migration->stopcopy_size =3D VFIO_MIG_STOP_COPY_SIZE; - return -errno; + ret =3D -errno; + warn_report_once("VFIO device %s ioctl(VFIO_DEVICE_FEATURE) on " + "VFIO_DEVICE_FEATURE_MIG_DATA_SIZE failed (%d)", + vbasedev->name, ret); + } else { + migration->stopcopy_size =3D mig_data_size->stop_copy_length; + ret =3D 0; } =20 - migration->stopcopy_size =3D mig_data_size->stop_copy_length; + trace_vfio_query_stop_copy_size(migration->stopcopy_size, ret); =20 - return 0; + return ret; } =20 static int vfio_query_precopy_size(VFIOMigration *migration) @@ -353,18 +360,24 @@ static int vfio_query_precopy_size(VFIOMigration *mig= ration) struct vfio_precopy_info precopy =3D { .argsz =3D sizeof(precopy), }; - - migration->precopy_init_size =3D 0; - migration->precopy_dirty_size =3D 0; + int ret; =20 if (ioctl(migration->data_fd, VFIO_MIG_GET_PRECOPY_INFO, &precopy)) { - return -errno; + migration->precopy_init_size =3D 0; + migration->precopy_dirty_size =3D 0; + ret =3D -errno; + warn_report_once("VFIO device %s ioctl(VFIO_MIG_GET_PRECOPY_INFO) " + "failed (%d)", migration->vbasedev->name, ret); + } else { + migration->precopy_init_size =3D precopy.initial_bytes; + migration->precopy_dirty_size =3D precopy.dirty_bytes; + ret =3D 0; } =20 - migration->precopy_init_size =3D precopy.initial_bytes; - migration->precopy_dirty_size =3D precopy.dirty_bytes; + trace_vfio_query_precopy_size(migration->precopy_init_size, + migration->precopy_dirty_size, ret); =20 - return 0; + return ret; } =20 /* Returns the size of saved data on success and -errno on error */ diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 287df0b8cb..854a7e4b19 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -176,6 +176,8 @@ vfio_save_setup(const char *name, uint64_t data_buffer_= size) " (%s) data buffer vfio_state_pending(const char *name, uint64_t stopcopy_size, uint64_t prec= opy_init_size, uint64_t precopy_dirty_size, bool exact) " (%s) stopcopy siz= e %"PRIu64" precopy initial size %"PRIu64" precopy dirty size %"PRIu64 " ex= act %d" 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" +vfio_query_stop_copy_size(uint64_t size, int ret) "stopcopy size %"PRIu64"= ret %d" +vfio_query_precopy_size(uint64_t init_size, uint64_t dirty_size, int ret) = "init %"PRIu64" dirty %"PRIu64" ret %d" =20 #iommufd.c =20 --=20 2.53.0