Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2225933/?format=api
{ "id": 2225933, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2225933/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-8-peterx@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.2/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": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260421202110.306051-8-peterx@redhat.com>", "list_archive_url": null, "date": "2026-04-21T20:21:01", "name": "[v2,07/16] migration: Introduce stopcopy_bytes in save_query_pending()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "cb37711f70a0aeb3becfa8803df16c8372fe64dc", "submitter": { "id": 67717, "url": "http://patchwork.ozlabs.org/api/1.2/people/67717/?format=api", "name": "Peter Xu", "email": "peterx@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-8-peterx@redhat.com/mbox/", "series": [ { "id": 500889, "url": "http://patchwork.ozlabs.org/api/1.2/series/500889/?format=api", "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/2225933/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225933/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=YhStOHSQ;\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=Mq9cjpQ4;\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 4g0Ygn36Lpz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:22:45 +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 1wFHbE-0000yq-F6; Tue, 21 Apr 2026 16:21:36 -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 1wFHb8-0000xM-Sp\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:31 -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 1wFHb6-0008Qt-DX\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:30 -0400", "from mail-qv1-f70.google.com (mail-qv1-f70.google.com\n [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-340-GYCqj8JLMpiQdSr7yrD_Og-1; Tue, 21 Apr 2026 16:21:26 -0400", "by mail-qv1-f70.google.com with SMTP id\n 6a1803df08f44-8ae752c5273so86571906d6.2\n for <qemu-devel@nongnu.org>; Tue, 21 Apr 2026 13:21:26 -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.23\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 13:21:23 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776802887;\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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=;\n b=YhStOHSQlN9vY7UL0GH8CPDPkd7GeCKRlT6VV73x7dUIr2xxlNqcMCz7GzTFozCBC+eAxL\n eglNitEP30JUD8SIYQ7KzWjLI9E5KUUQ0leYHIj1vPHvv6CMnFJPDasrKJIeXfG7joaIlH\n /Bb0SZDO2+CkWhXNROynPN8rjJlLhWM=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776802885; x=1777407685; 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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=;\n b=Mq9cjpQ4jqZpIUFvb/dn8E/L6eskXKKmvqIXYU9RvW1GkSU+LZRR7XrUkLBvpMuvAR\n 3YCz0aUiPveWPLrzYtzS5sHTgcNRVMmcTwPWtdfNvgygU1B2+TxMbGIPZdTdVpM0H5th\n rih7FaGENpOzK5ZL1gzxsi+kTXU12BtB8E6r+JVt6PidQu4xS05I9fW5uld2DmYKf7Yq\n sqrbiu4pxP6PPJiJAaRGEacE3suOZLaoIu/VL6mnZUVXkdfdLmTLV8i8e/TgRJRHv4tL\n NX1wwbQziRbTV2FvpKinZf4iFkRQA9G5mpj28Vb3dNSpGbAuQjdcXlQOwc2V8JSQYMN3\n /vqQ==" ], "X-MC-Unique": "GYCqj8JLMpiQdSr7yrD_Og-1", "X-Mimecast-MFC-AGG-ID": "GYCqj8JLMpiQdSr7yrD_Og_1776802886", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776802885; x=1777407685;\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=08GGg3JxwpdseV0NCpC++cfwyRjqfD6+A5Dnd/iqc6Y=;\n b=VX1ObUbum5CzWcG8oThw6IJ8QbQAspiJcBzr68dvbkr55eXLwzfv20iGfSJuM23g2C\n 2P5z74IGL0S9ZohgjsJfFHZHUCD6LPrpAXGydhFP/xUlOR8u49KJ6O4jvJ7BCXpVppbp\n gtAygfJ/0DCCN3O1Grfp/eE8kb94wPaEc6KUY84ITq9B1qGwIMWQDtKZ0kVZMHSMT2C4\n MCvm/2TmByZIV2D9mRDJAkQqVYf1VPgaKcJwK6CrNq+3ZeLd35RoHgGt9SvxhW/SDGCM\n pbk2n/6ZJhPAOE1ROBMVChBY9oC41n6aGh3z66MI+/AoQZncOvpGwZXzI+lNC68F7pYf\n 4l6A==", "X-Gm-Message-State": "AOJu0YyKiCkjvMxLZ3V0PE4kWpOppHjOtub9D1ZOMWt52h5c0ja2APPj\n C6kAS5ZPQ1fcnYBdxBdcJm498WJA+l8yyt7LQcek0wBPE/AEgtSJeHbfBRHUbW/B6ssHDqi+Jp2\n vt61mvlqW/notrhuyYAIylRh6i18nHK9s+Mbvc/YHotHkEndDBJwWAnTjd4nnEdkoh92kMsBWcS\n 54MShdbi1iVkISzh3fMQ9ennyIUAYfIYpkj4eFDA==", "X-Gm-Gg": "AeBDietBpZ9hz5EtCyFHFfLtsOxPfG9fEkrUPNPY6j6m3pcle3tfKTOMayzHUaMNssd\n 0/FBkqVHR8bZ4juWLN47gjtE76HHmCJ36mqsg6kphBMgaWQGFzAw59GTFy4teeBLJtmop/tjat0\n xSQzRU6/6m16jyuEvC3oTZ7MGP7zEO91F18aNdnopaFDOvi5vD1S8HVeMpuaoMx2M9Q6UFliTHT\n RL60IuncJw3tCM1gu5PnSt2ftmoYx4+Ihhdy7JYjF4SRNJIpVikLr7x+wHV8xtqszlqYnOtMc+F\n MfdMaxMqUGQo0FENFWvvH2ncDbzYMKLPgXH09rXw6lI5MYAfdXNhmoiF0Wb4xcENwfZplAGTDng\n 1Dq9+NT3vhNQPhTZjGW0yJOO8Uj0PQfkQZLU/FXcyqPlrHKzp23rsVDD6RA==", "X-Received": [ "by 2002:a05:6214:4e08:b0:89c:d886:c022 with SMTP id\n 6a1803df08f44-8b027ff9304mr273283706d6.1.1776802885368;\n Tue, 21 Apr 2026 13:21:25 -0700 (PDT)", "by 2002:a05:6214:4e08:b0:89c:d886:c022 with SMTP id\n 6a1803df08f44-8b027ff9304mr273283066d6.1.1776802884724;\n Tue, 21 Apr 2026 13:21:24 -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 07/16] migration: Introduce stopcopy_bytes in\n 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": "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": "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 | 65 ++++++++++++++++++++++++++++++------\n migration/savevm.c | 10 ++++--\n migration/trace-events | 2 +-\n 4 files changed, 70 insertions(+), 14 deletions(-)", "diff": "diff --git a/include/migration/register.h b/include/migration/register.h\nindex e2117e8dd4..5e5e0ee432 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..4b54fda4d7 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -3198,6 +3198,54 @@ 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+static bool postcopy_should_start(MigrationState *s, MigPendingData *pending)\n+{\n+ /* If postcopy's switchver will violate user specified downtime, stop */\n+ if (pending->precopy_bytes + pending->stopcopy_bytes > s->threshold_size) {\n+ return false;\n+ }\n+\n+ return qatomic_read(&s->start_postcopy);\n+}\n+\n /*\n * Return true if continue to the next iteration directly, false\n * otherwise.\n@@ -3209,12 +3257,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 +3268,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,14 +3288,12 @@ 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- if (pending.precopy_bytes <= s->threshold_size &&\n- can_switchover && qatomic_read(&s->start_postcopy)) {\n+ if (can_switchover && postcopy_should_start(s, &pending)) {\n if (postcopy_start(s, &local_err)) {\n migrate_error_propagate(s, error_copy(local_err));\n error_report_err(local_err);\n@@ -3264,11 +3308,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..d221e2961b 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,8 +1778,13 @@ 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->postcopy_bytes);\n+ pending->stopcopy_bytes,\n+ pending->postcopy_bytes,\n+ pending->total_bytes);\n }\n \n void qemu_savevm_state_cleanup(void)\ndiff --git a/migration/trace-events b/migration/trace-events\nindex f8995b8d0d..d2134af862 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, uint64_t total) \"exact=%d, precopy=%\"PRIu64\", stopcopy=%\"PRIu64\", postcopy=%\"PRIu64\", total=%\"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": [ "v2", "07/16" ] }