get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2194220,
    "url": "http://patchwork.ozlabs.org/api/patches/2194220/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260207134728.1495932-2-lulu@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/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": "<20260207134728.1495932-2-lulu@redhat.com>",
    "list_archive_url": null,
    "date": "2026-02-07T13:47:18",
    "name": "[02/12] net/filter-mirror: add enable_when_stopped option for filter-redirector",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "9f7c6002ba29382293d97b1c62ae1d3a90d00ad0",
    "submitter": {
        "id": 78960,
        "url": "http://patchwork.ozlabs.org/api/people/78960/?format=api",
        "name": "Cindy Lu",
        "email": "lulu@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260207134728.1495932-2-lulu@redhat.com/mbox/",
    "series": [
        {
            "id": 491379,
            "url": "http://patchwork.ozlabs.org/api/series/491379/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=491379",
            "date": "2026-02-07T13:47:17",
            "name": "[01/12] net: introduce read_poll/write_poll",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/491379/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2194220/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2194220/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=Lk7ChEJO;\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 (lists.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 4f7XNc1q4nz1xtV\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 08 Feb 2026 00:48:32 +1100 (AEDT)",
            "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 1voifU-000322-VV; Sat, 07 Feb 2026 08:48:13 -0500",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <lulu@redhat.com>) id 1voifH-00030I-5B\n for qemu-devel@nongnu.org; Sat, 07 Feb 2026 08:48:01 -0500",
            "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 <lulu@redhat.com>) id 1voifD-0003Cz-Uq\n for qemu-devel@nongnu.org; Sat, 07 Feb 2026 08:47:57 -0500",
            "from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-278-wAzO-Ss-O8CnEKWLz-o4NA-1; Sat,\n 07 Feb 2026 08:47:51 -0500",
            "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id BD8841956088; Sat,  7 Feb 2026 13:47:49 +0000 (UTC)",
            "from S2.redhat.com (unknown [10.72.112.15])\n by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 9D11618004BB; Sat,  7 Feb 2026 13:47:46 +0000 (UTC)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1770472074;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=9BUF9iLC/0WaAbCVNT/90vV7XGl20ndC7+Sq52C3rWQ=;\n b=Lk7ChEJOqRXluJxkKCQVFUMaEIMjc2QzNLNw/CL/pFSQu1XfOm9d0zrk2KrcXZjzlQI1vq\n Nq34TxPqn6YOPZ7BM8WGNKm20yyl9KBXefKdcfaWuAx9sjv73KmK41zJdVdT64yIELKVdR\n oyxkMlEk1SAHmjVYznLEtQXAuW8l/Wg=",
        "X-MC-Unique": "wAzO-Ss-O8CnEKWLz-o4NA-1",
        "X-Mimecast-MFC-AGG-ID": "wAzO-Ss-O8CnEKWLz-o4NA_1770472070",
        "From": "Cindy Lu <lulu@redhat.com>",
        "To": "lulu@redhat.com, mst@redhat.com, jasowang@redhat.com, zhangckid@gmail.com,\n lizhijian@fujitsu.com, qemu-devel@nongnu.org",
        "Subject": "[PATCH 02/12] net/filter-mirror: add enable_when_stopped option for\n filter-redirector",
        "Date": "Sat,  7 Feb 2026 21:47:18 +0800",
        "Message-ID": "<20260207134728.1495932-2-lulu@redhat.com>",
        "In-Reply-To": "<20260207134728.1495932-1-lulu@redhat.com>",
        "References": "<20260207134728.1495932-1-lulu@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93",
        "Received-SPF": "pass client-ip=170.10.133.124; envelope-from=lulu@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_H2=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": "From: Jason Wang <jasowang@redhat.com>\n\nAdd a QAPI option 'enable_when_stopped' for filter-redirector that\nallows it to continue receiving data from netdev when VM is stopped.\n\nWhen enabled, a VM state change handler activates the netdev's\nread_poll() when VM stops, allowing the netdev to continue reading\ndata and passing it through filter-redirector to the chardev output.\n\nThis is useful for scenarios where filter-redirector needs to\nprocess network traffic even when the VM is paused.\n\nUsage:\n  -object filter-redirector,id=f0,netdev=net0,queue=tx,\\\n          outdev=chardev0,enable_when_stopped=true\n\nSigned-off-by: Jason Wang <jasowang@redhat.com>\nSigned-off-by: Cindy Lu <lulu@redhat.com>\n---\n net/filter-mirror.c                  |  38 ++++++++++\n qapi/qom.json                        |   7 +-\n tests/qtest/test-filter-redirector.c | 106 +++++++++++++++++++++++++++\n 3 files changed, 150 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/net/filter-mirror.c b/net/filter-mirror.c\nindex aa2ab452fd..e1a0650abd 100644\n--- a/net/filter-mirror.c\n+++ b/net/filter-mirror.c\n@@ -21,6 +21,7 @@\n #include \"qemu/iov.h\"\n #include \"qemu/sockets.h\"\n #include \"block/aio-wait.h\"\n+#include \"system/runstate.h\"\n \n #define TYPE_FILTER_MIRROR \"filter-mirror\"\n typedef struct MirrorState MirrorState;\n@@ -41,6 +42,8 @@ struct MirrorState {\n     CharFrontend chr_out;\n     SocketReadState rs;\n     bool vnet_hdr;\n+    bool enable_when_stopped;\n+    VMChangeStateEntry *vmsentry;\n };\n \n typedef struct FilterSendCo {\n@@ -251,6 +254,7 @@ static void filter_redirector_cleanup(NetFilterState *nf)\n \n     qemu_chr_fe_deinit(&s->chr_in, false);\n     qemu_chr_fe_deinit(&s->chr_out, false);\n+    qemu_del_vm_change_state_handler(s->vmsentry);\n }\n \n static void filter_mirror_setup(NetFilterState *nf, Error **errp)\n@@ -282,6 +286,18 @@ static void redirector_rs_finalize(SocketReadState *rs)\n     redirector_to_filter(nf, rs->buf, rs->packet_len);\n }\n \n+static void filter_redirector_vm_state_change(void *opaque, bool running,\n+                                              RunState state)\n+{\n+    NetFilterState *nf = opaque;\n+    MirrorState *s = FILTER_REDIRECTOR(nf);\n+    NetClientState *nc = nf->netdev;\n+\n+    if (!running && s->enable_when_stopped && nc->info->read_poll) {\n+        nc->info->read_poll(nc, true);\n+    }\n+}\n+\n static void filter_redirector_setup(NetFilterState *nf, Error **errp)\n {\n     MirrorState *s = FILTER_REDIRECTOR(nf);\n@@ -331,6 +347,9 @@ static void filter_redirector_setup(NetFilterState *nf, Error **errp)\n             return;\n         }\n     }\n+\n+    s->vmsentry = qemu_add_vm_change_state_handler(\n+        filter_redirector_vm_state_change, nf);\n }\n \n static void filter_redirector_status_changed(NetFilterState *nf, Error **errp)\n@@ -437,6 +456,22 @@ static void filter_redirector_set_vnet_hdr(Object *obj,\n     s->vnet_hdr = value;\n }\n \n+static bool filter_redirector_get_enable_when_stopped(Object *obj, Error **errp)\n+{\n+    MirrorState *s = FILTER_REDIRECTOR(obj);\n+\n+    return s->enable_when_stopped;\n+}\n+\n+static void filter_redirector_set_enable_when_stopped(Object *obj,\n+                                                      bool value,\n+                                                      Error **errp)\n+{\n+    MirrorState *s = FILTER_REDIRECTOR(obj);\n+\n+    s->enable_when_stopped = value;\n+}\n+\n static void filter_mirror_class_init(ObjectClass *oc, const void *data)\n {\n     NetFilterClass *nfc = NETFILTER_CLASS(oc);\n@@ -463,6 +498,9 @@ static void filter_redirector_class_init(ObjectClass *oc, const void *data)\n     object_class_property_add_bool(oc, \"vnet_hdr_support\",\n                                    filter_redirector_get_vnet_hdr,\n                                    filter_redirector_set_vnet_hdr);\n+    object_class_property_add_bool(oc, \"enable_when_stopped\",\n+                                   filter_redirector_get_enable_when_stopped,\n+                                   filter_redirector_set_enable_when_stopped);\n \n     nfc->setup = filter_redirector_setup;\n     nfc->cleanup = filter_redirector_cleanup;\ndiff --git a/qapi/qom.json b/qapi/qom.json\nindex 6f5c9de0f0..b1fe55944c 100644\n--- a/qapi/qom.json\n+++ b/qapi/qom.json\n@@ -488,13 +488,18 @@\n # @vnet_hdr_support: if true, vnet header support is enabled\n #     (default: false)\n #\n+# @enable_when_stopped: if true, activate netdev's read poll when VM\n+#     stops to allow filter-redirector to continue receiving data\n+#     (default: false)\n+#\n # Since: 2.6\n ##\n { 'struct': 'FilterRedirectorProperties',\n   'base': 'NetfilterProperties',\n   'data': { '*indev': 'str',\n             '*outdev': 'str',\n-            '*vnet_hdr_support': 'bool' } }\n+            '*vnet_hdr_support': 'bool',\n+            '*enable_when_stopped': 'bool' } }\n \n ##\n # @FilterRewriterProperties:\ndiff --git a/tests/qtest/test-filter-redirector.c b/tests/qtest/test-filter-redirector.c\nindex 5540c232c0..fa958bb0a5 100644\n--- a/tests/qtest/test-filter-redirector.c\n+++ b/tests/qtest/test-filter-redirector.c\n@@ -385,6 +385,110 @@ static void test_redirector_init_status_off(void)\n     qtest_quit(qts);\n }\n \n+/*\n+ * Test filter-redirector works when VM is stopped (TX direction).\n+ *\n+ * This test verifies that when VM is stopped, the filter-redirector\n+ * can still receive data from the netdev because the VM state change\n+ * handler activates the netdev's read_poll(). Data flows from netdev\n+ * to filter-redirector and out through the chardev.\n+ *\n+ * Data flow: backend_sock -> netdev (read_poll) -> filter-redirector -> chardev\n+ */\n+static void test_redirector_with_vm_stop(void)\n+{\n+    int backend_sock[2], recv_sock;\n+    uint32_t ret = 0, len = 0;\n+    char send_buf[] = \"Hello!!\";\n+    char sock_path0[] = \"filter-redirector0.XXXXXX\";\n+    char *recv_buf;\n+    uint32_t size = sizeof(send_buf);\n+    size = htonl(size);\n+    QTestState *qts;\n+    struct timeval tv;\n+    fd_set rfds;\n+\n+    ret = socketpair(PF_UNIX, SOCK_STREAM, 0, backend_sock);\n+    g_assert_cmpint(ret, !=, -1);\n+\n+    ret = mkstemp(sock_path0);\n+    g_assert_cmpint(ret, !=, -1);\n+\n+    /*\n+     * Setup TX path: netdev -> filter-redirector -> chardev\n+     * Data sent to backend_sock[0] will be read by the netdev,\n+     * passed through filter-redirector, and output to sock_path0.\n+     * Enable enable_when_stopped to activate read_poll when VM stops.\n+     */\n+    qts = qtest_initf(\n+        \"-nic socket,id=qtest-bn0,fd=%d \"\n+        \"-chardev socket,id=redirector0,path=%s,server=on,wait=off \"\n+        \"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,\"\n+        \"queue=tx,outdev=redirector0,enable_when_stopped=true \",\n+        backend_sock[1], sock_path0);\n+\n+    recv_sock = unix_connect(sock_path0, NULL);\n+    g_assert_cmpint(recv_sock, !=, -1);\n+\n+    /* Ensure connection is established */\n+    qtest_qmp_assert_success(qts, \"{ 'execute' : 'query-status'}\");\n+\n+    struct iovec iov[] = {\n+        {\n+            .iov_base = &size,\n+            .iov_len = sizeof(size),\n+        }, {\n+            .iov_base = send_buf,\n+            .iov_len = sizeof(send_buf),\n+        },\n+    };\n+\n+    /*\n+     * Stop the VM - this triggers our vm_state_change handler\n+     * which should activate the netdev's read_poll()\n+     */\n+    qtest_qmp_assert_success(qts, \"{ 'execute' : 'stop'}\");\n+\n+    /* Wait for VM to actually stop */\n+    qtest_qmp_eventwait(qts, \"STOP\");\n+\n+    /*\n+     * Send data to backend socket while VM is stopped.\n+     * The netdev should still read the data (because read_poll is\n+     * activated by our vm_state_change handler), pass it through\n+     * filter-redirector, and output to the chardev.\n+     */\n+    ret = iov_send(backend_sock[0], iov, 2, 0, sizeof(size) + sizeof(send_buf));\n+    g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));\n+\n+    /*\n+     * Data should arrive at recv_sock even with VM stopped,\n+     * because read_poll is activated.\n+     */\n+    FD_ZERO(&rfds);\n+    FD_SET(recv_sock, &rfds);\n+    tv.tv_sec = 5;\n+    tv.tv_usec = 0;\n+    ret = select(recv_sock + 1, &rfds, NULL, NULL, &tv);\n+    g_assert_cmpint(ret, ==, 1);  /* Data should arrive */\n+\n+    ret = recv(recv_sock, &len, sizeof(len), 0);\n+    g_assert_cmpint(ret, ==, sizeof(len));\n+    len = ntohl(len);\n+\n+    g_assert_cmpint(len, ==, sizeof(send_buf));\n+    recv_buf = g_malloc(len);\n+    ret = recv(recv_sock, recv_buf, len, 0);\n+    g_assert_cmpint(ret, ==, len);\n+    g_assert_cmpstr(recv_buf, ==, send_buf);\n+\n+    g_free(recv_buf);\n+    close(recv_sock);\n+    close(backend_sock[0]);\n+    unlink(sock_path0);\n+    qtest_quit(qts);\n+}\n+\n static void test_redirector_rx_event_opened(void)\n {\n     int backend_sock[2], send_sock;\n@@ -489,5 +593,7 @@ int main(int argc, char **argv)\n                    test_redirector_init_status_off);\n     qtest_add_func(\"/netfilter/redirector_rx_event_opened\",\n                    test_redirector_rx_event_opened);\n+    qtest_add_func(\"/netfilter/redirector_with_vm_stop\",\n+                   test_redirector_with_vm_stop);\n     return g_test_run();\n }\n",
    "prefixes": [
        "02/12"
    ]
}