get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1839957,
    "url": "http://patchwork.ozlabs.org/api/patches/1839957/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20230926224107.2951144-2-jonah.palmer@oracle.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": "<20230926224107.2951144-2-jonah.palmer@oracle.com>",
    "list_archive_url": null,
    "date": "2023-09-26T22:41:05",
    "name": "[RESEND,v5,1/3] qmp: remove virtio_list, search QOM tree instead",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "87913dd446fba7b8eace2f6efd57cfc9fc49f719",
    "submitter": {
        "id": 81365,
        "url": "http://patchwork.ozlabs.org/api/people/81365/?format=api",
        "name": "Jonah Palmer",
        "email": "jonah.palmer@oracle.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20230926224107.2951144-2-jonah.palmer@oracle.com/mbox/",
    "series": [
        {
            "id": 375011,
            "url": "http://patchwork.ozlabs.org/api/series/375011/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=375011",
            "date": "2023-09-26T22:41:04",
            "name": "qmp, vhost-user: Remove virtio_list & update virtio introspection",
            "version": 5,
            "mbox": "http://patchwork.ozlabs.org/series/375011/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1839957/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1839957/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 (2048-bit key;\n unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256\n header.s=corp-2023-03-30 header.b=kvd71qoB;\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 4RwFB04hdYz1ypS\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 27 Sep 2023 08:42:31 +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 1qlGk9-0005xQ-0N; Tue, 26 Sep 2023 18:41:25 -0400",
            "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 <jonah.palmer@oracle.com>)\n id 1qlGk8-0005xB-5J\n for qemu-devel@nongnu.org; Tue, 26 Sep 2023 18:41:24 -0400",
            "from mx0a-00069f02.pphosted.com ([205.220.165.32])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <jonah.palmer@oracle.com>)\n id 1qlGk6-0005Tw-5i\n for qemu-devel@nongnu.org; Tue, 26 Sep 2023 18:41:23 -0400",
            "from pps.filterd (m0246617.ppops.net [127.0.0.1])\n by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 38QLTIi7011161; Tue, 26 Sep 2023 22:41:15 GMT",
            "from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com\n (phxpaimrmta02.appoci.oracle.com [147.154.114.232])\n by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t9rjug2cj-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Tue, 26 Sep 2023 22:41:15 +0000",
            "from pps.filterd\n (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1])\n by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19)\n with ESMTP id 38QKvGu9003238; Tue, 26 Sep 2023 22:41:14 GMT",
            "from pps.reinject (localhost [127.0.0.1])\n by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id\n 3t9pf74c8c-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n Tue, 26 Sep 2023 22:41:14 +0000",
            "from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com\n (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1])\n by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 38QMfBNn022981;\n Tue, 26 Sep 2023 22:41:14 GMT",
            "from jonah-ol8.us.oracle.com (dhcp-10-65-186-167.vpn.oracle.com\n [10.65.186.167])\n by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id\n 3t9pf74c6n-2; Tue, 26 Sep 2023 22:41:13 +0000"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type : content-transfer-encoding; s=corp-2023-03-30;\n bh=w5etLEMISJG2qsLVhiZMoZtWwzuiDUc38taoQ2VP56Q=;\n b=kvd71qoBiTf2qw1+icOSq469R8SGmwEZwvBQJBhklUrcF+6qPJJBQjpnpOqZPq8oVDWX\n yXRN6sWXXnGh5A8ArAynAVAxeGGSLY0HyxUMHiJCjBhzj5GYqhez7uVa5AwSk5L7kvHO\n umS2lfYCKsAImkgV/jj6sGnX+Xsey+vIV305cuLneT5sPEGvw0929eEMC08xsIOum7DD\n 0ozIpFFys3jw/iCaNDAVHh+FRnhNY9ORA6RuoBDvggfaW84Kpp4RoPBfIGJvgGIxGj3G\n sL7YNYCTx4vNcMPEw+oy9HyPcg0Kja0/IDzIyseUiiJ8PSN/+jPLt06+g/9IeZk9J2ag OA==",
        "From": "Jonah Palmer <jonah.palmer@oracle.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "philmd@linaro.org, laurent@vivier.eu, mst@redhat.com,\n boris.ostrovsky@oracle.com, alex.bennee@linaro.org,\n viresh.kumar@linaro.org, armbru@redhat.com, pbonzini@redhat.com,\n berrange@redhat.com, eduardo@habkost.net, jonah.palmer@oracle.com",
        "Subject": "[PATCH RESEND v5 1/3] qmp: remove virtio_list,\n search QOM tree instead",
        "Date": "Tue, 26 Sep 2023 18:41:05 -0400",
        "Message-Id": "<20230926224107.2951144-2-jonah.palmer@oracle.com>",
        "X-Mailer": "git-send-email 2.39.3",
        "In-Reply-To": "<20230926224107.2951144-1-jonah.palmer@oracle.com>",
        "References": "<20230926224107.2951144-1-jonah.palmer@oracle.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26\n definitions=2023-09-26_15,2023-09-26_01,2023-05-22_02",
        "X-Proofpoint-Spam-Details": "rule=notspam policy=default score=0 phishscore=0\n bulkscore=0 mlxscore=0\n adultscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0\n classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000\n definitions=main-2309260194",
        "X-Proofpoint-ORIG-GUID": "pA8a2dpM6e2C6hJH1zzBNef-vd5KUDuc",
        "X-Proofpoint-GUID": "pA8a2dpM6e2C6hJH1zzBNef-vd5KUDuc",
        "Received-SPF": "pass client-ip=205.220.165.32;\n envelope-from=jonah.palmer@oracle.com; helo=mx0a-00069f02.pphosted.com",
        "X-Spam_score_int": "-26",
        "X-Spam_score": "-2.7",
        "X-Spam_bar": "--",
        "X-Spam_report": "(-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001,\n URIBL_SBL_A=0.1 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-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": "The virtio_list duplicates information about virtio devices that already\nexist in the QOM composition tree. Instead of creating this list of\nrealized virtio devices, search the QOM composition tree instead.\n\nThis patch modifies the QMP command qmp_x_query_virtio to instead\nrecursively search the QOM composition tree for devices of type\n'TYPE_VIRTIO_DEVICE'. The device is also checked to ensure it's\nrealized.\n\nSigned-off-by: Jonah Palmer <jonah.palmer@oracle.com>\nReviewed-by: Daniel P. Berrangé <berrange@redhat.com>\n---\n hw/virtio/virtio-qmp.c | 85 ++++++++++++++----------------------------\n hw/virtio/virtio-qmp.h |  7 ----\n hw/virtio/virtio.c     |  6 ---\n 3 files changed, 29 insertions(+), 69 deletions(-)",
    "diff": "diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c\nindex 7515b0947b..adebf87e9b 100644\n--- a/hw/virtio/virtio-qmp.c\n+++ b/hw/virtio/virtio-qmp.c\n@@ -667,70 +667,43 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bitmap)\n     return features;\n }\n \n+static int query_dev_child(Object *child, void *opaque)\n+{\n+    VirtioInfoList **vdevs = opaque;\n+    Object *dev = object_dynamic_cast(child, TYPE_VIRTIO_DEVICE);\n+    if (dev != NULL && DEVICE(dev)->realized) {\n+        VirtIODevice *vdev = VIRTIO_DEVICE(dev);\n+        VirtioInfo *info = g_new(VirtioInfo, 1);\n+\n+        /* Get canonical path & name of device */\n+        info->path = object_get_canonical_path(dev);\n+        info->name = g_strdup(vdev->name);\n+        QAPI_LIST_PREPEND(*vdevs, info);\n+    }\n+    return 0;\n+}\n+\n VirtioInfoList *qmp_x_query_virtio(Error **errp)\n {\n-    VirtioInfoList *list = NULL;\n-    VirtioInfo *node;\n-    VirtIODevice *vdev;\n+    VirtioInfoList *vdevs = NULL;\n \n-    QTAILQ_FOREACH(vdev, &virtio_list, next) {\n-        DeviceState *dev = DEVICE(vdev);\n-        Error *err = NULL;\n-        QObject *obj = qmp_qom_get(dev->canonical_path, \"realized\", &err);\n-\n-        if (err == NULL) {\n-            GString *is_realized = qobject_to_json_pretty(obj, true);\n-            /* virtio device is NOT realized, remove it from list */\n-            if (!strncmp(is_realized->str, \"false\", 4)) {\n-                QTAILQ_REMOVE(&virtio_list, vdev, next);\n-            } else {\n-                node = g_new(VirtioInfo, 1);\n-                node->path = g_strdup(dev->canonical_path);\n-                node->name = g_strdup(vdev->name);\n-                QAPI_LIST_PREPEND(list, node);\n-            }\n-           g_string_free(is_realized, true);\n-        }\n-        qobject_unref(obj);\n+    /* Query the QOM composition tree recursively for virtio devices */\n+    object_child_foreach_recursive(object_get_root(), query_dev_child, &vdevs);\n+    if (vdevs == NULL) {\n+        error_setg(errp, \"No virtio devices found\");\n     }\n-\n-    return list;\n+    return vdevs;\n }\n \n VirtIODevice *qmp_find_virtio_device(const char *path)\n {\n-    VirtIODevice *vdev;\n-\n-    QTAILQ_FOREACH(vdev, &virtio_list, next) {\n-        DeviceState *dev = DEVICE(vdev);\n-\n-        if (strcmp(dev->canonical_path, path) != 0) {\n-            continue;\n-        }\n-\n-        Error *err = NULL;\n-        QObject *obj = qmp_qom_get(dev->canonical_path, \"realized\", &err);\n-        if (err == NULL) {\n-            GString *is_realized = qobject_to_json_pretty(obj, true);\n-            /* virtio device is NOT realized, remove it from list */\n-            if (!strncmp(is_realized->str, \"false\", 4)) {\n-                g_string_free(is_realized, true);\n-                qobject_unref(obj);\n-                QTAILQ_REMOVE(&virtio_list, vdev, next);\n-                return NULL;\n-            }\n-            g_string_free(is_realized, true);\n-        } else {\n-            /* virtio device doesn't exist in QOM tree */\n-            QTAILQ_REMOVE(&virtio_list, vdev, next);\n-            qobject_unref(obj);\n-            return NULL;\n-        }\n-        /* device exists in QOM tree & is realized */\n-        qobject_unref(obj);\n-        return vdev;\n+    /* Verify the canonical path is a realized virtio device */\n+    Object *dev = object_dynamic_cast(object_resolve_path(path, NULL),\n+                                      TYPE_VIRTIO_DEVICE);\n+    if (!dev || !DEVICE(dev)->realized) {\n+        return NULL;\n     }\n-    return NULL;\n+    return VIRTIO_DEVICE(dev);\n }\n \n VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)\n@@ -740,7 +713,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp)\n \n     vdev = qmp_find_virtio_device(path);\n     if (vdev == NULL) {\n-        error_setg(errp, \"Path %s is not a VirtIODevice\", path);\n+        error_setg(errp, \"Path %s is not a realized VirtIODevice\", path);\n         return NULL;\n     }\n \ndiff --git a/hw/virtio/virtio-qmp.h b/hw/virtio/virtio-qmp.h\nindex 8af5f5e65a..245a446a56 100644\n--- a/hw/virtio/virtio-qmp.h\n+++ b/hw/virtio/virtio-qmp.h\n@@ -15,13 +15,6 @@\n #include \"hw/virtio/virtio.h\"\n #include \"hw/virtio/vhost.h\"\n \n-#include \"qemu/queue.h\"\n-\n-typedef QTAILQ_HEAD(QmpVirtIODeviceList, VirtIODevice) QmpVirtIODeviceList;\n-\n-/* QAPI list of realized VirtIODevices */\n-extern QmpVirtIODeviceList virtio_list;\n-\n VirtIODevice *qmp_find_virtio_device(const char *path);\n VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap);\n VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap);\ndiff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c\nindex 4577f3f5b3..6df5d9bec6 100644\n--- a/hw/virtio/virtio.c\n+++ b/hw/virtio/virtio.c\n@@ -45,8 +45,6 @@\n #include \"standard-headers/linux/virtio_mem.h\"\n #include \"standard-headers/linux/virtio_vsock.h\"\n \n-QmpVirtIODeviceList virtio_list;\n-\n /*\n  * Maximum size of virtio device config space\n  */\n@@ -3651,7 +3649,6 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)\n     vdev->listener.commit = virtio_memory_listener_commit;\n     vdev->listener.name = \"virtio\";\n     memory_listener_register(&vdev->listener, vdev->dma_as);\n-    QTAILQ_INSERT_TAIL(&virtio_list, vdev, next);\n }\n \n static void virtio_device_unrealize(DeviceState *dev)\n@@ -3666,7 +3663,6 @@ static void virtio_device_unrealize(DeviceState *dev)\n         vdc->unrealize(dev);\n     }\n \n-    QTAILQ_REMOVE(&virtio_list, vdev, next);\n     g_free(vdev->bus_name);\n     vdev->bus_name = NULL;\n }\n@@ -3840,8 +3836,6 @@ static void virtio_device_class_init(ObjectClass *klass, void *data)\n     vdc->stop_ioeventfd = virtio_device_stop_ioeventfd_impl;\n \n     vdc->legacy_features |= VIRTIO_LEGACY_FEATURES;\n-\n-    QTAILQ_INIT(&virtio_list);\n }\n \n bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev)\n",
    "prefixes": [
        "RESEND",
        "v5",
        "1/3"
    ]
}