get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2225923,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/2225923/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-11-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-11-peterx@redhat.com>",
    "list_archive_url": null,
    "date": "2026-04-21T20:21:04",
    "name": "[v2,10/16] migration: Introduce a helper to return switchover bw estimate",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "40910d22baa7354680a125e81bcdbdcb5281a2b6",
    "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-11-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/2225923/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2225923/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=h6iok2/v;\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=kNofL9P3;\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 4g0Yfy1Skzz1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:22:02 +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 1wFHbF-0000zK-6M; Tue, 21 Apr 2026 16:21:37 -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 1wFHbC-0000yW-Ui\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:35 -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 1wFHbB-0008S4-Bs\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:34 -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-297-oSm0CgqPMOWHfxh8k-Mx4w-1; Tue, 21 Apr 2026 16:21:31 -0400",
            "by mail-qt1-f200.google.com with SMTP id\n d75a77b69052e-50edf0245b0so54171811cf.1\n for <qemu-devel@nongnu.org>; Tue, 21 Apr 2026 13:21:31 -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.28\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 13:21:28 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776802892;\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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=;\n b=h6iok2/vP2KYlrKShfUcINuQX+jMQTk2Z9Ygm22ncSo/hnUxZ1PiLvSwbQl8XNXO3G6/jv\n k95QWOOVD1csZAQfPYo9ds4eA4TJA8YtAoZP4My865P3Eceu3DYAzKKxam6E1pdYk2kFcG\n 991p9mYTPRr+06PlX+joWAvSXYdrBhY=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776802890; x=1777407690; 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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=;\n b=kNofL9P3mc1ff3iR0ggIgFliJ8YDa6RERSkPQhJ1v6LyGLVEvzs+O1yER5X7A1wlk+\n dSlO5pe9okSgIjC28rXRIebzv31JE4j67oJwvfwM646x+Sz9DWCmCZ1lX6JBSr6BfGfF\n yE3Pzr0tVeF59e6a5QbwEubATmnINJP0trvl2J7LA8mcAcx9vVVXExzPbyGFxjeO3NkD\n 6pnwLM8ht4ZbxZ9qiuLfl5tdUNmhO9J2oB8AqJNAacfBmVCU5o72bzTjApo9kwStY/X0\n GP9JwbD5RBBqaTF5baaSuMYBcHfsPT6/E4eh30W3LbfLAV9LKhOsg76sj9Vav5q3Sps3\n WFqQ=="
        ],
        "X-MC-Unique": "oSm0CgqPMOWHfxh8k-Mx4w-1",
        "X-Mimecast-MFC-AGG-ID": "oSm0CgqPMOWHfxh8k-Mx4w_1776802891",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776802890; x=1777407690;\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=MP6eJHP+Kzsfxz3ElFor7EoD903ypuntI/q5FTsZpKQ=;\n b=kf/gfpf7HM4xtAxOaoD7IWLdfWX1gsnLQp798cr1h5qbImHDCleeCX6yFEF4HpPZFL\n WC5YUBoFrDPjKg6C3ajkFHRmn52Xav8uHPlbMmawWjsMoLv0QNo6uNJcsdDDBMOLANSQ\n UJ+TkYYaz2gg4puTJns0njBZc2zft9uhBq9F3g3Px9C5SjnDP7wdEI/RwZ4OnIvBRquV\n Ds30LO1ypYhMRLsVDQwhrKgsCAi35TMXuRdZG+jXlR1jVFL69n8IkfJx5Laiq8B+DiZY\n APam6fFiGZ8gzeH+hVLPGaN1Mz8EPl1PTVxEXrOp23lW6wvEjGRrBAAAS9Bt2MYI+s37\n CrZg==",
        "X-Gm-Message-State": "AOJu0YwvuAUIa4oGwvGvGa/YHiL9MDQhUGivhptWUIBz6V+WFGdALeeG\n 6hPZ/R5fQPcjPc/52/kNcZVRw79JJdb3ErNXDyF4zzRoC+kTIB9hGCnRWVKjVlp8kRAcbwZ42rK\n TRKHVkuRNy0uwdPqfYmaRvtZTxYWgcxFhnYgS1Wxc1JLt9ZiYIPdAR6yudkp17tw7ym2shAVPpN\n tHBZgjItKlnJPH3s2jkuTcRthWWjsXBj1OZi3+Bg==",
        "X-Gm-Gg": "AeBDiesymm8nNgG2H4CjG9mtUeBhk67FdrB7/y2SJ+kizpKnxyJbF7kKT2qO0wrHr2Z\n UuGjjwxytLKhciOTwcCOo2TbIwq91ZNF9UbWPMmBPdPz2K94qFPx4XNaDizS9PyyfjSK964QWGg\n lT+VjivvzSFrDXed0Lgq2kp17YpApbmzSR6DBrx0lZldZYVPF8nfO8fLPSJYtpsVs9uBYOSj/Jj\n rloP2rsRUbUdj+V71NClb+AZE6ADLCjYTmQz7/Cf/+PfguJ25G4SoYA/CYJLz1FyKCrZy09YeaY\n kUZ2d2V4eSqLuXEW4EQyZ2gskJrwhUMqj7mZW9acmE7w1MAvn4PnGmQ2iUxqGneG7HfK1rldwll\n SBcaw/O+ySxzPa3lfz738SuWDgKGAaTG8RpIx8qkO995LH8TasqIsZUhiOQ==",
        "X-Received": [
            "by 2002:a05:622a:17c7:b0:50e:89e9:271c with SMTP id\n d75a77b69052e-50e89e92b67mr120918351cf.17.1776802890325;\n Tue, 21 Apr 2026 13:21:30 -0700 (PDT)",
            "by 2002:a05:622a:17c7:b0:50e:89e9:271c with SMTP id\n d75a77b69052e-50e89e92b67mr120917561cf.17.1776802889606;\n Tue, 21 Apr 2026 13:21:29 -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 10/16] migration: Introduce a helper to return switchover\n bw estimate",
        "Date": "Tue, 21 Apr 2026 16:21:04 -0400",
        "Message-ID": "<20260421202110.306051-11-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.129.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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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": "Add a helper migration_get_switchover_bw() to return an estimate of\nswitchover bandwidth.  Use it to simplify the current code.\n\nThis will be used in later to remove expected_downtime.\n\nWhen at it, remove two qatomic_read() to shrink the lines because atomic\nops are not needed when it's always the same thread who does the updates.\n\nReviewed-by: Juraj Marcin <jmarcin@redhat.com>\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n migration/migration.c | 48 +++++++++++++++++++++----------------------\n 1 file changed, 24 insertions(+), 24 deletions(-)",
    "diff": "diff --git a/migration/migration.c b/migration/migration.c\nindex e3f82baaac..caa1d13130 100644\n--- a/migration/migration.c\n+++ b/migration/migration.c\n@@ -984,6 +984,21 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value)\n     migrate_send_rp_message(mis, MIG_RP_MSG_RESUME_ACK, sizeof(buf), &buf);\n }\n \n+/*\n+ * Returns the estimated switchover bandwidth (unit: bytes / seconds)\n+ */\n+static double migration_get_switchover_bw(MigrationState *s)\n+{\n+    uint64_t switchover_bw = migrate_avail_switchover_bandwidth();\n+\n+    if (switchover_bw) {\n+        /* If user specified, prioritize this value and don't estimate */\n+        return (double)switchover_bw;\n+    }\n+\n+    return s->mbps / 8 * 1000 * 1000;\n+}\n+\n bool migration_is_running(void)\n {\n     MigrationState *s = current_migration;\n@@ -3126,37 +3141,22 @@ static void migration_update_counters(MigrationState *s,\n {\n     uint64_t transferred, transferred_pages, time_spent;\n     uint64_t current_bytes; /* bytes transferred since the beginning */\n-    uint64_t switchover_bw;\n-    /* Expected bandwidth when switching over to destination QEMU */\n-    double expected_bw_per_ms;\n-    double bandwidth;\n+    double switchover_bw_per_ms;\n \n     if (current_time < s->iteration_start_time + BUFFER_DELAY) {\n         return;\n     }\n \n-    switchover_bw = migrate_avail_switchover_bandwidth();\n     current_bytes = migration_transferred_bytes();\n     transferred = current_bytes - s->iteration_initial_bytes;\n     time_spent = current_time - s->iteration_start_time;\n-    bandwidth = (double)transferred / time_spent;\n-\n-    if (switchover_bw) {\n-        /*\n-         * If the user specified a switchover bandwidth, let's trust the\n-         * user so that can be more accurate than what we estimated.\n-         */\n-        expected_bw_per_ms = (double)switchover_bw / 1000;\n-    } else {\n-        /* If the user doesn't specify bandwidth, we use the estimated */\n-        expected_bw_per_ms = bandwidth;\n-    }\n-\n-    s->threshold_size = expected_bw_per_ms * migrate_downtime_limit();\n-\n     s->mbps = (((double) transferred * 8.0) /\n                ((double) time_spent / 1000.0)) / 1000.0 / 1000.0;\n \n+    /* NOTE: only update this after bandwidth (s->mbps) updated */\n+    switchover_bw_per_ms = migration_get_switchover_bw(s) / 1000;\n+    s->threshold_size = switchover_bw_per_ms * migrate_downtime_limit();\n+\n     transferred_pages = ram_get_total_transferred_pages() -\n                             s->iteration_initial_pages;\n     s->pages_per_second = (double) transferred_pages /\n@@ -3166,10 +3166,9 @@ static void migration_update_counters(MigrationState *s,\n      * if we haven't sent anything, we don't want to\n      * recalculate. 10000 is a small enough number for our purposes\n      */\n-    if (qatomic_read(&mig_stats.dirty_pages_rate) &&\n-        transferred > 10000) {\n+    if (mig_stats.dirty_pages_rate && transferred > 10000) {\n         s->expected_downtime =\n-            qatomic_read(&mig_stats.dirty_bytes_last_sync) / expected_bw_per_ms;\n+            mig_stats.dirty_bytes_last_sync / switchover_bw_per_ms;\n     }\n \n     migration_rate_reset();\n@@ -3178,7 +3177,8 @@ static void migration_update_counters(MigrationState *s,\n \n     trace_migrate_transferred(transferred, time_spent,\n                               /* Both in unit bytes/ms */\n-                              bandwidth, switchover_bw / 1000,\n+                              (uint64_t)s->mbps,\n+                              (uint64_t)switchover_bw_per_ms,\n                               s->threshold_size);\n }\n \n",
    "prefixes": [
        "v2",
        "10/16"
    ]
}