get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 812234,
    "url": "http://patchwork.ozlabs.org/api/patches/812234/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1505202976-1784-4-git-send-email-changpeng.liu@intel.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": "<1505202976-1784-4-git-send-email-changpeng.liu@intel.com>",
    "list_archive_url": null,
    "date": "2017-09-12T07:56:15",
    "name": "[v3,3/4] contrib/libvhost-user: enable virtio config space messages",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "3dd58b648c9b3d152b8b208ad583bdd414e104fd",
    "submitter": {
        "id": 71275,
        "url": "http://patchwork.ozlabs.org/api/people/71275/?format=api",
        "name": "Liu, Changpeng",
        "email": "changpeng.liu@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/1505202976-1784-4-git-send-email-changpeng.liu@intel.com/mbox/",
    "series": [
        {
            "id": 2447,
            "url": "http://patchwork.ozlabs.org/api/series/2447/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2447",
            "date": "2017-09-12T07:56:15",
            "name": "*** Introduce a new vhost-user-blk host device to Qemu ***",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/2447/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/812234/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/812234/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@bilbo.ozlabs.org",
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrKWP3sYKz9s4q\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 17:37:04 +1000 (AEST)",
            "from localhost ([::1]:55947 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drJHB-0001Dr-KF\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 03:37:01 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:43355)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <changpeng.liu@intel.com>) id 1drJGV-0001DS-EF\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 03:36:20 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <changpeng.liu@intel.com>) id 1drJGT-0007eQ-GA\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 03:36:19 -0400",
            "from mga05.intel.com ([192.55.52.43]:49932)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <changpeng.liu@intel.com>)\n\tid 1drJGT-0007dn-4H\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 03:36:17 -0400",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby fmsmga105.fm.intel.com with ESMTP; 11 Sep 2017 00:36:14 -0700",
            "from fedora.sh.intel.com ([10.67.112.210])\n\tby orsmga004.jf.intel.com with ESMTP; 11 Sep 2017 00:36:08 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.42,376,1500966000\"; d=\"scan'208\";a=\"127495100\"",
        "From": "Changpeng Liu <changpeng.liu@intel.com>",
        "To": "changpeng.liu@intel.com,\n\tqemu-devel@nongnu.org",
        "Date": "Tue, 12 Sep 2017 15:56:15 +0800",
        "Message-Id": "<1505202976-1784-4-git-send-email-changpeng.liu@intel.com>",
        "X-Mailer": "git-send-email 1.9.3",
        "In-Reply-To": "<1505202976-1784-1-git-send-email-changpeng.liu@intel.com>",
        "References": "<1505202976-1784-1-git-send-email-changpeng.liu@intel.com>",
        "X-detected-operating-system": "by eggs.gnu.org: Genre and OS details not\n\trecognized.",
        "X-Received-From": "192.55.52.43",
        "Subject": "[Qemu-devel] [PATCH v3 3/4] contrib/libvhost-user: enable virtio\n\tconfig space messages",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://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\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "james.r.harris@intel.com, mst@redhat.com, stefanha@gmail.com,\n\tpbonzini@redhat.com, felipe@nutanix.com, marcandre.lureau@redhat.com",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "Enable VHOST_USER_GET_CONFIG/VHOST_USER_SET_CONFIG/VHOST_USER_SET_CONFIG_FD\nmessages in libvhost-user library, users can implement their own I/O target\nbased on the library. This enable the virtio config space delivered between\nQemu host device and the I/O target, also event notifier is added in case\nof virtio config space changed.\n\nSigned-off-by: Changpeng Liu <changpeng.liu@intel.com>\n---\n contrib/libvhost-user/libvhost-user.c | 74 +++++++++++++++++++++++++++++++++++\n contrib/libvhost-user/libvhost-user.h | 15 +++++++\n 2 files changed, 89 insertions(+)",
    "diff": "diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c\nindex d27d630..ff37d6b 100644\n--- a/contrib/libvhost-user/libvhost-user.c\n+++ b/contrib/libvhost-user/libvhost-user.c\n@@ -63,6 +63,9 @@ vu_request_to_string(int req)\n         REQ(VHOST_USER_SET_VRING_ENABLE),\n         REQ(VHOST_USER_SEND_RARP),\n         REQ(VHOST_USER_INPUT_GET_CONFIG),\n+        REQ(VHOST_USER_GET_CONFIG),\n+        REQ(VHOST_USER_SET_CONFIG),\n+        REQ(VHOST_USER_SET_CONFIG_FD),\n         REQ(VHOST_USER_MAX),\n     };\n #undef REQ\n@@ -757,6 +760,66 @@ vu_set_vring_enable_exec(VuDev *dev, VhostUserMsg *vmsg)\n }\n \n static bool\n+vu_get_config(VuDev *dev, VhostUserMsg *vmsg)\n+{\n+    int ret = -1;\n+\n+    if (dev->iface->get_config) {\n+        ret = dev->iface->get_config(dev, vmsg->payload.config, vmsg->size);\n+    }\n+\n+    if (ret) {\n+        /* resize to zero to indicate an error to master */\n+        vmsg->size = 0;\n+    }\n+\n+    return true;\n+}\n+\n+static bool\n+vu_set_config(VuDev *dev, VhostUserMsg *vmsg)\n+{\n+    int ret = -1;\n+    bool reply_supported = !!(dev->protocol_features &\n+                             (1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK));\n+\n+    if (dev->iface->set_config) {\n+        ret = dev->iface->set_config(dev, vmsg->payload.config, vmsg->size);\n+    }\n+\n+    vmsg->size = sizeof(vmsg->payload.u64);\n+    if (!ret) {\n+        vmsg->payload.u64 = 0;\n+    } else {\n+        /* indicate an error in case reply supported */\n+        vmsg->payload.u64 = 1;\n+    }\n+\n+    if (reply_supported) {\n+        return true;\n+    }\n+\n+    return false;\n+}\n+\n+static bool\n+vu_set_config_fd(VuDev *dev, VhostUserMsg *vmsg)\n+{\n+   if (vmsg->fd_num != 1) {\n+        vu_panic(dev, \"Invalid config_fd message\");\n+        return false;\n+    }\n+\n+    if (dev->config_fd != -1) {\n+        close(dev->config_fd);\n+    }\n+    dev->config_fd = vmsg->fds[0];\n+    DPRINT(\"Got config_fd: %d\\n\", vmsg->fds[0]);\n+\n+    return false;\n+}\n+\n+static bool\n vu_process_message(VuDev *dev, VhostUserMsg *vmsg)\n {\n     int do_reply = 0;\n@@ -819,6 +882,12 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)\n         return vu_get_queue_num_exec(dev, vmsg);\n     case VHOST_USER_SET_VRING_ENABLE:\n         return vu_set_vring_enable_exec(dev, vmsg);\n+    case VHOST_USER_GET_CONFIG:\n+        return vu_get_config(dev, vmsg);\n+    case VHOST_USER_SET_CONFIG:\n+        return vu_set_config(dev, vmsg);\n+    case VHOST_USER_SET_CONFIG_FD:\n+        return vu_set_config_fd(dev, vmsg);\n     case VHOST_USER_NONE:\n         break;\n     default:\n@@ -893,6 +962,10 @@ vu_deinit(VuDev *dev)\n \n     vu_close_log(dev);\n \n+    if (dev->config_fd != -1) {\n+        close(dev->config_fd);\n+    }\n+\n     if (dev->sock != -1) {\n         close(dev->sock);\n     }\n@@ -922,6 +995,7 @@ vu_init(VuDev *dev,\n     dev->remove_watch = remove_watch;\n     dev->iface = iface;\n     dev->log_call_fd = -1;\n+    dev->config_fd = -1;\n     for (i = 0; i < VHOST_MAX_NR_VIRTQUEUE; i++) {\n         dev->vq[i] = (VuVirtq) {\n             .call_fd = -1, .kick_fd = -1, .err_fd = -1,\ndiff --git a/contrib/libvhost-user/libvhost-user.h b/contrib/libvhost-user/libvhost-user.h\nindex 4021f11..15167b8 100644\n--- a/contrib/libvhost-user/libvhost-user.h\n+++ b/contrib/libvhost-user/libvhost-user.h\n@@ -30,10 +30,13 @@\n \n #define VHOST_MEMORY_MAX_NREGIONS 8\n \n+#define VHOST_USER_MAX_CONFIG_SIZE 256\n+\n enum VhostUserProtocolFeature {\n     VHOST_USER_PROTOCOL_F_MQ = 0,\n     VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1,\n     VHOST_USER_PROTOCOL_F_RARP = 2,\n+    VHOST_USER_PROTOCOL_F_REPLY_ACK = 3,\n \n     VHOST_USER_PROTOCOL_F_MAX\n };\n@@ -62,6 +65,9 @@ typedef enum VhostUserRequest {\n     VHOST_USER_SET_VRING_ENABLE = 18,\n     VHOST_USER_SEND_RARP = 19,\n     VHOST_USER_INPUT_GET_CONFIG = 20,\n+    VHOST_USER_GET_CONFIG = 24,\n+    VHOST_USER_SET_CONFIG = 25,\n+    VHOST_USER_SET_CONFIG_FD = 26,\n     VHOST_USER_MAX\n } VhostUserRequest;\n \n@@ -105,6 +111,7 @@ typedef struct VhostUserMsg {\n         struct vhost_vring_addr addr;\n         VhostUserMemory memory;\n         VhostUserLog log;\n+        uint8_t config[VHOST_USER_MAX_CONFIG_SIZE];\n     } payload;\n \n     int fds[VHOST_MEMORY_MAX_NREGIONS];\n@@ -133,6 +140,9 @@ typedef int (*vu_process_msg_cb) (VuDev *dev, VhostUserMsg *vmsg,\n                                   int *do_reply);\n typedef void (*vu_queue_set_started_cb) (VuDev *dev, int qidx, bool started);\n typedef bool (*vu_queue_is_processed_in_order_cb) (VuDev *dev, int qidx);\n+typedef int (*vu_get_config_cb) (VuDev *dev, uint8_t *config, size_t len);\n+typedef int (*vu_set_config_cb) (VuDev *dev, const uint8_t *config,\n+                                 size_t len);\n \n typedef struct VuDevIface {\n     /* called by VHOST_USER_GET_FEATURES to get the features bitmask */\n@@ -155,6 +165,10 @@ typedef struct VuDevIface {\n      * on unmanaged exit/crash.\n      */\n     vu_queue_is_processed_in_order_cb queue_is_processed_in_order;\n+    /* get the config space of the device */\n+    vu_get_config_cb get_config;\n+    /* set the config space of the device */\n+    vu_set_config_cb set_config;\n } VuDevIface;\n \n typedef void (*vu_queue_handler_cb) (VuDev *dev, int qidx);\n@@ -219,6 +233,7 @@ struct VuDev {\n     VuDevRegion regions[VHOST_MEMORY_MAX_NREGIONS];\n     VuVirtq vq[VHOST_MAX_NR_VIRTQUEUE];\n     int log_call_fd;\n+    int config_fd;\n     uint64_t log_size;\n     uint8_t *log_table;\n     uint64_t features;\n",
    "prefixes": [
        "v3",
        "3/4"
    ]
}