{"id":2225939,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2225939/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-9-peterx@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/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":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260421202110.306051-9-peterx@redhat.com>","list_archive_url":null,"date":"2026-04-21T20:21:02","name":"[v2,08/16] 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.2/people/67717/?format=json","name":"Peter Xu","email":"peterx@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-9-peterx@redhat.com/mbox/","series":[{"id":500889,"url":"http://patchwork.ozlabs.org/api/1.2/series/500889/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500889","date":"2026-04-21T20:20:55","name":"migration/vfio: Fix a few issues on API misuse or statistic reports","version":2,"mbox":"http://patchwork.ozlabs.org/series/500889/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225939/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225939/checks/","tags":{},"related":[],"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=cYBTGFVd;\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=CDgyMvHG;\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=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.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 4g0YhV5mwxz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:23:22 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFHbD-0000yk-Nt; Tue, 21 Apr 2026 16: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 1wFHb9-0000xr-Kd\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:33 -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 1wFHb7-0008R9-PR\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:31 -0400","from mail-qv1-f69.google.com (mail-qv1-f69.google.com\n [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-170-_SuEQvpmOZemoCx2UR7ZLQ-1; Tue, 21 Apr 2026 16:21:27 -0400","by mail-qv1-f69.google.com with SMTP id\n 6a1803df08f44-8a275472d89so69877266d6.1\n for <qemu-devel@nongnu.org>; Tue, 21 Apr 2026 13:21:27 -0700 (PDT)","from x1.local ([142.189.10.167]) by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8b02ae5c26csm114343556d6.31.2026.04.21.13.21.24\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 13:21:25 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776802889;\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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=;\n b=cYBTGFVd/JA7IdrN4APu8XKu3V4b5UTwzTFpT7SzVSV09vgiAJPk7Yp2Kd61sZtu0jMriG\n B3QrHGTrwCcJEIAR5JjcMPzxLD9/VswL/6zCYIbzkaSMGl2NI9iFR359GWWBlsi8nFyL4L\n ZQODVC6cmdHxlJ+0qers3wez8S8I7Xw=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776802887; x=1777407687; 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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=;\n b=CDgyMvHGmbr49Za/wCmF9F201qEfau+WHSFueiRFF0K/8t53VQmSa4Vi7SxsGpIl2X\n KnsaNHaEnKuJX/2iKsBNSrm8Pr0WrK9Y5HBbTTpsI8FVtcroe1OIezY6rsDyP2ORNvif\n 6e5bfBcu0FYfXt4Q0UraMK30SMUya/4k+0H/Qr/fwlNGbOcSqDs+UdtJ8D/MpgBy0HvA\n aCAUe6ty8dM9PvT2e6vBYqJrzHeHVDtx9vetQ70vhqLA8N+PBfsxI6AHHloQLRmYJuuA\n 0a/y1rfsOuwCB1Lt07vtFRx0Amf9LRC1np42akgFQ59XSGAwft9+o4pCWnkT9k8mUpfD\n GWUw=="],"X-MC-Unique":"_SuEQvpmOZemoCx2UR7ZLQ-1","X-Mimecast-MFC-AGG-ID":"_SuEQvpmOZemoCx2UR7ZLQ_1776802887","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776802887; x=1777407687;\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=JxOej4+K9+12DVShlen6zBubWxbQhJb/dp07j+yzJwU=;\n b=gu2orQ4LuAyk5ykNkfiV9/UBL0EcLGLbcl4rh91ZF37cgF+CnrEeHuA+IJX0NtA/74\n JUYmCj4xFINneHThYuMppvM6isVipJ+BT0gg43zATIZubhE4tV5PdDR8prG/OB0KNb47\n mKu+hyFLPcaLRxEqtcv7ckZMRZGvjleni8FJgd4MTITa+mW8JtavV4dsRPNcV9G79bCH\n aMSfsg4f3rdR/QUlduGLaFVYNqRzGFIkhpX4IORyxePZ3NoGEbwBNrLw8F+zsXTFyf8c\n IuKMTEgNwqnxEiQpVs8IKiTW7Giw5PEymBdG2Wgrv2Q4VNjiCFixIA8Bhq3OqAJY0hcq\n vQbw==","X-Gm-Message-State":"AOJu0YwT/zouZI0hCGfwu+jw+V5J5nwoW4UaiWLx2xgoAs60yQkrM3Xh\n aVgXoGHVOgbUD9Fg/U5LTp+dFJ5r86qkrxEhdmbMGtiIrdYXYxZ8Zmu+qwC3ZLRL5sW+ikPfLPE\n ziMbh0+501727xQNCx7i/D2EVTSDoRE9kBCGgmQCCayQ10b18YYB0LYiBfbt+NzxAYGa7B7bgdM\n KDWakel6PbNywPHEKF7co1EAgZv/tUN+TNUmNoJQ==","X-Gm-Gg":"AeBDievtd3DMdhfE00939w5W2otk05jSwp/t9f/q0BTbbtQZpN0oUwybMFeABvVQHsb\n Pwy1wToe/cYUV9i70YhvsWTErJZGmKMiMHLbUvDGSOUUV+Pt2QTlcnC5fGhmR++FZai6cnhrh8F\n vXxsvHMVL0MepROlsPpzdT07JPhXsltwD1oSi4xR96daKz27jzb4YSZp+ipy9saF0ZBzv0JKqGp\n SEKVzbcj8Tc/O4RBMuLm1vaD7X+UEo7AEsAjmxEvGD8mKBWK+2gG40oM2F19jUIlARVSX+wHIIF\n Gih62G+tnOU6N7FGWan+TAcZ8KWRmO7dvwz8ySRN577g3aZnn2lM6FN1z52H4zY6JS7LWPQZBdj\n fhDXUS+fLV4Yy9qis/zHVNToFcWq/yqUK3ikBvDyPt0Xg9/hGnRhMupN6DQ==","X-Received":["by 2002:a05:6214:2521:b0:8ac:b6d7:e60b with SMTP id\n 6a1803df08f44-8b028013c49mr316275196d6.1.1776802886735;\n Tue, 21 Apr 2026 13:21:26 -0700 (PDT)","by 2002:a05:6214:2521:b0:8ac:b6d7:e60b with SMTP id\n 6a1803df08f44-8b028013c49mr316274406d6.1.1776802886015;\n Tue, 21 Apr 2026 13:21:26 -0700 (PDT)"],"From":"Peter Xu <peterx@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Joao Martins <joao.m.martins@oracle.com>,\n Markus Armbruster <armbru@redhat.com>,\n =?utf-8?q?C=C3=A9dric_Le_Goater?= <clg@redhat.com>,\n Avihai Horon <avihaih@nvidia.com>,\n =?utf-8?q?Daniel_P_=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Fabiano Rosas <farosas@suse.de>, Prasad Pandit <ppandit@redhat.com>,\n Alex Williamson <alex@shazbot.org>, Kirti Wankhede <kwankhede@nvidia.com>,\n Zhiyi Guo <zhguo@redhat.com>, Peter Xu <peterx@redhat.com>,\n \"Maciej S . Szmigiero\" <mail@maciej.szmigiero.name>,\n Juraj Marcin <jmarcin@redhat.com>","Subject":"[PATCH v2 08/16] vfio/migration: Fix incorrect reporting for VFIO\n 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":"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":"-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,\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, SPF_HELO_PASS=-0.001,\n 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\nReviewed-by: Avihai Horon <avihaih@nvidia.com>\nTested-by: 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 e965ba51fb..e6e6a0d53d 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":["v2","08/16"]}