get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2221616,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2221616/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260409213454.5186-1-matthieu@min.io/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/1.1/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": "<20260409213454.5186-1-matthieu@min.io>",
    "date": "2026-04-09T21:34:51",
    "name": "[v2] hw/nvme: add namespace hotplug support",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "089a6e1b9f1796a90356ea16f66613834e6a7dec",
    "submitter": {
        "id": 93098,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/93098/?format=api",
        "name": "Matthieu Rolla",
        "email": "matthieu@minio.io"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260409213454.5186-1-matthieu@min.io/mbox/",
    "series": [
        {
            "id": 499373,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/499373/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499373",
            "date": "2026-04-09T21:34:51",
            "name": "[v2] hw/nvme: add namespace hotplug support",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/499373/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2221616/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2221616/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 (2048-bit key;\n secure) header.d=minio.io header.i=@minio.io header.a=rsa-sha256\n header.s=minio header.b=QatAF1RC;\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 4fsHtF5C2Qz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 10:36:35 +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 1wAzqT-0005QF-Ou; Thu, 09 Apr 2026 20:35: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 <matthieu@minio.io>) id 1wAx1Y-00015p-9a\n for qemu-devel@nongnu.org; Thu, 09 Apr 2026 17:34:52 -0400",
            "from mail-wm1-x334.google.com ([2a00:1450:4864:20::334])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <matthieu@minio.io>) id 1wAx1W-0000pw-Aa\n for qemu-devel@nongnu.org; Thu, 09 Apr 2026 17:34:51 -0400",
            "by mail-wm1-x334.google.com with SMTP id\n 5b1f17b1804b1-488b0e1b870so19742495e9.2\n for <qemu-devel@nongnu.org>; Thu, 09 Apr 2026 14:34:49 -0700 (PDT)",
            "from localhost\n (2a01cb001411480071f5d8bdb591a8f9.ipv6.abo.wanadoo.fr.\n [2a01:cb00:1411:4800:71f5:d8bd:b591:a8f9])\n by smtp.gmail.com with UTF8SMTPSA id\n 5b1f17b1804b1-488d5888acbsm25725115e9.1.2026.04.09.14.34.47\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Thu, 09 Apr 2026 14:34:47 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=minio.io; s=minio; t=1775770489; x=1776375289; 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=KvcC0OHWydsrQ65Aj+iaZfcTmw/zkBxH7csPVJaQ8y0=;\n b=QatAF1RC3P7XbbCf/17g5ry7yzICj0+hfLui0ZGiMp6PNDGQ7XqdVfu6Kqq0IJ40e1\n sbkd0DzOa1x3GCtbvTHiJeCqClrkgyi+i03yLmrC0bugnp7tco9hsc3v9WeglvPFOzFs\n 2SsAfv98W9jnlD5J1vudhaipOg1/I+L+sDZ++RtbSZQcEcmU80kQ13cEaAufqAitpvbi\n wHSJtfkoypxT30MjdH1qgQ6SHUTr5fXNbMq0D6NmDTvJhDqabkJcUGsZYPGv+nmJ2s1M\n Qjme/mkxG9GaAKAOqOx2mRRp8FaTn9cka5kdqnCf2eadkE4TuGMu7b5dOHNBAqXOdQ0n\n jNBA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775770489; x=1776375289;\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=KvcC0OHWydsrQ65Aj+iaZfcTmw/zkBxH7csPVJaQ8y0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diudqdII964l4L0TWT\n 0hSylTxfeduknQFudIb5hmEUCLfaHF8HsCaEI6g4X4Me3BoEvpdZCOkhG8puXpYsZVP1SeSn5wR\n ncjBnzxEmEviFLrogfsl0tDyzevelko0ITujZogCmpaj9ZxEz1W17j0VgB2aw==",
        "X-Received": "by 2002:a05:600c:8b30:b0:488:b14f:b8ed with SMTP id\n 5b1f17b1804b1-488d6657928mr5875225e9.0.1775770488168;\n Thu, 09 Apr 2026 14:34:48 -0700 (PDT)",
        "From": "mr-083 <matthieu@minio.io>",
        "X-Google-Original-From": "mr-083 <matthieu@min.io>",
        "To": "qemu-devel@nongnu.org,\n\tqemu-block@nongnu.org",
        "Cc": "its@irrelevant.dk, kbusch@kernel.org, stefanha@redhat.com,\n mr-083 <matthieu@min.io>",
        "Subject": "[PATCH v2] hw/nvme: add namespace hotplug support",
        "Date": "Thu,  9 Apr 2026 23:34:51 +0200",
        "Message-ID": "<20260409213454.5186-1-matthieu@min.io>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260409060155.94704-1-matthieu@min.io>",
        "References": "<20260409060155.94704-1-matthieu@min.io>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=2a00:1450:4864:20::334;\n envelope-from=matthieu@minio.io; helo=mail-wm1-x334.google.com",
        "X-Spam_score_int": "-10",
        "X-Spam_score": "-1.1",
        "X-Spam_bar": "-",
        "X-Spam_report": "(-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n HK_NAME_MR_MRS=0.998,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=no autolearn_force=no",
        "X-Spam_action": "no action",
        "X-Mailman-Approved-At": "Thu, 09 Apr 2026 20:35:35 -0400",
        "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 hotplug support for nvme-ns devices on the NvmeBus. This enables\nnamespace-level hot-swap without removing the NVMe controller, matching\nthe behavior of physical NVMe drives hot-swapped in the same PCIe slot.\n\nMark nvme-ns devices as hotpluggable and register the NvmeBus as a\nhotplug handler with proper plug and unplug callbacks:\n\n- plug: attach namespace to all started controllers and send an\n  Asynchronous Event Notification (AEN) with NS_ATTR_CHANGED so\n  the guest kernel rescans namespaces and adds the block device\n- unplug: detach from all controllers, send AEN, remove from\n  subsystem, then unrealize the device. The guest kernel rescans\n  and removes the block device.\n\nThe plug handler skips controllers that haven't started yet\n(qs_created == false) to avoid interfering with boot-time namespace\nattachment in nvme_start_ctrl().\n\nBoth the controller bus and subsystem bus are configured as hotplug\nhandlers via qbus_set_bus_hotplug_handler() since nvme-ns devices\nmay reparent to the subsystem bus during realize.\n\nExample hot-swap sequence using the NVMe subsystem model:\n\n  # Boot with: -device nvme-subsys,id=subsys0\n  #            -device nvme,id=ctrl0,subsys=subsys0\n  #            -device nvme-ns,id=ns0,drive=drv0,bus=ctrl0,nsid=1\n\n  device_del ns0             # guest receives AEN, removes /dev/nvme0n1\n  drive_del drv0\n  drive_add 0 file=disk.qcow2,format=qcow2,id=drv0,if=none\n  device_add nvme-ns,id=ns0,drive=drv0,bus=ctrl0,nsid=1\n                              # guest receives AEN, adds /dev/nvme0n1\n\nTested with Linux 6.1 guest (NVMe driver processes AEN and rescans\nnamespace list automatically).\n\nSigned-off-by: Matthieu Receveur <matthieu@min.io>\n---\n hw/nvme/ctrl.c   | 85 ++++++++++++++++++++++++++++++++++++++++++++++++\n hw/nvme/ns.c     |  1 +\n hw/nvme/subsys.c |  2 ++\n 3 files changed, 88 insertions(+)",
    "diff": "diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c\nindex be6c7028cb..5502e4ea2b 100644\n--- a/hw/nvme/ctrl.c\n+++ b/hw/nvme/ctrl.c\n@@ -206,6 +206,7 @@\n #include \"system/hostmem.h\"\n #include \"hw/pci/msix.h\"\n #include \"hw/pci/pcie_sriov.h\"\n+#include \"hw/core/qdev.h\"\n #include \"system/spdm-socket.h\"\n #include \"migration/vmstate.h\"\n \n@@ -9293,6 +9294,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **errp)\n     }\n \n     qbus_init(&n->bus, sizeof(NvmeBus), TYPE_NVME_BUS, dev, dev->id);\n+    qbus_set_bus_hotplug_handler(BUS(&n->bus));\n \n     if (nvme_init_subsys(n, errp)) {\n         return;\n@@ -9553,10 +9555,93 @@ static const TypeInfo nvme_info = {\n     },\n };\n \n+static void nvme_ns_hot_plug(HotplugHandler *hotplug_dev, DeviceState *dev,\n+                              Error **errp)\n+{\n+    NvmeNamespace *ns = NVME_NS(dev);\n+    NvmeSubsystem *subsys = ns->subsys;\n+    uint32_t nsid = ns->params.nsid;\n+    int i;\n+\n+    /*\n+     * Attach to all started controllers and notify via AEN.\n+     * Skip controllers that haven't started yet (boot-time realize) —\n+     * nvme_start_ctrl() will attach namespaces during controller init.\n+     */\n+    for (i = 0; i < NVME_MAX_CONTROLLERS; i++) {\n+        NvmeCtrl *ctrl = nvme_subsys_ctrl(subsys, i);\n+        if (!ctrl || !ctrl->qs_created) {\n+            continue;\n+        }\n+\n+        if (nvme_csi_supported(ctrl, ns->csi) && !ns->params.detached) {\n+            nvme_attach_ns(ctrl, ns);\n+            nvme_update_dsm_limits(ctrl, ns);\n+\n+            if (!test_and_set_bit(nsid, ctrl->changed_nsids)) {\n+                nvme_enqueue_event(ctrl, NVME_AER_TYPE_NOTICE,\n+                                   NVME_AER_INFO_NOTICE_NS_ATTR_CHANGED,\n+                                   NVME_LOG_CHANGED_NSLIST);\n+            }\n+        }\n+    }\n+}\n+\n+static void nvme_ns_hot_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,\n+                               Error **errp)\n+{\n+    NvmeNamespace *ns = NVME_NS(dev);\n+    NvmeSubsystem *subsys = ns->subsys;\n+    uint32_t nsid = ns->params.nsid;\n+    int i;\n+\n+    /*\n+     * Detach from all controllers and notify the guest via AEN.\n+     * Must happen before unrealize to avoid use-after-free when the\n+     * guest sends I/O to a freed namespace.\n+     */\n+    for (i = 0; i < NVME_MAX_CONTROLLERS; i++) {\n+        NvmeCtrl *ctrl = nvme_subsys_ctrl(subsys, i);\n+        if (!ctrl || !nvme_ns(ctrl, nsid)) {\n+            continue;\n+        }\n+\n+        nvme_detach_ns(ctrl, ns);\n+        nvme_update_dsm_limits(ctrl, NULL);\n+\n+        if (!test_and_set_bit(nsid, ctrl->changed_nsids)) {\n+            nvme_enqueue_event(ctrl, NVME_AER_TYPE_NOTICE,\n+                               NVME_AER_INFO_NOTICE_NS_ATTR_CHANGED,\n+                               NVME_LOG_CHANGED_NSLIST);\n+        }\n+    }\n+\n+    /* Remove from subsystem namespace list. */\n+    subsys->namespaces[nsid] = NULL;\n+\n+    /*\n+     * Unrealize: drain I/O, flush, cleanup structures, remove from QOM.\n+     * nvme_ns_unrealize() handles drain/shutdown/cleanup internally.\n+     */\n+    qdev_unrealize(dev);\n+}\n+\n+static void nvme_bus_class_init(ObjectClass *klass, const void *data)\n+{\n+    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);\n+    hc->plug = nvme_ns_hot_plug;\n+    hc->unplug = nvme_ns_hot_unplug;\n+}\n+\n static const TypeInfo nvme_bus_info = {\n     .name = TYPE_NVME_BUS,\n     .parent = TYPE_BUS,\n     .instance_size = sizeof(NvmeBus),\n+    .class_init = nvme_bus_class_init,\n+    .interfaces = (const InterfaceInfo[]) {\n+        { TYPE_HOTPLUG_HANDLER },\n+        { }\n+    },\n };\n \n static void nvme_register_types(void)\ndiff --git a/hw/nvme/ns.c b/hw/nvme/ns.c\nindex b0106eaa5c..eb628c0734 100644\n--- a/hw/nvme/ns.c\n+++ b/hw/nvme/ns.c\n@@ -937,6 +937,7 @@ static void nvme_ns_class_init(ObjectClass *oc, const void *data)\n     dc->bus_type = TYPE_NVME_BUS;\n     dc->realize = nvme_ns_realize;\n     dc->unrealize = nvme_ns_unrealize;\n+    dc->hotpluggable = true;\n     device_class_set_props(dc, nvme_ns_props);\n     dc->desc = \"Virtual NVMe namespace\";\n }\ndiff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c\nindex 777e1c620f..fa35055d3c 100644\n--- a/hw/nvme/subsys.c\n+++ b/hw/nvme/subsys.c\n@@ -9,6 +9,7 @@\n #include \"qemu/osdep.h\"\n #include \"qemu/units.h\"\n #include \"qapi/error.h\"\n+#include \"hw/core/qdev.h\"\n \n #include \"nvme.h\"\n \n@@ -205,6 +206,7 @@ static void nvme_subsys_realize(DeviceState *dev, Error **errp)\n     NvmeSubsystem *subsys = NVME_SUBSYS(dev);\n \n     qbus_init(&subsys->bus, sizeof(NvmeBus), TYPE_NVME_BUS, dev, dev->id);\n+    qbus_set_bus_hotplug_handler(BUS(&subsys->bus));\n \n     nvme_subsys_setup(subsys, errp);\n }\n",
    "prefixes": [
        "v2"
    ]
}