get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2225924,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/2225924/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260421202110.306051-5-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-5-peterx@redhat.com>",
    "list_archive_url": null,
    "date": "2026-04-21T20:20:58",
    "name": "[v2,04/16] vfio/migration: Cache stop size in VFIOMigration",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "a51d0922f84fcaebd5fae0382030c5cc2befa9d4",
    "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-5-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/2225924/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2225924/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=AGZv7/xv;\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=NcjKn/IT;\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 4g0Yg44cQ7z1yGs\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 06:22:08 +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 1wFHbC-0000yE-QX; Tue, 21 Apr 2026 16:21:35 -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 1wFHb3-0000wR-Fd\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:26 -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 1wFHb1-0008M3-3l\n for qemu-devel@nongnu.org; Tue, 21 Apr 2026 16:21:24 -0400",
            "from mail-qv1-f71.google.com (mail-qv1-f71.google.com\n [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-280-qgbagd24OwCFHrYoiY79lQ-1; Tue, 21 Apr 2026 16:21:21 -0400",
            "by mail-qv1-f71.google.com with SMTP id\n 6a1803df08f44-8ac9609d3d6so123117436d6.0\n for <qemu-devel@nongnu.org>; Tue, 21 Apr 2026 13:21:21 -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.18\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 21 Apr 2026 13:21:18 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776802882;\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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=;\n b=AGZv7/xvKsSGsMKKvV3wgfPJj6ALuqXRMIKbGlqCn2tA6n0E0orHKsq0n2H/Fyz/IiU7mJ\n do9ooaLEHDmCnRYvIyU30cKwSjZdprmb5+IyFETIoY0l1doxxbTF/mXibpDjKFxJTHq4Be\n P/9dL24DDP4czrpUNKnYDzAY6jAP9zc=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1776802880; x=1777407680; 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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=;\n b=NcjKn/ITK6k1XdFp+U/VdSl9W7IwwmjJKCYGSvTCdfT+tpe1B3GRVM+3+LtbuADgEw\n AtHvIPBaceU+Nffau9orxVjgb5HseNjymryaEjLrUgAr7nut3PHkLxBkJFlvm6CFyhNv\n x90iLiMtgaqowmXTblq3DDBSxccHNxU4HCgQPTsrzJhkwnzA4tBNPfVbxwK5dQXltOye\n rnvcQh5bUZUiJ1PpMFjk3joTLNKX4KIMvL+vn4at2nB8MQZLeHtpuXDcdkTVQbnYS0qn\n 8gmix8cwkQhS9KJxhwC3q2szSw7ZPLlx2gFk4MOoW3r2Xy8KRkE5xUA765ANZQsOeWgs\n szDA=="
        ],
        "X-MC-Unique": "qgbagd24OwCFHrYoiY79lQ-1",
        "X-Mimecast-MFC-AGG-ID": "qgbagd24OwCFHrYoiY79lQ_1776802881",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776802880; x=1777407680;\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=TbQkWYzWJZ1O2pLi9yPiyFUNUWcVz6fI8AXsfo7wY1s=;\n b=bGPvRmW02NyD1/jJnmPS0BRLh3tvyZpd+8Hzy7iDx9uNoKmDNwBbjMo+/nkjTelG/9\n PetrqoMwLkOjkNT6TgAyrSX8WaSriLPCvFidSfJWFaVwfTVOyDLcLhapTdk/moj+2Kof\n 8dAED5Wgc5DhAQmAwq5xZBIOoNljBW05fuqIT7+A35r7M0YEg2TMOJrdY0ZZYha6yf0G\n DIxg2XCjm1vmPMfbpHY9e6ygG9UQXnS7k0P9ZwMHcsefL/LKALJDPAo24IEKmwLcIMr6\n iyQwDjH7o+besi1GRyhw8FobhczWhAc7ck/REV1MBA/Ywk0mrRlje/JGFFhyDp0yGnvf\n K0Yw==",
        "X-Gm-Message-State": "AOJu0YyMyn9SK3NrARsrQgiFPfHgU2wNCFtcedRKOYnvlWDTgurj28Pn\n e/FePyOH73WYJVIK3geW0gHWdu2C6h5NZg5beaZl6G+NpZ9D7wClVtgk9/jewmH5gGBKMff2LMi\n YHrQMUoulj5/ARWd+SdGJJ017uPEs3sSPjDZWO5/sATQK4edPtKe23o48NUggIAbGfN0t8X2W+v\n dyb3w806d237S+vH0P3A2r48z0K9DUipaqKEICvA==",
        "X-Gm-Gg": "AeBDieuYfGSRvmwNCRIedepyDfF48Eg0cteQ6evtyAm2Upg98lsOt2YNfPYydcEB7HP\n bToIHgEFtPSyYipmwcPywz+rVVqaPNXRAglBHiyPiEqWzSM9tWvNZUWCReuxuKBtNKVCDY2h7TU\n k5NGEAm1DaU2NgoFkGcYhftSSPq7Yf7nj3zTiemUdDye2qFQjLyno5w/CpgIHM0cGcO25dBi1OO\n wpuFcy29kCikmmivKJGuUsEQdBRnf5ao5j8O71hIxF4O3sBmsicMKCaOwIwqx275oD7rdu/Ij34\n qIeQIIXK6l5tZmmB8C8CVi0sttFVAhnv0wA0dGyMjhW6wx4nPctLOaYYg70fE2gM+qDkVwbdIgj\n cd1+3gJibdBwS9C1MVRQsd4DfmKlvZbKIeIG4rLMQNVrBEzmwxfS98U1doA==",
        "X-Received": [
            "by 2002:a05:6214:cc1:b0:8ac:af40:53d5 with SMTP id\n 6a1803df08f44-8b02810fc05mr298319026d6.34.1776802879974;\n Tue, 21 Apr 2026 13:21:19 -0700 (PDT)",
            "by 2002:a05:6214:cc1:b0:8ac:af40:53d5 with SMTP id\n 6a1803df08f44-8b02810fc05mr298318086d6.34.1776802879194;\n Tue, 21 Apr 2026 13:21:19 -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 04/16] vfio/migration: Cache stop size in VFIOMigration",
        "Date": "Tue, 21 Apr 2026 16:20:58 -0400",
        "Message-ID": "<20260421202110.306051-5-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": "Add a field to cache stop size.  Note that there's an initial value change\nin vfio_save_setup for the stop size default, but it shouldn't matter if it\nis followed with a math of MIN() against VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE.\n\nDocument that all the three sizes we read from VFIO's uAPI on dirty or stop\nsizes are estimates, so QEMU needs to always remember they can be anything.\n\nReviewed-by: Avihai Horon <avihaih@nvidia.com>\nSigned-off-by: Peter Xu <peterx@redhat.com>\n---\n hw/vfio/vfio-migration-internal.h |  8 +++++\n hw/vfio/migration.c               | 50 ++++++++++++++++++-------------\n 2 files changed, 38 insertions(+), 20 deletions(-)",
    "diff": "diff --git a/hw/vfio/vfio-migration-internal.h b/hw/vfio/vfio-migration-internal.h\nindex 814fbd9eba..a15fc74703 100644\n--- a/hw/vfio/vfio-migration-internal.h\n+++ b/hw/vfio/vfio-migration-internal.h\n@@ -45,8 +45,16 @@ typedef struct VFIOMigration {\n     void *data_buffer;\n     size_t data_buffer_size;\n     uint64_t mig_flags;\n+    /*\n+     * NOTE: all three sizes cached are reported from VFIO's uAPI, which\n+     * are defined as estimate only.  QEMU should not trust these values\n+     * but only use them to do best-effort estimates.  Always be prepared\n+     * that these sizes may either grow or even shrink in reality while\n+     * read()ing from the VFIO fds.\n+     */\n     uint64_t precopy_init_size;\n     uint64_t precopy_dirty_size;\n+    uint64_t stopcopy_size;\n     bool multifd_transfer;\n     VFIOMultifd *multifd;\n     bool initial_data_sent;\ndiff --git a/hw/vfio/migration.c b/hw/vfio/migration.c\nindex 83327b6573..5d5fca09bd 100644\n--- a/hw/vfio/migration.c\n+++ b/hw/vfio/migration.c\n@@ -41,6 +41,12 @@\n  */\n #define VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE (1 * MiB)\n \n+/*\n+ * Migration size of VFIO devices can be as little as a few KBs or as big as\n+ * many GBs. This value should be big enough to cover the worst case.\n+ */\n+#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB)\n+\n static unsigned long bytes_transferred;\n \n static const char *mig_state_to_str(enum vfio_device_mig_state state)\n@@ -314,8 +320,7 @@ static void vfio_migration_cleanup(VFIODevice *vbasedev)\n     migration->data_fd = -1;\n }\n \n-static int vfio_query_stop_copy_size(VFIODevice *vbasedev,\n-                                     uint64_t *stop_copy_size)\n+static int vfio_query_stop_copy_size(VFIODevice *vbasedev)\n {\n     uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) +\n                               sizeof(struct vfio_device_feature_mig_data_size),\n@@ -323,16 +328,22 @@ static int vfio_query_stop_copy_size(VFIODevice *vbasedev,\n     struct vfio_device_feature *feature = (struct vfio_device_feature *)buf;\n     struct vfio_device_feature_mig_data_size *mig_data_size =\n         (struct vfio_device_feature_mig_data_size *)feature->data;\n+    VFIOMigration *migration = vbasedev->migration;\n \n     feature->argsz = sizeof(buf);\n     feature->flags =\n         VFIO_DEVICE_FEATURE_GET | VFIO_DEVICE_FEATURE_MIG_DATA_SIZE;\n \n     if (ioctl(vbasedev->fd, VFIO_DEVICE_FEATURE, feature)) {\n+        /*\n+         * If getting pending migration size fails, VFIO_MIG_STOP_COPY_SIZE\n+         * is reported so downtime limit won't be violated.\n+         */\n+        migration->stopcopy_size = VFIO_MIG_STOP_COPY_SIZE;\n         return -errno;\n     }\n \n-    *stop_copy_size = mig_data_size->stop_copy_length;\n+    migration->stopcopy_size = mig_data_size->stop_copy_length;\n \n     return 0;\n }\n@@ -409,6 +420,16 @@ static void vfio_update_estimated_pending_data(VFIOMigration *migration,\n         return;\n     }\n \n+    /*\n+     * The total size remaining requires separate accounting.  Do not trust\n+     * the counter, so what we have read() may be more than what reported.\n+     */\n+    if (migration->stopcopy_size > data_size) {\n+        migration->stopcopy_size -= data_size;\n+    } else {\n+        migration->stopcopy_size = 0;\n+    }\n+\n     if (migration->precopy_init_size) {\n         uint64_t init_size = MIN(migration->precopy_init_size, data_size);\n \n@@ -463,7 +484,6 @@ static int vfio_save_setup(QEMUFile *f, void *opaque, Error **errp)\n {\n     VFIODevice *vbasedev = opaque;\n     VFIOMigration *migration = vbasedev->migration;\n-    uint64_t stop_copy_size = VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE;\n     int ret;\n \n     if (!vfio_multifd_setup(vbasedev, false, errp)) {\n@@ -472,9 +492,9 @@ static int vfio_save_setup(QEMUFile *f, void *opaque, Error **errp)\n \n     qemu_put_be64(f, VFIO_MIG_FLAG_DEV_SETUP_STATE);\n \n-    vfio_query_stop_copy_size(vbasedev, &stop_copy_size);\n+    vfio_query_stop_copy_size(vbasedev);\n     migration->data_buffer_size = MIN(VFIO_MIG_DEFAULT_DATA_BUFFER_SIZE,\n-                                      stop_copy_size);\n+                                      migration->stopcopy_size);\n     migration->data_buffer = g_try_malloc0(migration->data_buffer_size);\n     if (!migration->data_buffer) {\n         error_setg(errp, \"%s: Failed to allocate migration data buffer\",\n@@ -570,32 +590,22 @@ static void vfio_state_pending_estimate(void *opaque, uint64_t *must_precopy,\n                                       migration->precopy_dirty_size);\n }\n \n-/*\n- * Migration size of VFIO devices can be as little as a few KBs or as big as\n- * many GBs. This value should be big enough to cover the worst case.\n- */\n-#define VFIO_MIG_STOP_COPY_SIZE (100 * GiB)\n-\n static void vfio_state_pending_exact(void *opaque, uint64_t *must_precopy,\n                                      uint64_t *can_postcopy)\n {\n     VFIODevice *vbasedev = opaque;\n     VFIOMigration *migration = vbasedev->migration;\n-    uint64_t stop_copy_size = VFIO_MIG_STOP_COPY_SIZE;\n \n-    /*\n-     * If getting pending migration size fails, VFIO_MIG_STOP_COPY_SIZE is\n-     * reported so downtime limit won't be violated.\n-     */\n-    vfio_query_stop_copy_size(vbasedev, &stop_copy_size);\n-    *must_precopy += stop_copy_size;\n+    vfio_query_stop_copy_size(vbasedev);\n+    *must_precopy += migration->stopcopy_size;\n \n     if (vfio_device_state_is_precopy(vbasedev)) {\n         vfio_query_precopy_size(migration);\n     }\n \n     trace_vfio_state_pending_exact(vbasedev->name, *must_precopy, *can_postcopy,\n-                                   stop_copy_size, migration->precopy_init_size,\n+                                   migration->stopcopy_size,\n+                                   migration->precopy_init_size,\n                                    migration->precopy_dirty_size);\n }\n \n",
    "prefixes": [
        "v2",
        "04/16"
    ]
}