get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2221156,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2221156/?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-11-peterx@redhat.com>",
    "date": "2026-04-08T16:55:54",
    "name": "[10/14] 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.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-11-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/2221156/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=F8EGtmB8;\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=NG+0FBbj;\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 4frY7z47sJz1xv0\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:30:55 +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 1wAYWU-00073D-KP; Wed, 08 Apr 2026 15:25:10 -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 1wAY6y-0007Ou-HI\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 14:58:48 -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 1wAWCS-00029E-2f\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 12:56:21 -0400",
            "from mail-qt1-f197.google.com (mail-qt1-f197.google.com\n [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-153-DLlQR6maOByv-nGFlwDZ9g-1; Wed, 08 Apr 2026 12:56:18 -0400",
            "by mail-qt1-f197.google.com with SMTP id\n d75a77b69052e-50d6bf346adso2333351cf.1\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 09:56:18 -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.15\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 08 Apr 2026 09:56:16 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1775667379;\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=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=;\n b=F8EGtmB8Fd4WtYSXM6Ktiji32yqMDgPfMDoC718kaDFVTYbe3RykzmjIbe7F/5bPVIJoQZ\n E5y+Mw6Xu31nyNSAKC2VF94L7hP1hUaQlf4ZKas5z0mLdqj3tk3bpSUlQqC7hUe1IMojG1\n 8j2/dpwjnnFkZjH5xK6ZuIHHoTYASHo=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1775667377; x=1776272177; 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=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=;\n b=NG+0FBbjo0r5wMm7BydRmLKoTG0wbI3hgXzV4E0A/6l9p+lz72gWlyJS89o8BlMfPh\n 7tgWE5R4WH13EYkVas2g7IdlzNxP1BOT0X5FIGolaPOAbu5Cu/H7eF7I7zGjBWJgKrHQ\n owYkqrRBwdTMi8J9vb+f06GKFWC/q3pYbC2jFSPIoRsorQSqNGEYGXH1OudSztmSkE0G\n OjOgX/B08FVTACmUAMJe4zr5NyO++ptODiNl7TfLFIfLZizSevarLaX3xfYwj6E8dOWd\n 3XVZsGIZ/ssTGmpMqeGtYiqhMXasbjOvSAuVzHvon/scHC/pakMERDaf7y9rzcoX3o3n\n twZw=="
        ],
        "X-MC-Unique": "DLlQR6maOByv-nGFlwDZ9g-1",
        "X-Mimecast-MFC-AGG-ID": "DLlQR6maOByv-nGFlwDZ9g_1775667378",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775667377; x=1776272177;\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=zE/OR2UJlEPUMANmN2EULG0b7Ek3BGjAQyC/gyTr4yY=;\n b=NDrdzEnnSwow5R8k8IoQusrG2aP1aVSlzz84unirONzEHvfrKZqzr0mhphygPY7Wql\n KAB5UzauxgtBKo33QLTSUpBowPt3cMpYIfgoFQiyuL5Scp6BlHKKBGJ+y6azHBPFuHdV\n dQd6cfnLob+HLXdoF9D2vtPOfGhdWk/FLxfQUrQGP9YXWnoi6v/7PRdFz6TfVa0++L+W\n blwbf1bfBaQGYpXC4NmQ+D0dShS9Gw0HAGTZQ0UZBSaDMK0GDV1KUrFByBBJSgGb3fwD\n DcHH5WqdK4XChw2nXU+OyjYwreJiLeoJwxy8oSVT7wEXoDLUPGwqEEfKVtIYYKHEjRB+\n 204g==",
        "X-Gm-Message-State": "AOJu0YxHrTyENXkjAuUrXhWuZ5mnvVwlDXaPEe6XoPNDXgRn3dbKF9C/\n n8psrZikThNGFzE3bx7jy3mK/pQErnvjbIz5EN0DwrDxugP4mGDzYeFadeTJGWYRwOtP88gszjw\n d28Eoz86fAmhrGIKkecHEr6kJO+LUUZrG6rhVBmTY40vU2K2SWvs9EsZth5kVDKTgX9/WJ0gUs2\n c822tfIrMMbXYv2M9GKgde8ZPFx+XerwKhENqmuQ==",
        "X-Gm-Gg": "AeBDieuEc8fwSrbDFQcC8h8nECkwDupmtqMDghANgyD357/1CEVUMMGRYzPf6G9+BRy\n uyjiITr7u2Iqr9oNodCkxdkqa98OP5fCnBR13yKjKnLLgHpaQBxvE9ZEqr88N5+/RCglsHzyaFl\n Czedjm6oUByLNRPD+Hj1Y9NHO6fTGpS7bkkHLfYm36BTia3iPRPxq+PyZBHMDEE6q+9rMaTg4Fa\n u3BKjcrojyGrJ5rP8QJfnTI8VX/knyKRAqqlV4vSZFEY60JvIljPr0flcYbHmxceoLWEHR5+X3o\n o5/N0sRvEBbnvQtqB+wRlYKdEZJNwQ+F6Rlkset9U8C7dHxtAyCEP22fWIuqYANBGNC3tn/b8CA\n gjZCH1LkGU+mIJAysdhjUkiwvUV46/o3VdsS/un2uBwTg",
        "X-Received": [
            "by 2002:ac8:7d88:0:b0:50d:6acb:42db with SMTP id\n d75a77b69052e-50d6acb4a89mr300089221cf.23.1775667377350;\n Wed, 08 Apr 2026 09:56:17 -0700 (PDT)",
            "by 2002:ac8:7d88:0:b0:50d:6acb:42db with SMTP id\n d75a77b69052e-50d6acb4a89mr300088321cf.23.1775667376464;\n Wed, 08 Apr 2026 09:56:16 -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 10/14] migration: Introduce a helper to return switchover bw\n estimate",
        "Date": "Wed,  8 Apr 2026 12:55:54 -0400",
        "Message-ID": "<20260408165559.157108-11-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": "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 57d91ad9e3..a1a02e3a9f 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": [
        "10/14"
    ]
}