get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.0/patches/2221157/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2221157,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2221157/?format=api",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.0/projects/14/?format=api",
        "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-7-peterx@redhat.com>",
    "date": "2026-04-08T16:55:50",
    "name": "[06/14] migration: Introduce stopcopy_bytes in save_query_pending()",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "35b4a9cc0e66fdbc1f9aa1a745451cdcd6bbb229",
    "submitter": {
        "id": 67717,
        "url": "http://patchwork.ozlabs.org/api/1.0/people/67717/?format=api",
        "name": "Peter Xu",
        "email": "peterx@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408165559.157108-7-peterx@redhat.com/mbox/",
    "series": [
        {
            "id": 499176,
            "url": "http://patchwork.ozlabs.org/api/1.0/series/499176/?format=api",
            "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/2221157/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=aTfhsN5v;\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=jnQx1ibA;\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 4frY844yKHz1xv0\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:31:00 +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 1wAYVz-0005ff-B4; Wed, 08 Apr 2026 15:24:39 -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 1wAY6o-0007AB-9d\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:58:38 -0400",
            "from us-smtp-delivery-124.mimecast.com ([170.10.129.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 1wAWCL-00028T-Kz\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:15 -0400",
            "from mail-qt1-f198.google.com (mail-qt1-f198.google.com\n [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-427-0mmlNPhOPf2omk0CpvAyOA-1; Wed, 08 Apr 2026 12:56:11 -0400",
            "by mail-qt1-f198.google.com with SMTP id\n d75a77b69052e-50d8c192b3fso3701361cf.1\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 09:56:11 -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.08\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 08 Apr 2026 09:56:09 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775667373;\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=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=;\n b=aTfhsN5vidp+EnI1PgGgNloMwRDYe0L7A3/mO9embGFDfP8gAZP2pLTVi2ensfDILaD16v\n aITdW1e7Yk/2l0mXSKbnP0c2STTrvga+m3heOUUpXz3CW5YxxFYJ+NT/A9yS4amf+jZIzu\n QiZ6KvjwvKYVc/jhvl0RBDPTa/gYC3I=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775667371; x=1776272171; 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=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=;\n b=jnQx1ibA7s9H6Bee7rOSt9NL5mVJydGGB3tZJ50Zi6tCmahyhHmoFeEsjfv9kAX5HT\n l4fadRvM85WBt+MDNfBS3WX4RRujGjIRhtTBp5gwTeDapwpZJBY48aFzd4V3+b48ONMd\n cm+J7VpylzrUGE1gaQEOl/Me7tFz/RhZdIXVzZDOOex5Ztlw3JGbdKgNqBQqNjj4qZLa\n tiZyF7D5KTmLokRF2WNNLGW98IpcNt6gqhJwIcUjxZq0esT9a3Ge2vwcb3u54J+0h8Wp\n FYsNxNlWmxgblOKBiQcoHvPrq6wN1N2FKqHjk32KNQ85LH+W8xTgH8/V7Jk1jdpUbuOQ\n OOAg=="
        ],
        "X-MC-Unique": "0mmlNPhOPf2omk0CpvAyOA-1",
        "X-Mimecast-MFC-AGG-ID": "0mmlNPhOPf2omk0CpvAyOA_1775667371",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775667371; x=1776272171;\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=/so6tADcpAnszGZfb6E8GQmrFKlFQ/pKW4GZKB1ulXc=;\n b=qt5VLKKS/AjKvH35ebrQezWWYtg0Ua53xz8cfDCvvuEbexsLthwBG7kjlPbmUq/Dlr\n erJZh9THIymFYuD8vy/rPQldpgvzuICiobjtjepxfkrquMcJkTFb/H4rkGjpWA7rj99F\n G4KvMKeJvdb/T3OM0OTgUIW9mYegWPtgg/Pis9v0h28xB7wWSvc7eojFEpgKVDdaC2fu\n njjBGmrCn4ttrWmtVlXzfGALYq23C5OQMl/BzRvgg54C0aUPIE4TCcrr3FJ/KagSM7xF\n wmhQLg3KwcUzQNyX1dPKBmztRAiP+64kii+Ujm83M/5Mmq1qQJouDTSr+BQIDtaL5sjC\n sMVw==",
        "X-Gm-Message-State": "AOJu0YzIEIGOuc5JCyjTVQz+kGJ4GFattKiqW5GjvY2QNLKK6iqhpG/9\n rhIOPL8hqTKoz1Q4yhxuCzGtJb9uefT1NSlmelRhlK0N/YSehycL8rBQ0TidIkbEp3nhx35k9zJ\n QZmki9CRXyLG/vqmi8daJzQBnnukSZve23MNfg7oRMPkp1OSAh5PSrJLS0yRCDiRoxy5/3E4v5A\n MHC9/AOz6NHaIBpV+Li2ufp4UWSUt/sdDjT2N12g==",
        "X-Gm-Gg": "AeBDiev1a3AQETaPW9DkhKb9Y1BNinrqnwdPQp+fMy/CbyBqS36Nip4zSqd7TOYA35+\n PYi+PXFFrGFpCk0s+Im3bu/WrWtNBeZsLDqhweP7J+zlX8PblOocg8Qwo4k6j5yUPvcYZi/LZu2\n C/QZLfzp6dzTzXWir7y+ekibi0xBUgTXAlUAySZnjx9SSdzCsvlyMFpAKhPhy4FGVcNS+Phb4Tc\n //ZevUZfoBoDx2LGm3eIbyi9DdC2Wku9mmLeUtRffN8Bf3CA09Lb5t49pRG9gYeJwKPrntJLury\n 4VFsQRyJVOMy/Co1/KDtB3iKmlEIB+muzGBMz/NLxPxl6suzSluLUAjACZjRa7dQyJGlNLb9GOD\n IY60qhWIl/uPkhs3aJL9/D1WJzW+OfujtLzQEfM6yEyQg",
        "X-Received": [
            "by 2002:a05:622a:540c:b0:50d:81c4:4c85 with SMTP id\n d75a77b69052e-50dc224d638mr1233171cf.36.1775667370587;\n Wed, 08 Apr 2026 09:56:10 -0700 (PDT)",
            "by 2002:a05:622a:540c:b0:50d:81c4:4c85 with SMTP id\n d75a77b69052e-50dc224d638mr1232261cf.36.1775667369944;\n Wed, 08 Apr 2026 09:56:09 -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 06/14] migration: Introduce stopcopy_bytes in\n save_query_pending()",
        "Date": "Wed,  8 Apr 2026 12:55:50 -0400",
        "Message-ID": "<20260408165559.157108-7-peterx@redhat.com>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260408165559.157108-1-peterx@redhat.com>",
        "References": "<20260408165559.157108-1-peterx@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=170.10.129.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_H4=0.001, RCVD_IN_MSPIKE_WL=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": "Allow modules to report data that can only be migrated after VM is stopped.\n\nWhen this concept is introduced, we will need to account stopcopy size to\nbe part of pending_size as before.\n\nHowever, when there're data only can be migrated in stopcopy phase, it\nmeans the old \"pending_size\" may not always be able to reach low enough to\nkickoff an slow version of query sync.\n\nIt used to be almost guaranteed to happen as all prior iterative modules\ndoesn't have stopcopy only data.  VFIO may change that fact by having some\ndata that must be copied during stop phase.\n\nSo we need to make sure QEMU will kickoff a synchronized version of query\npending when all precopy data is migrated.  This might be important to VFIO\nto keep making progress even if the downtime cannot yet be satisfied.\n\nSo far, this patch should introduce no functional change, as no module yet\nreport stopcopy size.\n\nThis paves way for VFIO to properly report its pending data sizes, which\nwill start to include stop-only data.\n\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n include/migration/register.h |  7 +++++\n migration/migration.c        | 52 ++++++++++++++++++++++++++++++------\n migration/savevm.c           |  7 +++--\n migration/trace-events       |  2 +-\n 4 files changed, 57 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/include/migration/register.h b/include/migration/register.h\nindex aba3c9af2f..e822a2a59f 100644\n--- a/include/migration/register.h\n+++ b/include/migration/register.h\n@@ -21,6 +21,13 @@ typedef struct MigPendingData {\n     uint64_t precopy_bytes;\n     /* Amount of pending bytes can be transferred in postcopy */\n     uint64_t postcopy_bytes;\n+    /* Amount of pending bytes can be transferred only in stopcopy */\n+    uint64_t stopcopy_bytes;\n+    /*\n+     * Total pending data, modules do not need to update this field, it\n+     * will be automatically calculated by migration core API.\n+     */\n+    uint64_t total_bytes;\n } MigPendingData;\n \n /**\ndiff --git a/migration/migration.c b/migration/migration.c\nindex 68cfe2d3bf..bb17bd0e68 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -3198,6 +3198,44 @@ typedef enum {\n     MIG_ITERATE_BREAK,          /* Break the loop */\n } MigIterateState;\n \n+/* Are we ready to move to the next iteration phase? */\n+static bool migration_iteration_next_ready(MigrationState *s,\n+                                           MigPendingData *pending)\n+{\n+    /*\n+     * If the estimated values already suggest us to switchover, mark this\n+     * iteration finished, time to do a slow sync.\n+     */\n+    if (pending->total_bytes <= s->threshold_size) {\n+        return true;\n+    }\n+\n+    /*\n+     * Since we may have modules reporting stop-only data, we also want to\n+     * re-query with slow mode if all precopy data is moved over.  This\n+     * will also mark the current iteration done.\n+     *\n+     * This could happen when e.g. a module (like, VFIO) reports stopcopy\n+     * size too large so it will never yet satisfy the downtime with the\n+     * current setup (above check).  Here, slow version of re-query helps\n+     * because we keep trying the best to move whatever we have.\n+     */\n+    if (pending->precopy_bytes == 0) {\n+        return true;\n+    }\n+\n+    return false;\n+}\n+\n+static void migration_iteration_go_next(MigPendingData *pending)\n+{\n+    /*\n+     * Do a slow sync will achieve this.  TODO: move RAM iteration code\n+     * into the core layer.\n+     */\n+    qemu_savevm_query_pending(pending, true);\n+}\n+\n /*\n  * Return true if continue to the next iteration directly, false\n  * otherwise.\n@@ -3209,12 +3247,10 @@ static MigIterateState migration_iteration_run(MigrationState *s)\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_query_pending(&pending, false);\n-    pending_size = pending.precopy_bytes + pending.postcopy_bytes;\n \n     if (in_postcopy) {\n         /*\n@@ -3222,7 +3258,7 @@ static MigIterateState migration_iteration_run(MigrationState *s)\n          * postcopy completion doesn't rely on can_switchover, because when\n          * POSTCOPY_ACTIVE it means switchover already happened.\n          */\n-        complete_ready = !pending_size;\n+        complete_ready = !pending.total_bytes;\n         if (s->state == MIGRATION_STATUS_POSTCOPY_DEVICE &&\n             (s->postcopy_package_loaded || complete_ready)) {\n             /*\n@@ -3242,9 +3278,8 @@ static MigIterateState migration_iteration_run(MigrationState *s)\n          * postcopy started, so ESTIMATE should always match with EXACT\n          * during postcopy phase.\n          */\n-        if (pending_size <= s->threshold_size) {\n-            qemu_savevm_query_pending(&pending, true);\n-            pending_size = pending.precopy_bytes + pending.postcopy_bytes;\n+        if (migration_iteration_next_ready(s, &pending)) {\n+            migration_iteration_go_next(&pending);\n         }\n \n         /* Should we switch to postcopy now? */\n@@ -3264,11 +3299,12 @@ static MigIterateState migration_iteration_run(MigrationState *s)\n          * (2) Pending size is no more than the threshold specified\n          *     (which was calculated from expected downtime)\n          */\n-        complete_ready = can_switchover && (pending_size <= s->threshold_size);\n+        complete_ready = can_switchover &&\n+            (pending.total_bytes <= s->threshold_size);\n     }\n \n     if (complete_ready) {\n-        trace_migration_thread_low_pending(pending_size);\n+        trace_migration_thread_low_pending(pending.total_bytes);\n         migration_completion(s);\n         return MIG_ITERATE_BREAK;\n     }\ndiff --git a/migration/savevm.c b/migration/savevm.c\nindex 397f602257..b75c311a95 100644\n--- a/migration/savevm.c\n+++ b/migration/savevm.c\n@@ -1766,8 +1766,7 @@ void qemu_savevm_query_pending(MigPendingData *pending, bool exact)\n {\n     SaveStateEntry *se;\n \n-    pending->precopy_bytes = 0;\n-    pending->postcopy_bytes = 0;\n+    memset(pending, 0, sizeof(*pending));\n \n     QTAILQ_FOREACH(se, &savevm_state.handlers, entry) {\n         if (!se->ops || !se->ops->save_query_pending) {\n@@ -1779,7 +1778,11 @@ void qemu_savevm_query_pending(MigPendingData *pending, bool exact)\n         se->ops->save_query_pending(se->opaque, pending, exact);\n     }\n \n+    pending->total_bytes = pending->precopy_bytes +\n+        pending->stopcopy_bytes + pending->postcopy_bytes;\n+\n     trace_qemu_savevm_query_pending(exact, pending->precopy_bytes,\n+                                    pending->stopcopy_bytes,\n                                     pending->postcopy_bytes);\n }\n \ndiff --git a/migration/trace-events b/migration/trace-events\nindex f8995b8d0d..2f86ad448e 100644\n--- a/migration/trace-events\n+++ b/migration/trace-events\n@@ -7,7 +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+qemu_savevm_query_pending(bool exact, uint64_t precopy, uint64_t stopcopy, uint64_t postcopy) \"exact=%d, precopy=%\"PRIu64\", stopcopy=%\"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",
    "prefixes": [
        "06/14"
    ]
}