{"id":2221160,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2221160/?format=json","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.0/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260408165559.157108-8-peterx@redhat.com>","date":"2026-04-08T16:55:51","name":"[07/14] vfio/migration: Fix incorrect reporting for VFIO pending data","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"40586eafb38817f842cd0277b3ded3d12f308284","submitter":{"id":67717,"url":"http://patchwork.ozlabs.org/api/1.0/people/67717/?format=json","name":"Peter Xu","email":"peterx@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408165559.157108-8-peterx@redhat.com/mbox/","series":[{"id":499176,"url":"http://patchwork.ozlabs.org/api/1.0/series/499176/?format=json","date":"2026-04-08T16:55:55","name":"migration/vfio: Fix a few issues on API misuse or statistic reports","version":1,"mbox":"http://patchwork.ozlabs.org/series/499176/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221160/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=J1uRNKP2;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=Pa5mFaiE;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frY8q1l7Mz1xv0\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:31:39 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wAYT1-0006Ki-FO; Wed, 08 Apr 2026 15:21:35 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1wAY3x-0006DI-1z\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:55:41 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <peterx@redhat.com>) id 1wAWCO-00028m-10\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:17 -0400","from mail-qt1-f200.google.com (mail-qt1-f200.google.com\n [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-364-dXVsTwTdNWKNF-JbTlEzdw-1; Wed, 08 Apr 2026 12:56:14 -0400","by mail-qt1-f200.google.com with SMTP id\n d75a77b69052e-50b31cff27fso996151cf.3\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 09:56:13 -0700 (PDT)","from x1.com ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n d75a77b69052e-50d712c2617sm130491901cf.31.2026.04.08.09.56.10\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 08 Apr 2026 09:56:11 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775667375;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=;\n b=J1uRNKP2ox37xyMjv2mMxewoFLmpwYSSxI41bNf7OlVMPuN9w1bFutS7KjgyKWYazGrXLs\n h7mk8xC6BNZjeEWv3rlUPHIhIj9Jj50aBPHkazyXLdZ4dRsiu5nzLJCq4yseKn6+jhjdQR\n 5l0qs8SktWpzf2YqaVwf/G0iAnu7tV0=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775667372; x=1776272172; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=;\n b=Pa5mFaiEcJUkhajtukqU36QUOsB8NfJKx5t8d2SHOTacWimWC0bRUphCosbP0QfqTA\n tUSWBA3yqbcOnp1FMuUJhalAQ8bLo1XhEHChSkWHqD/iDmBZFcMgNa7HcoVy2Z9EbY5G\n 3HOs6Rl9XLb5ByRfmaWbazDMpvrUClwl8uXlASX3Dmb4zfq4y61+505HUG672OpRmIYG\n kLhgtNwsNFcN/SStNCUoMszciHvqEq7m2tS3otA60b63ledkSTt9vUbywDd+Fx4RExBq\n z26+yqwJGUTqpaTihVvPJHJtJ4PApGPCZdSvHLRwxZ1GMfNXiH8AVDs31b4OSla29uBX\n 6JXQ=="],"X-MC-Unique":"dXVsTwTdNWKNF-JbTlEzdw-1","X-Mimecast-MFC-AGG-ID":"dXVsTwTdNWKNF-JbTlEzdw_1775667373","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775667372; x=1776272172;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=JNWsc1Vb2/FFVZ+FiEtlLRVcdly+39Jh6AgLzzLmjt4=;\n b=FO0gvPdcZmN6NqKmcq8cGqHKSpgJPROxYhoesVHdSHlK9lpfKqlgTenAbkmNwGr2cP\n O82IyE4vxBGRb5fGAwsriEqq2KboE0FaZqW+ZkB83WPkWKPhQLU7kWln/ijr0M6LMLaP\n TP/q7XDfDbef8lRgDrwKUv3Ofnxw8xQDo9EEs6UOAAUJc2aj0As8FXV9XnjGqv/ZD1S1\n 5YcfayyLkjlw6KxoE7Ulu7Iag+iIM3YExB86VmdX+zLNZNj+igee1nrBK1kM7vzbDlly\n HSyq4gEv+Vxm+a0N78GjCmv6ZFFmG/sSL15pn7V7RBfELYLztDlhaLbMFClUoGFX944/\n aoPg==","X-Gm-Message-State":"AOJu0YwJtUfjHI++PRHhqqHJRRn+PbXbQBudrNHf4t0X8zxZVb9zUFSM\n f+G8OoyKV/U7th9OPYbtduKoBbmogfFqYIeakjnuqg7R1I2XVWN69QHAeZiLrdXggY4ixPdAFkq\n 7NBZorQPzhtHS89l1xT5SIeuaQyWsxrWJXzvg1eUsbr8mtc91kNDFIGfRLsrqAcrlC20QaLy5JJ\n /PzpRQwZUFDrwLBYGGBOuxfbFqNohq5QuBkfoTqg==","X-Gm-Gg":"AeBDiesL9ThOjRAKZTQPrg0eQmhA6vNL72kSrO76+thJe2HDcrfj4sg/myBakjqZ3r6\n PGY3LY97Tz6ScEKWadrh6ptkICyNM8sSLkRL1dyNDcEGD6Lj8zkU1oItfvmYZ9HrXc1SDX1DM2x\n W+ZKgoGvXuE474Esew+Z1NCspOh/aWKlOZYdx8ZYpL4sbJbcRANIa2S9vO7RrRYeCWNiMkPGoZZ\n O+AYk1J2vUlSUw1Q5+y89/+ddI/DkftSPyWIQz6zr3u9HX6ptuFn5iu9P8V8LrE0MDfpDl66b1F\n YV2F5SyI1udSYpTV5CCxYrf8pRHrHa+UmkxQbt8UNsEThCzt2x6veVkQYQgh6ulug1dTXwDCoKT\n p8UIVEpusJWBgSzOJPCRkeucvEZuv7LFuYcid+a5MSkl0","X-Received":["by 2002:a05:622a:4cc8:b0:50b:37a6:4f0a with SMTP id\n d75a77b69052e-50d62b7b3c3mr324406131cf.57.1775667372452;\n Wed, 08 Apr 2026 09:56:12 -0700 (PDT)","by 2002:a05:622a:4cc8:b0:50b:37a6:4f0a with SMTP id\n d75a77b69052e-50d62b7b3c3mr324405301cf.57.1775667371693;\n Wed, 08 Apr 2026 09:56:11 -0700 (PDT)"],"From":"Peter Xu <peterx@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"\"Maciej S . Szmigiero\" <mail@maciej.szmigiero.name>, =?utf-8?q?Daniel_P_?=\n\t=?utf-8?q?=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Zhiyi Guo <zhguo@redhat.com>, Juraj Marcin <jmarcin@redhat.com>,\n Peter Xu <peterx@redhat.com>, Prasad Pandit <ppandit@redhat.com>,\n Avihai Horon <avihaih@nvidia.com>, Kirti Wankhede <kwankhede@nvidia.com>,\n\t=?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>,\n Fabiano Rosas <farosas@suse.de>, Joao Martins <joao.m.martins@oracle.com>,\n Markus Armbruster <armbru@redhat.com>, Alex Williamson <alex@shazbot.org>","Subject":"[PATCH 07/14] vfio/migration: Fix incorrect reporting for VFIO\n pending data","Date":"Wed,  8 Apr 2026 12:55:51 -0400","Message-ID":"<20260408165559.157108-8-peterx@redhat.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260408165559.157108-1-peterx@redhat.com>","References":"<20260408165559.157108-1-peterx@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124; envelope-from=peterx@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-25","X-Spam_score":"-2.6","X-Spam_bar":"--","X-Spam_report":"(-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"VFIO reports different things in its fast/slow version of query pending\nresults.  It was because it wants to make sure precopy data can reach 0,\nwhich is needed to make sure sync queries will happen periodically over\ntime.\n\nNow with stopcopy size reporting facility it doesn't need this hack\nanymore.  Fix this by reporting the same values in fast/slow versions of\nquery pending request, except that the slow version will do a slow sync\nwith the hardwares.\n\nWhen at it, removing the special casing for vfio_device_state_is_precopy()\nwhich may reporting nothing in a fast query.  Then ther reporting will be\nconsistent to VFIO devices that do not support precopy phase.\n\nCopy stable might be too much; just skip it and skip the Fixes.\n\nCc: Avihai Horon <avihaih@nvidia.com>\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n hw/vfio/migration.c | 18 +++++++++++-------\n 1 file changed, 11 insertions(+), 7 deletions(-)","diff":"diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c\nindex 1e999f0040..57e88c9dcf 100644\n--- a/hw/vfio/migration.c\n+++ b/hw/vfio/migration.c\n@@ -587,19 +587,23 @@ static void vfio_state_pending(void *opaque, MigPendingData *pending,\n {\n     VFIODevice *vbasedev = opaque;\n     VFIOMigration *migration = vbasedev->migration;\n-    uint64_t remain;\n+    uint64_t precopy_size, stopcopy_size;\n \n     if (exact) {\n         vfio_state_pending_sync(vbasedev);\n-        remain = migration->stopcopy_size;\n+    }\n+\n+    precopy_size =\n+        migration->precopy_init_size + migration->precopy_dirty_size;\n+\n+    if (migration->stopcopy_size > precopy_size) {\n+        stopcopy_size = migration->stopcopy_size - precopy_size;\n     } else {\n-        if (!vfio_device_state_is_precopy(vbasedev)) {\n-            return;\n-        }\n-        remain = migration->precopy_init_size + migration->precopy_dirty_size;\n+        stopcopy_size = 0;\n     }\n \n-    pending->precopy_bytes += remain;\n+    pending->precopy_bytes += precopy_size;\n+    pending->stopcopy_bytes += stopcopy_size;\n \n     trace_vfio_state_pending(vbasedev->name, migration->stopcopy_size,\n                              migration->precopy_init_size,\n","prefixes":["07/14"]}