Show a patch.

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

{
    "id": 43222,
    "url": "http://patches.dpdk.org/api/patches/43222/",
    "web_url": "http://patches.dpdk.org/patch/43222/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk"
    },
    "msgid": "<153202762812.21481.4897742465873945718.stgit@T460>",
    "date": "2018-07-19T19:13:48",
    "name": "[v2,4/5] vhost: unify message handling function signature",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "178a218d1c65640ec2afc24c6fa472238c6518b9",
    "submitter": {
        "id": 1062,
        "url": "http://patches.dpdk.org/api/people/1062/",
        "name": "Nikolay Nikolaev",
        "email": "nicknickolaev@gmail.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/patch/43222/mbox/",
    "series": [
        {
            "id": 681,
            "url": "http://patches.dpdk.org/api/series/681/",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=681",
            "date": "2018-07-19T19:13:20",
            "name": "vhost_user.c code cleanup",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/681/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/43222/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/43222/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "To": "maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com",
        "X-Google-Smtp-Source": "AAOMgpfuM9GTtXnl2S3/ispaV3IBiYVGFPQrK0mAUHZkfYqzQN5hv+lTncflhEhnxrbZV8WlEFqO/A==",
        "X-Gm-Message-State": "AOUpUlGnvw+VVNg6Q8luCXigTwIqaQ2DAmV9N3nL0bvLM6OQEEB2DNk7\n\txnmrWm61G7QLhcKjYTlpx8UOV71mjT8=",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=subject:from:to:cc:date:message-id:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=54IOh5VHBYD03NLbWDjjU6ki9Ig8/ynVaU6fYQSRTWM=;\n\tb=LWeO7ityu0CyDb8Aqn17GOGaEgCtbQqMheloI9Bw0vhoxZ8Vq1wDdTVxd3wyU2wBwX\n\t3+vXVo3DFIzRYEggrzpo8PXNJp8GeUbxsYYiQMT/U6XC+GBZcr/iQ8UVdREh6T5uqkd/\n\tL7mXvT0Pw78uRcWCDAOxnouC6w62udCNPM31d0JF1xHcGhd74z5rCU34MVVFTRbZiRK8\n\tRJEh4bjvhhV7Xwr7OnoEZEP3rpYhEKCoTjqMcDtGAX1X5PEWK5hIFjcwu/Mbr/IxyNpN\n\t6+g8/cSTdmlcu66yOlOruVmccuJawy5lKsr59//Jhz3uicJhTcQJvXLyw/FJlizN6Snf\n\t76aA==",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Message-ID": "<153202762812.21481.4897742465873945718.stgit@T460>",
        "X-BeenThere": "dev@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D65B15B3C;\n\tThu, 19 Jul 2018 21:13:51 +0200 (CEST)",
            "from mail-wr1-f65.google.com (mail-wr1-f65.google.com\n\t[209.85.221.65]) by dpdk.org (Postfix) with ESMTP id 91BDD5F2F\n\tfor <dev@dpdk.org>; Thu, 19 Jul 2018 21:13:50 +0200 (CEST)",
            "by mail-wr1-f65.google.com with SMTP id b15-v6so9087108wrv.10\n\tfor <dev@dpdk.org>; Thu, 19 Jul 2018 12:13:50 -0700 (PDT)",
            "from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id\n\tf20-v6sm488578wmd.3.2018.07.19.12.13.48\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 19 Jul 2018 12:13:49 -0700 (PDT)"
        ],
        "Subject": "[dpdk-dev] [PATCH v2 4/5] vhost: unify message handling function\n\tsignature",
        "In-Reply-To": "<153202755842.21481.1772155561595981441.stgit@T460>",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Cc": "dev@dpdk.org",
        "Precedence": "list",
        "From": "Nikolay Nikolaev <nicknickolaev@gmail.com>",
        "X-Received": "by 2002:adf:ffc7:: with SMTP id\n\tx7-v6mr8658347wrs.137.1532027629910; \n\tThu, 19 Jul 2018 12:13:49 -0700 (PDT)",
        "Content-Transfer-Encoding": "7bit",
        "MIME-Version": "1.0",
        "References": "<153202755842.21481.1772155561595981441.stgit@T460>",
        "X-Original-To": "patchwork@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Errors-To": "dev-bounces@dpdk.org",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Delivered-To": "patchwork@dpdk.org",
        "Date": "Thu, 19 Jul 2018 22:13:48 +0300",
        "X-Mailman-Version": "2.1.15",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=54IOh5VHBYD03NLbWDjjU6ki9Ig8/ynVaU6fYQSRTWM=;\n\tb=aIQk2TBFwExWtXnYUx8+YL25gahfNlcZxW1OKbv6GAcy3QITFd2AP/qRpLCu6iLu0E\n\tRlr3e8LtCsQ6es3zLI7MwHjoA5W7fwz0WxjMV25wc+/ufKjBM0CX64tQ/tNahA85ZE2v\n\tOdMenP3VYOG5Dqq/HfVFgbbYbUE+2LzjsHkJP8OQPKvup8vksGQjEiRIIbybJQMAUBCp\n\tmdDpvMkNYy+rh9UTDkG+4JgYhEqf9jDiQOEll2teg5p/eXq1XQ5vZIhyhnikbkSvhecY\n\tO7ccT6EIN3nsmtpuCACljoyZWNB+eqYx/WEi3Th04m/YIxxaygRJ/KbcITzX5evBZSrk\n\tRrbQ==",
        "User-Agent": "StGit/0.17.1-dirty"
    },
    "content": "Each vhost-user message handling function will return an int result\nwhich is described in the new enum vh_result: error, OK and reply.\nAll functions will now have two arguments, virtio_net double pointer\nand VhostUserMsg pointer.\n\nSigned-off-by: Nikolay Nikolaev <nicknickolaev@gmail.com>\n---\n lib/librte_vhost/vhost_user.c |  219 ++++++++++++++++++++++++-----------------\n 1 file changed, 130 insertions(+), 89 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex b408460f0..6b39d1e30 100644\n--- a/lib/librte_vhost/vhost_user.c\n+++ b/lib/librte_vhost/vhost_user.c\n@@ -71,6 +71,16 @@ static const char *vhost_message_str[VHOST_USER_MAX] = {\n \t[VHOST_USER_CRYPTO_CLOSE_SESS] = \"VHOST_USER_CRYPTO_CLOSE_SESS\",\n };\n \n+/* The possible results of a message handling function */\n+enum vh_result {\n+\t/* Message handling failed */\n+\tVH_RESULT_ERR   = -1,\n+\t/* Message handling successful */\n+\tVH_RESULT_OK    =  0,\n+\t/* Message handling successful and reply prepared */\n+\tVH_RESULT_REPLY =  1,\n+};\n+\n static uint64_t\n get_blk_size(int fd)\n {\n@@ -127,27 +137,31 @@ vhost_backend_cleanup(struct virtio_net *dev)\n  * the device hasn't been initialised.\n  */\n static int\n-vhost_user_set_owner(void)\n+vhost_user_set_owner(struct virtio_net **pdev __rte_unused,\n+\t\tVhostUserMsg * msg __rte_unused)\n {\n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n static int\n-vhost_user_reset_owner(struct virtio_net *dev)\n+vhost_user_reset_owner(struct virtio_net **pdev,\n+\t\tVhostUserMsg * msg __rte_unused)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tvhost_destroy_device_notify(dev);\n \n \tcleanup_device(dev, 0);\n \treset_device(dev);\n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n /*\n  * The features that we support are requested.\n  */\n-static uint64_t\n-vhost_user_get_features(struct virtio_net *dev, VhostUserMsg *msg)\n+static int\n+vhost_user_get_features(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tuint64_t features = 0;\n \n \trte_vhost_driver_get_features(dev->ifname, &features);\n@@ -155,15 +169,16 @@ vhost_user_get_features(struct virtio_net *dev, VhostUserMsg *msg)\n \tmsg->payload.u64 = features;\n \tmsg->size = sizeof(msg->payload.u64);\n \n-\treturn features;\n+\treturn VH_RESULT_REPLY;\n }\n \n /*\n  * The queue number that we support are requested.\n  */\n-static uint32_t\n-vhost_user_get_queue_num(struct virtio_net *dev, VhostUserMsg *msg)\n+static int\n+vhost_user_get_queue_num(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tuint32_t queue_num = 0;\n \n \trte_vhost_driver_get_queue_num(dev->ifname, &queue_num);\n@@ -171,15 +186,17 @@ vhost_user_get_queue_num(struct virtio_net *dev, VhostUserMsg *msg)\n \tmsg->payload.u64 = (uint64_t)queue_num;\n \tmsg->size = sizeof(msg->payload.u64);\n \n-\treturn queue_num;\n+\treturn VH_RESULT_REPLY;\n }\n \n /*\n  * We receive the negotiated features supported by us and the virtio device.\n  */\n static int\n-vhost_user_set_features(struct virtio_net *dev, uint64_t features)\n+vhost_user_set_features(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n+\tuint64_t features = msg->payload.u64;\n \tuint64_t vhost_features = 0;\n \tstruct rte_vdpa_device *vdpa_dev;\n \tint did = -1;\n@@ -189,12 +206,12 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features)\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"(%d) received invalid negotiated features.\\n\",\n \t\t\tdev->vid);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tif (dev->flags & VIRTIO_DEV_RUNNING) {\n \t\tif (dev->features == features)\n-\t\t\treturn 0;\n+\t\t\treturn VH_RESULT_OK;\n \n \t\t/*\n \t\t * Error out if master tries to change features while device is\n@@ -205,7 +222,7 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features)\n \t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\t\"(%d) features changed while device is running.\\n\",\n \t\t\t\tdev->vid);\n-\t\t\treturn -1;\n+\t\t\treturn VH_RESULT_ERR;\n \t\t}\n \n \t\tif (dev->notify_ops->features_changed)\n@@ -250,16 +267,17 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features)\n \tif (vdpa_dev && vdpa_dev->ops->set_features)\n \t\tvdpa_dev->ops->set_features(dev->vid);\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n /*\n  * The virtio device sends us the size of the descriptor ring.\n  */\n static int\n-vhost_user_set_vring_num(struct virtio_net *dev,\n+vhost_user_set_vring_num(struct virtio_net **pdev,\n \t\t\t VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tstruct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];\n \n \tvq->size = msg->payload.state.num;\n@@ -272,7 +290,7 @@ vhost_user_set_vring_num(struct virtio_net *dev,\n \tif ((vq->size & (vq->size - 1)) || vq->size > 32768) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"invalid virtqueue size %u\\n\", vq->size);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tif (dev->dequeue_zero_copy) {\n@@ -298,7 +316,7 @@ vhost_user_set_vring_num(struct virtio_net *dev,\n \t\tif (!vq->shadow_used_packed) {\n \t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n-\t\t\treturn -1;\n+\t\t\treturn VH_RESULT_ERR;\n \t\t}\n \n \t} else {\n@@ -308,7 +326,7 @@ vhost_user_set_vring_num(struct virtio_net *dev,\n \t\tif (!vq->shadow_used_split) {\n \t\t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n-\t\t\treturn -1;\n+\t\t\treturn VH_RESULT_ERR;\n \t\t}\n \t}\n \n@@ -318,10 +336,10 @@ vhost_user_set_vring_num(struct virtio_net *dev,\n \tif (!vq->batch_copy_elems) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"failed to allocate memory for batching copy.\\n\");\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n /*\n@@ -619,12 +637,12 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)\n static int\n vhost_user_set_vring_addr(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tstruct vhost_virtqueue *vq;\n \tstruct vhost_vring_addr *addr = &msg->payload.addr;\n-\tstruct virtio_net *dev = *pdev;\n \n \tif (dev->mem == NULL)\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \n \t/* addr->index refers to the queue index. The txq 1, rxq is 0. */\n \tvq = dev->virtqueue[msg->payload.addr.index];\n@@ -641,27 +659,28 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\t\t\t(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) {\n \t\tdev = translate_ring_addresses(dev, msg->payload.addr.index);\n \t\tif (!dev)\n-\t\t\treturn -1;\n+\t\t\treturn VH_RESULT_ERR;\n \n \t\t*pdev = dev;\n \t}\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n /*\n  * The virtio device sends us the available ring last used index.\n  */\n static int\n-vhost_user_set_vring_base(struct virtio_net *dev,\n+vhost_user_set_vring_base(struct virtio_net **pdev,\n \t\t\t  VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tdev->virtqueue[msg->payload.state.index]->last_used_idx  =\n \t\t\tmsg->payload.state.num;\n \tdev->virtqueue[msg->payload.state.index]->last_avail_idx =\n \t\t\tmsg->payload.state.num;\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n static int\n@@ -802,7 +821,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg)\n \tif (memory.nregions > VHOST_MEMORY_MAX_NREGIONS) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"too many memory regions (%u)\\n\", memory.nregions);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tif (dev->mem && !vhost_memory_changed(&memory, dev->mem)) {\n@@ -812,7 +831,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\tfor (i = 0; i < memory.nregions; i++)\n \t\t\tclose(msg->fds[i]);\n \n-\t\treturn 0;\n+\t\treturn VH_RESULT_OK;\n \t}\n \n \tif (dev->mem) {\n@@ -831,7 +850,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\t\t\t\"(%d) failed to allocate memory \"\n \t\t\t\t\"for dev->guest_pages\\n\",\n \t\t\t\tdev->vid);\n-\t\t\treturn -1;\n+\t\t\treturn VH_RESULT_ERR;\n \t\t}\n \t}\n \n@@ -841,7 +860,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"(%d) failed to allocate memory for dev->mem\\n\",\n \t\t\tdev->vid);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \tdev->mem->nregions = memory.nregions;\n \n@@ -938,7 +957,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg)\n \n \t\t\tdev = translate_ring_addresses(dev, i);\n \t\t\tif (!dev)\n-\t\t\t\treturn -1;\n+\t\t\t\treturn VH_RESULT_ERR;\n \n \t\t\t*pdev = dev;\n \t\t}\n@@ -946,13 +965,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, VhostUserMsg *msg)\n \n \tdump_guest_pages(dev);\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n \n err_mmap:\n \tfree_mem_region(dev);\n \trte_free(dev->mem);\n \tdev->mem = NULL;\n-\treturn -1;\n+\treturn VH_RESULT_ERR;\n }\n \n static bool\n@@ -994,9 +1013,10 @@ virtio_is_ready(struct virtio_net *dev)\n \treturn 1;\n }\n \n-static void\n-vhost_user_set_vring_call(struct virtio_net *dev, VhostUserMsg *msg)\n+static int\n+vhost_user_set_vring_call(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tstruct vhost_vring_file file;\n \tstruct vhost_virtqueue *vq;\n \n@@ -1013,22 +1033,26 @@ vhost_user_set_vring_call(struct virtio_net *dev, VhostUserMsg *msg)\n \t\tclose(vq->callfd);\n \n \tvq->callfd = file.fd;\n+\n+\treturn VH_RESULT_OK;\n }\n \n-static void vhost_user_set_vring_err(struct virtio_net *dev __rte_unused,\n+static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,\n \t\t\tVhostUserMsg *msg)\n {\n \tif (!(msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK))\n \t\tclose(msg->fds[0]);\n \tRTE_LOG(INFO, VHOST_CONFIG, \"not implemented\\n\");\n+\n+\treturn VH_RESULT_OK;\n }\n \n-static void\n+static int\n vhost_user_set_vring_kick(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tstruct vhost_vring_file file;\n \tstruct vhost_virtqueue *vq;\n-\tstruct virtio_net *dev = *pdev;\n \n \tfile.index = msg->payload.u64 & VHOST_USER_VRING_IDX_MASK;\n \tif (msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)\n@@ -1041,7 +1065,7 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, VhostUserMsg *msg)\n \t/* Interpret ring addresses only when ring is started. */\n \tdev = translate_ring_addresses(dev, file.index);\n \tif (!dev)\n-\t\treturn;\n+\t\treturn VH_RESULT_OK;\n \n \t*pdev = dev;\n \n@@ -1058,6 +1082,8 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, VhostUserMsg *msg)\n \tif (vq->kickfd >= 0)\n \t\tclose(vq->kickfd);\n \tvq->kickfd = file.fd;\n+\n+\treturn VH_RESULT_OK;\n }\n \n static void\n@@ -1080,9 +1106,10 @@ free_zmbufs(struct vhost_virtqueue *vq)\n  * when virtio is stopped, qemu will send us the GET_VRING_BASE message.\n  */\n static int\n-vhost_user_get_vring_base(struct virtio_net *dev,\n+vhost_user_get_vring_base(struct virtio_net **pdev,\n \t\t\t  VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tstruct vhost_virtqueue *vq = dev->virtqueue[msg->payload.state.index];\n \n \t/* We have to stop the queue (virtio) if it is running. */\n@@ -1127,7 +1154,7 @@ vhost_user_get_vring_base(struct virtio_net *dev,\n \n \tmsg->size = sizeof(msg->payload.state);\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n /*\n@@ -1135,9 +1162,10 @@ vhost_user_get_vring_base(struct virtio_net *dev,\n  * enable the virtio queue pair.\n  */\n static int\n-vhost_user_set_vring_enable(struct virtio_net *dev,\n+vhost_user_set_vring_enable(struct virtio_net **pdev,\n \t\t\t    VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tint enable = (int)msg->payload.state.num;\n \tint index = (int)msg->payload.state.index;\n \tstruct rte_vdpa_device *vdpa_dev;\n@@ -1158,13 +1186,14 @@ vhost_user_set_vring_enable(struct virtio_net *dev,\n \n \tdev->virtqueue[index]->enabled = enable;\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n-static void\n-vhost_user_get_protocol_features(struct virtio_net *dev,\n+static int\n+vhost_user_get_protocol_features(struct virtio_net **pdev,\n \t\t\t\t VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tuint64_t features, protocol_features;\n \n \trte_vhost_driver_get_features(dev->ifname, &features);\n@@ -1181,35 +1210,42 @@ vhost_user_get_protocol_features(struct virtio_net *dev,\n \n \tmsg->payload.u64 = protocol_features;\n \tmsg->size = sizeof(msg->payload.u64);\n+\n+\treturn VH_RESULT_OK;\n }\n \n-static void\n-vhost_user_set_protocol_features(struct virtio_net *dev,\n-\t\t\t\t uint64_t protocol_features)\n+static int\n+vhost_user_set_protocol_features(struct virtio_net **pdev,\n+\t\t\t\t VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n+\tuint64_t protocol_features = msg->payload.u64;\n \tif (protocol_features & ~VHOST_USER_PROTOCOL_FEATURES)\n-\t\treturn;\n+\t\treturn VH_RESULT_OK;\n \n \tdev->protocol_features = protocol_features;\n+\n+\treturn VH_RESULT_OK;\n }\n \n static int\n-vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg)\n+vhost_user_set_log_base(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tint fd = msg->fds[0];\n \tuint64_t size, off;\n \tvoid *addr;\n \n \tif (fd < 0) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG, \"invalid log fd: %d\\n\", fd);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tif (msg->size != sizeof(VhostUserLog)) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"invalid log base msg size: %\"PRId32\" != %d\\n\",\n \t\t\tmsg->size, (int)sizeof(VhostUserLog));\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tsize = msg->payload.log.mmap_size;\n@@ -1220,7 +1256,7 @@ vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg)\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"log offset %#\"PRIx64\" exceeds log size %#\"PRIx64\"\\n\",\n \t\t\toff, size);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tRTE_LOG(INFO, VHOST_CONFIG,\n@@ -1235,7 +1271,7 @@ vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg)\n \tclose(fd);\n \tif (addr == MAP_FAILED) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG, \"mmap log base failed!\\n\");\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \t/*\n@@ -1251,14 +1287,16 @@ vhost_user_set_log_base(struct virtio_net *dev, VhostUserMsg *msg)\n \n \tmsg->size = sizeof(msg->payload.u64);\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n-static void\n-vhost_user_set_log_fd(struct virtio_net *dev __rte_unused, VhostUserMsg *msg)\n+static int\n+vhost_user_set_log_fd(struct virtio_net **pdev __rte_unused, VhostUserMsg *msg)\n {\n \tclose(msg->fds[0]);\n \tRTE_LOG(INFO, VHOST_CONFIG, \"not implemented.\\n\");\n+\n+\treturn VH_RESULT_OK;\n }\n \n /*\n@@ -1270,8 +1308,9 @@ vhost_user_set_log_fd(struct virtio_net *dev __rte_unused, VhostUserMsg *msg)\n  * a flag 'broadcast_rarp' to let rte_vhost_dequeue_burst() inject it.\n  */\n static int\n-vhost_user_send_rarp(struct virtio_net *dev, VhostUserMsg *msg)\n+vhost_user_send_rarp(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tuint8_t *mac = (uint8_t *)&msg->payload.u64;\n \tstruct rte_vdpa_device *vdpa_dev;\n \tint did = -1;\n@@ -1295,40 +1334,42 @@ vhost_user_send_rarp(struct virtio_net *dev, VhostUserMsg *msg)\n \tif (vdpa_dev && vdpa_dev->ops->migration_done)\n \t\tvdpa_dev->ops->migration_done(dev->vid);\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n static int\n-vhost_user_net_set_mtu(struct virtio_net *dev, VhostUserMsg *msg)\n+vhost_user_net_set_mtu(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tif (msg->payload.u64 < VIRTIO_MIN_MTU ||\n \t\t\tmsg->payload.u64 > VIRTIO_MAX_MTU) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG, \"Invalid MTU size (%\"PRIu64\")\\n\",\n \t\t\t\tmsg->payload.u64);\n \n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tdev->mtu = msg->payload.u64;\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n static int\n-vhost_user_set_req_fd(struct virtio_net *dev, VhostUserMsg *msg)\n+vhost_user_set_req_fd(struct virtio_net **pdev, VhostUserMsg *msg)\n {\n+\tstruct virtio_net *dev = *pdev;\n \tint fd = msg->fds[0];\n \n \tif (fd < 0) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\t\"Invalid file descriptor for slave channel (%d)\\n\",\n \t\t\t\tfd);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tdev->slave_req_fd = fd;\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n static int\n@@ -1393,7 +1434,7 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, VhostUserMsg *msg)\n \t\tlen = imsg->size;\n \t\tvva = qva_to_vva(dev, imsg->uaddr, &len);\n \t\tif (!vva)\n-\t\t\treturn -1;\n+\t\t\treturn VH_RESULT_ERR;\n \n \t\tfor (i = 0; i < dev->nr_vring; i++) {\n \t\t\tstruct vhost_virtqueue *vq = dev->virtqueue[i];\n@@ -1419,10 +1460,10 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, VhostUserMsg *msg)\n \tdefault:\n \t\tRTE_LOG(ERR, VHOST_CONFIG, \"Invalid IOTLB message type (%d)\\n\",\n \t\t\t\timsg->type);\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n-\treturn 0;\n+\treturn VH_RESULT_OK;\n }\n \n /* return bytes# of read on success or negative val on failure. */\n@@ -1671,28 +1712,28 @@ vhost_user_msg_handler(int vid, int fd)\n \n \tswitch (msg.request.master) {\n \tcase VHOST_USER_GET_FEATURES:\n-\t\tvhost_user_get_features(dev, &msg);\n+\t\tret = vhost_user_get_features(&dev, &msg);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_FEATURES:\n-\t\tret = vhost_user_set_features(dev, msg.payload.u64);\n+\t\tret = vhost_user_set_features(&dev, &msg);\n \t\tif (ret)\n \t\t\treturn -1;\n \t\tbreak;\n \n \tcase VHOST_USER_GET_PROTOCOL_FEATURES:\n-\t\tvhost_user_get_protocol_features(dev, &msg);\n+\t\tret = vhost_user_get_protocol_features(&dev, &msg);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_PROTOCOL_FEATURES:\n-\t\tvhost_user_set_protocol_features(dev, msg.payload.u64);\n+\t\tret = vhost_user_set_protocol_features(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_OWNER:\n-\t\tvhost_user_set_owner();\n+\t\tret = vhost_user_set_owner(&dev, &msg);\n \t\tbreak;\n \tcase VHOST_USER_RESET_OWNER:\n-\t\tvhost_user_reset_owner(dev);\n+\t\tret = vhost_user_reset_owner(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_MEM_TABLE:\n@@ -1700,57 +1741,57 @@ vhost_user_msg_handler(int vid, int fd)\n \t\tbreak;\n \n \tcase VHOST_USER_SET_LOG_BASE:\n-\t\tvhost_user_set_log_base(dev, &msg);\n+\t\tret = vhost_user_set_log_base(&dev, &msg);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_LOG_FD:\n-\t\tvhost_user_set_log_fd(dev, &msg);\n+\t\tret = vhost_user_set_log_fd(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_VRING_NUM:\n-\t\tvhost_user_set_vring_num(dev, &msg);\n+\t\tret = vhost_user_set_vring_num(&dev, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_VRING_ADDR:\n-\t\tvhost_user_set_vring_addr(&dev, &msg);\n+\t\tret = vhost_user_set_vring_addr(&dev, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_VRING_BASE:\n-\t\tvhost_user_set_vring_base(dev, &msg);\n+\t\tret = vhost_user_set_vring_base(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_GET_VRING_BASE:\n-\t\tvhost_user_get_vring_base(dev, &msg);\n+\t\tret = vhost_user_get_vring_base(&dev, &msg);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_VRING_KICK:\n-\t\tvhost_user_set_vring_kick(&dev, &msg);\n+\t\tret = vhost_user_set_vring_kick(&dev, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SET_VRING_CALL:\n-\t\tvhost_user_set_vring_call(dev, &msg);\n+\t\tret = vhost_user_set_vring_call(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_VRING_ERR:\n-\t\tvhost_user_set_vring_err(dev, &msg);\n+\t\tret = vhost_user_set_vring_err(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_GET_QUEUE_NUM:\n-\t\tvhost_user_get_queue_num(dev, &msg);\n+\t\tret = vhost_user_get_queue_num(&dev, &msg);\n \t\tsend_vhost_reply(fd, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_VRING_ENABLE:\n-\t\tvhost_user_set_vring_enable(dev, &msg);\n+\t\tret = vhost_user_set_vring_enable(&dev, &msg);\n \t\tbreak;\n \tcase VHOST_USER_SEND_RARP:\n-\t\tvhost_user_send_rarp(dev, &msg);\n+\t\tret = vhost_user_send_rarp(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_NET_SET_MTU:\n-\t\tret = vhost_user_net_set_mtu(dev, &msg);\n+\t\tret = vhost_user_net_set_mtu(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_SET_SLAVE_REQ_FD:\n-\t\tret = vhost_user_set_req_fd(dev, &msg);\n+\t\tret = vhost_user_set_req_fd(&dev, &msg);\n \t\tbreak;\n \n \tcase VHOST_USER_IOTLB_MSG:\n",
    "prefixes": [
        "v2",
        "4/5"
    ]
}