{"id":2221147,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2221147/?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-6-peterx@redhat.com>","date":"2026-04-08T16:55:49","name":"[05/14] migration: Use the new save_query_pending() API directly","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"288253a57752d21865407be4a0af0bd9d0ce47f6","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-6-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/2221147/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=Ctbqi8Ka;\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=XAmqfiku;\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 4frY3J6FPsz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:26:51 +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 1wAYQs-0006nW-A7; Wed, 08 Apr 2026 15:19:22 -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 1wAY0I-00052P-9b\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:51:54 -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 1wAWCK-00028B-05\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:13 -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-64-Yqkji9IZO_iUxmYY7dLeyA-1; Wed, 08 Apr 2026 12:56:10 -0400","by mail-qt1-f200.google.com with SMTP id\n d75a77b69052e-50d8ed08aa4so3214891cf.3\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 09:56:10 -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.07\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 08 Apr 2026 09:56:08 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775667371;\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=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=;\n b=Ctbqi8KaGxfcU511hIcWRx04URdljM5DEFzjVbIHTgAkFKsRFEsbqoGxDT+FNnZC3P+Mig\n 0jPewPhZjnhdpjzkKhlWN/wo81CvmYGyXdxvpe7YVQIj5lmMd3QXPxRGlBMB+xl2qP9oBd\n Gg1/CTafo9oZ31jgFhMPRs/rG7UmQjE=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775667370; x=1776272170; 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=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=;\n b=XAmqfikupgATTl82knCH6Rwqo2ftrq4OSOVDxHgBM7PvHKGd1r4+Gw0IJOE6jE/s/e\n qclweKKVwyeiSboI9TkmlIUO3vg58MEzB+GkGEts0BiEXhVNzvWhN5WCrQY5bSfk/0mN\n RPqBJ4dTZsu3RtmkmpxFv83lRB5GOjU3tir2sP28i8HjlTsbWYa9vgCse2ciS3egTbLX\n 5wuICgma0+4NPNO14tqsYg/+9vjiwU0s9557DBK1PyoLDPQiDexNR3f5dG7EKCVcpi1z\n KpP/JfMbjApal7YHBUYq3ZMAxdX0wzgZfSmyps+ylxDrtoysY4pXYNuduH0C0QfNCfz6\n dbmw=="],"X-MC-Unique":"Yqkji9IZO_iUxmYY7dLeyA-1","X-Mimecast-MFC-AGG-ID":"Yqkji9IZO_iUxmYY7dLeyA_1775667370","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775667370; x=1776272170;\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=d0qTHjD0q4Ya9dJ7GpDTbLPVx/TGmnxCqtBUTkBdLKA=;\n b=YFe4Ql2Xxy0RpI3F3z0M+2GPT49fZux7fO9mkXhgyDv3f9r7ojbWWjERvX7DEy23GT\n 2ggeyHyQ1RVHxLxgdRUZ4JM23XdYFnFCziTNkdeLMZe+Oo2Ft+PRQPfyFL11UhJuLbd+\n 4CQwUMbDQlt1RCHisaWQDKkZx5ZGqKo7fTVXMhD+RVMxqbwBOKzjNqUKyFr3S+fxXwJ5\n LuRgm0w9kPCcGC+Hk5yCGBxepyGrnGMTUM5/BaABZY8p/b0qWP69pEvWsYnlX92MQKWZ\n a6InE7TJmGOBuFlGl43hqY/MTK3RBVw1VJ0IjJ57zohECG9Nli3RwdYOpBdwmKXvXl3H\n 7Yug==","X-Gm-Message-State":"AOJu0Yx2bhVdMUAsJ1MiLM9R5w7i1UbNO+j1jz6RAzu1TAS5vXTYFnpi\n Q4UUJcpbG71fMVVfGTOspVpLWW9IBZXaOyZpWrHGV0ZFE9hAcgqAI/YrfPFysRZJTW3G44zKkXE\n HUUFHSKKhm/BbiZS7OPrzEmkamoGoZEsMFVUy3hUPQllE5RBSAWIxTsAuONclJCA9+LYmn+t+hv\n K/rC7gw31dmGs+0H6xNWl+02lEW6SFvQtlIoueOw==","X-Gm-Gg":"AeBDieuqVeDV64vyGI43TU2VjSkgQYKvwRKQSSn43Ok3wMl+2MVT+e8BuWioBalSVOw\n ST+J5v0vFb9C0XV0YenAWY+GCiSQ6Fqo9J94j+aCwQsrrBHzB8lso5sMGfsxK8qQdE5/Xn7eqkg\n MvTu0qvD+CDfAI5jhuUI8SYvAoUWQ+ex6EXbp8/vNbYJTBw1ZXECp18VXlluWfVLcG3OMl6SiqY\n RuypcryiCFIXJaFK0jBnwfbcE06DeIkyUpzKeWoC5o4Ul0RhG4lmozsezFL9Qy+A1IvqSPlzw6y\n q3Dw3McHKJmq+q0HiPdGbi7HRTSzmSKiqcHPF+ZCKDHyM1htiSDDZSl+ncmeMTIvPVbMYVkmQe4\n jxXCPeE1dqemYW1AD2hd1cWWMV2fR3p1ggLGMxJBLP9Ga","X-Received":["by 2002:a05:622a:1aaa:b0:50d:7e1f:9cbd with SMTP id\n d75a77b69052e-50dc21d7d2cmr1424321cf.25.1775667369466;\n Wed, 08 Apr 2026 09:56:09 -0700 (PDT)","by 2002:a05:622a:1aaa:b0:50d:7e1f:9cbd with SMTP id\n d75a77b69052e-50dc21d7d2cmr1423691cf.25.1775667368648;\n Wed, 08 Apr 2026 09:56:08 -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 05/14] migration: Use the new save_query_pending() API\n directly","Date":"Wed,  8 Apr 2026 12:55:49 -0400","Message-ID":"<20260408165559.157108-6-peterx@redhat.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260408165559.157108-1-peterx@redhat.com>","References":"<20260408165559.157108-1-peterx@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"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":"It's easier to use the new API directly in the migration iterations.  This\nalso paves way for follow up patches to add new data to report directly to\nthe iterator function.\n\nWhen at it, merge the tracepoints too into one.\n\nNo functional change intended.\n\nReviewed-by: Juraj Marcin <jmarcin@redhat.com>\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n migration/savevm.h     |  4 ----\n migration/migration.c  | 16 +++++++---------\n migration/savevm.c     | 23 ++---------------------\n migration/trace-events |  3 +--\n 4 files changed, 10 insertions(+), 36 deletions(-)","diff":"diff --git a/migration/savevm.h b/migration/savevm.h\nindex e4efd243f3..96fdf96d4e 100644\n--- a/migration/savevm.h\n+++ b/migration/savevm.h\n@@ -46,10 +46,6 @@ void qemu_savevm_state_cleanup(void);\n void qemu_savevm_state_complete_postcopy(QEMUFile *f);\n int qemu_savevm_state_complete_precopy(MigrationState *s);\n void qemu_savevm_query_pending(MigPendingData *pending, bool exact);\n-void qemu_savevm_state_pending_exact(uint64_t *must_precopy,\n-                                     uint64_t *can_postcopy);\n-void qemu_savevm_state_pending_estimate(uint64_t *must_precopy,\n-                                        uint64_t *can_postcopy);\n int qemu_savevm_state_complete_precopy_iterable(QEMUFile *f, bool in_postcopy);\n bool qemu_savevm_state_postcopy_prepare(QEMUFile *f, Error **errp);\n void qemu_savevm_state_end(QEMUFile *f);\ndiff --git a/migration/migration.c b/migration/migration.c\nindex dfc60372cf..68cfe2d3bf 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -3204,17 +3204,17 @@ typedef enum {\n  */\n static MigIterateState migration_iteration_run(MigrationState *s)\n {\n-    uint64_t must_precopy, can_postcopy, pending_size;\n     Error *local_err = NULL;\n     bool in_postcopy = (s->state == MIGRATION_STATUS_POSTCOPY_DEVICE ||\n                         s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE);\n     bool can_switchover = migration_can_switchover(s);\n+    MigPendingData pending = { };\n+    uint64_t pending_size;\n     bool complete_ready;\n \n     /* Fast path - get the estimated amount of pending data */\n-    qemu_savevm_state_pending_estimate(&must_precopy, &can_postcopy);\n-    pending_size = must_precopy + can_postcopy;\n-    trace_migrate_pending_estimate(pending_size, must_precopy, can_postcopy);\n+    qemu_savevm_query_pending(&pending, false);\n+    pending_size = pending.precopy_bytes + pending.postcopy_bytes;\n \n     if (in_postcopy) {\n         /*\n@@ -3243,14 +3243,12 @@ static MigIterateState migration_iteration_run(MigrationState *s)\n          * during postcopy phase.\n          */\n         if (pending_size <= s->threshold_size) {\n-            qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy);\n-            pending_size = must_precopy + can_postcopy;\n-            trace_migrate_pending_exact(pending_size, must_precopy,\n-                                        can_postcopy);\n+            qemu_savevm_query_pending(&pending, true);\n+            pending_size = pending.precopy_bytes + pending.postcopy_bytes;\n         }\n \n         /* Should we switch to postcopy now? */\n-        if (must_precopy <= s->threshold_size &&\n+        if (pending.precopy_bytes <= s->threshold_size &&\n             can_switchover && qatomic_read(&s->start_postcopy)) {\n             if (postcopy_start(s, &local_err)) {\n                 migrate_error_propagate(s, error_copy(local_err));\ndiff --git a/migration/savevm.c b/migration/savevm.c\nindex 392d840955..397f602257 100644\n--- a/migration/savevm.c\n+++ b/migration/savevm.c\n@@ -1778,28 +1778,9 @@ void qemu_savevm_query_pending(MigPendingData *pending, bool exact)\n         }\n         se->ops->save_query_pending(se->opaque, pending, exact);\n     }\n-}\n-\n-void qemu_savevm_state_pending_estimate(uint64_t *must_precopy,\n-                                        uint64_t *can_postcopy)\n-{\n-    MigPendingData pending;\n-\n-    qemu_savevm_query_pending(&pending, false);\n-\n-    *must_precopy = pending.precopy_bytes;\n-    *can_postcopy = pending.postcopy_bytes;\n-}\n-\n-void qemu_savevm_state_pending_exact(uint64_t *must_precopy,\n-                                     uint64_t *can_postcopy)\n-{\n-    MigPendingData pending;\n-\n-    qemu_savevm_query_pending(&pending, true);\n \n-    *must_precopy = pending.precopy_bytes;\n-    *can_postcopy = pending.postcopy_bytes;\n+    trace_qemu_savevm_query_pending(exact, pending->precopy_bytes,\n+                                    pending->postcopy_bytes);\n }\n \n void qemu_savevm_state_cleanup(void)\ndiff --git a/migration/trace-events b/migration/trace-events\nindex 60e5087e38..f8995b8d0d 100644\n--- a/migration/trace-events\n+++ b/migration/trace-events\n@@ -7,6 +7,7 @@ qemu_loadvm_state_section_partend(uint32_t section_id) \"%u\"\n qemu_loadvm_state_post_main(int ret) \"%d\"\n qemu_loadvm_state_section_startfull(uint32_t section_id, const char *idstr, uint32_t instance_id, uint32_t version_id) \"%u(%s) %u %u\"\n qemu_savevm_send_packaged(void) \"\"\n+qemu_savevm_query_pending(bool exact, uint64_t precopy, uint64_t postcopy) \"exact=%d, precopy=%\"PRIu64\", postcopy=%\"PRIu64\n loadvm_state_switchover_ack_needed(unsigned int switchover_ack_pending_num) \"Switchover ack pending num=%u\"\n loadvm_state_setup(void) \"\"\n loadvm_state_cleanup(void) \"\"\n@@ -159,8 +160,6 @@ migration_cleanup(void) \"\"\n migrate_error(const char *error_desc) \"error=%s\"\n migration_cancel(void) \"\"\n migrate_handle_rp_req_pages(const char *rbname, size_t start, size_t len) \"in %s at 0x%zx len 0x%zx\"\n-migrate_pending_exact(uint64_t size, uint64_t pre, uint64_t post) \"exact pending size %\" PRIu64 \" (pre = %\" PRIu64 \" post=%\" PRIu64 \")\"\n-migrate_pending_estimate(uint64_t size, uint64_t pre, uint64_t post) \"estimate pending size %\" PRIu64 \" (pre = %\" PRIu64 \" post=%\" PRIu64 \")\"\n migrate_send_rp_message(int msg_type, uint16_t len) \"%d: len %d\"\n migrate_send_rp_recv_bitmap(char *name, int64_t size) \"block '%s' size 0x%\"PRIi64\n migration_completion_file_err(void) \"\"\n","prefixes":["05/14"]}