get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 41582,
    "url": "http://patches.dpdk.org/api/patches/41582/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/153002997115.22089.11268165694203279446.stgit@T460/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<153002997115.22089.11268165694203279446.stgit@T460>",
    "list_archive_url": "https://inbox.dpdk.org/dev/153002997115.22089.11268165694203279446.stgit@T460",
    "date": "2018-06-26T16:19:31",
    "name": "[v1,4/5] vhost: unify message handling function signature",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "36d605e819cb11fc943351132b8643ed83aa1989",
    "submitter": {
        "id": 1062,
        "url": "http://patches.dpdk.org/api/people/1062/?format=api",
        "name": "Nikolay Nikolaev",
        "email": "nicknickolaev@gmail.com"
    },
    "delegate": {
        "id": 2642,
        "url": "http://patches.dpdk.org/api/users/2642/?format=api",
        "username": "mcoquelin",
        "first_name": "Maxime",
        "last_name": "Coquelin",
        "email": "maxime.coquelin@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/153002997115.22089.11268165694203279446.stgit@T460/mbox/",
    "series": [
        {
            "id": 246,
            "url": "http://patches.dpdk.org/api/series/246/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=246",
            "date": "2018-06-26T16:19:02",
            "name": "vhost_user.c code cleanup",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/246/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/41582/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/41582/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 321791BB7F;\n\tTue, 26 Jun 2018 18:19:35 +0200 (CEST)",
            "from mail-wm0-f67.google.com (mail-wm0-f67.google.com\n\t[74.125.82.67]) by dpdk.org (Postfix) with ESMTP id EF6831BB7A\n\tfor <dev@dpdk.org>; Tue, 26 Jun 2018 18:19:33 +0200 (CEST)",
            "by mail-wm0-f67.google.com with SMTP id e16-v6so2633949wmd.0\n\tfor <dev@dpdk.org>; Tue, 26 Jun 2018 09:19:33 -0700 (PDT)",
            "from [127.0.1.1] ([82.146.27.14]) by smtp.gmail.com with ESMTPSA id\n\tr15-v6sm2228097wro.21.2018.06.26.09.19.31\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 26 Jun 2018 09:19:32 -0700 (PDT)"
        ],
        "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=2/Q+KCq8Y+0J4uCKiF8BZJgg2rZiU7VnNRV4rS167Kg=;\n\tb=EyPNqFuulhXozjayjKbSWEAh9nWNPfwPJaRC5b9ujiTDIcBS6fTj/Y7TC9fkysnwRz\n\tu7ZS15WBOlTWsGGsngp5CSWQFyYRYc6c5l3r8795orNo0vkeWdrwTrlL5jq4nqWRZ4Pu\n\tVFY79erZIgGsOgAKngA+VHDi8GB/gOcPXKiL1aA89XoZ2wFky0y+YHCdz6RZr8I9NRTA\n\tzCedvBl9Lkekjn1218bCTvVj6ChAzX0CSQq00BF7TeKE9qdKmOqcGfBawtav/YbhZnvg\n\tS5wiGMeR4ldOTLwPCNHTBSk1iHg013uG61YR0f2sexsyLYkXfz6LfpA9vzuR65P0l6wB\n\t5Wlg==",
        "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=2/Q+KCq8Y+0J4uCKiF8BZJgg2rZiU7VnNRV4rS167Kg=;\n\tb=EAfSK7NUWfzr08aw4YfTBZX/LszzUOeZLTRKk5ppKZnjwiMzvsiRnCSx1icBCkhvak\n\te1zuFywtq1RnHuKm2yZ27v+s18kSq8CO3d9r72c2tkuWwIiX1BulmZbjTbLHIWNv00wq\n\tZWQNQXVXIkMn152B3wHyyy75WFwKX2Eq02xCTVZV4D+OB9jCCwpg8uPRk46A4iIX4BjG\n\tT8/ph1wMh4xiztcHipkQpeCsA6gnIAqOQMGEOVfZSQJYrHBH1quO4ihv0rtbsrZaKsNZ\n\tPXCxtpSZydR7LSXHT84X6xi//LPSBqpEBXmkdRrIPekr8GQHM35YH5FxzX/KCqQ08Mlr\n\tqFpQ==",
        "X-Gm-Message-State": "APt69E2ny3/S/pvf1eiEQxscKNQOx7E5pcHF5Yi3MJekQUxXRIFL+gpM\n\tZZsNO5IR1RK/efgWnMYuuibFvF9c",
        "X-Google-Smtp-Source": "AAOMgpeuLu26Gwerj3dVzpzEps7qQ2aWI2kBULHneimlWEGAefh0P3b0wXSb1MjaRurixrdkWmqrRw==",
        "X-Received": "by 2002:a1c:d004:: with SMTP id\n\th4-v6mr2116043wmg.151.1530029973145; \n\tTue, 26 Jun 2018 09:19:33 -0700 (PDT)",
        "From": "Nikolay Nikolaev <nicknickolaev@gmail.com>",
        "To": "maxime.coquelin@redhat.com, tiwei.bie@intel.com, zhihong.wang@intel.com",
        "Cc": "dev@dpdk.org",
        "Date": "Tue, 26 Jun 2018 19:19:31 +0300",
        "Message-ID": "<153002997115.22089.11268165694203279446.stgit@T460>",
        "In-Reply-To": "<153002988259.22089.8523468795459281187.stgit@T460>",
        "References": "<153002988259.22089.8523468795459281187.stgit@T460>",
        "User-Agent": "StGit/0.17.1-dirty",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Subject": "[dpdk-dev] [PATCH v1 4/5] vhost: unify message handling function\n\tsignature",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "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-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Each vhost-user message handlign 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 |  217 ++++++++++++++++++++++++-----------------\n 1 file changed, 129 insertions(+), 88 deletions(-)",
    "diff": "diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c\nindex d999c80ed..dd47d84c7 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 handlig failed */\n+\tVH_RESULT_ERR   = -1,\n+\t/* Message handlig successful */\n+\tVH_RESULT_OK    =  0,\n+\t/* Message handlig 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@@ -296,7 +314,7 @@ vhost_user_set_vring_num(struct virtio_net *dev,\n \tif (!vq->shadow_used_ring) {\n \t\tRTE_LOG(ERR, VHOST_CONFIG,\n \t\t\t\"failed to allocate memory for shadow used ring.\\n\");\n-\t\treturn -1;\n+\t\treturn VH_RESULT_ERR;\n \t}\n \n \tvq->batch_copy_elems = rte_malloc(NULL,\n@@ -305,10 +323,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@@ -547,12 +565,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@@ -569,27 +587,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@@ -730,7 +749,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@@ -740,7 +759,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@@ -759,7 +778,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@@ -769,7 +788,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@@ -866,7 +885,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@@ -874,13 +893,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 int\n@@ -912,9 +931,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@@ -931,22 +951,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@@ -959,7 +983,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@@ -976,6 +1000,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@@ -998,9 +1024,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@@ -1040,7 +1067,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@@ -1048,9 +1075,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@@ -1071,13 +1099,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@@ -1094,35 +1123,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@@ -1133,7 +1169,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@@ -1148,7 +1184,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@@ -1164,14 +1200,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@@ -1183,8 +1221,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@@ -1208,40 +1247,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@@ -1306,7 +1347,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@@ -1332,10 +1373,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@@ -1584,28 +1625,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@@ -1613,57 +1654,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": [
        "v1",
        "4/5"
    ]
}