Show a patch.

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

{
    "id": 444,
    "url": "https://patches.dpdk.org/api/patches/444/?format=api",
    "web_url": "https://patches.dpdk.org/patch/444/",
    "project": {
        "id": 1,
        "url": "https://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"
    },
    "msgid": "<1411410879-28872-6-git-send-email-alan.carew@intel.com>",
    "date": "2014-09-22T18:34:34",
    "name": "[dpdk-dev,05/10] VM communication channels for VM Power Management(Guest).",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f5374ae8d2fca009b88c79c8b34fd67f55fd118e",
    "submitter": {
        "id": 72,
        "url": "https://patches.dpdk.org/api/people/72/?format=api",
        "name": "Alan Carew",
        "email": "alan.carew@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/patch/444/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/444/comments/",
    "check": "pending",
    "checks": "https://patches.dpdk.org/api/patches/444/checks/",
    "tags": {},
    "headers": {
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "Message-Id": "<1411410879-28872-6-git-send-email-alan.carew@intel.com>",
        "X-Mailer": "git-send-email 1.9.3",
        "To": "dev@dpdk.org",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 00B13B3BA;\n\tMon, 22 Sep 2014 20:29:46 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id AE2B3ADC4\n\tfor <dev@dpdk.org>; Mon, 22 Sep 2014 20:29:38 +0200 (CEST)",
            "from orsmga002.jf.intel.com ([10.7.209.21])\n\tby orsmga101.jf.intel.com with ESMTP; 22 Sep 2014 11:35:24 -0700",
            "from sie-lab-212-143.ir.intel.com (HELO\n\tsilpixa00385294.ir.intel.com) ([10.237.212.143])\n\tby orsmga002.jf.intel.com with ESMTP; 22 Sep 2014 11:35:23 -0700"
        ],
        "X-BeenThere": "dev@dpdk.org",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "Subject": "[dpdk-dev] [PATCH 05/10] VM communication channels for VM Power\n\tManagement(Guest).",
        "In-Reply-To": "<1411410879-28872-1-git-send-email-alan.carew@intel.com>",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Date": "Mon, 22 Sep 2014 19:34:34 +0100",
        "X-ExtLoop1": "1",
        "Precedence": "list",
        "From": "Alan Carew <alan.carew@intel.com>",
        "X-IronPort-AV": "E=Sophos;i=\"5.04,573,1406617200\"; d=\"scan'208\";a=\"606714491\"",
        "References": "<1411410879-28872-1-git-send-email-alan.carew@intel.com>",
        "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>",
        "Delivered-To": "patchwork@dpdk.org",
        "X-Mailman-Version": "2.1.15"
    },
    "content": "Allows for the opening of Virtio-Serial devices on a VM, where a DPDK\napplication can send packets to the host based monitor. The packet formatted is\nspecified in channel_commands.h\nEach device appears as a serial device in path\n/dev/virtio-ports/virtio.serial.port.<agent_type>.<lcore_num> where each lcore\nin a DPDK application has exclusive to a device/channel.\nEach channel is opened in non-blocking mode, after a successful open a test\npacket is send to the host to ensure the host side is monitoring.\n\nSigned-off-by: Alan Carew <alan.carew@intel.com>\n---\n lib/librte_power_vm/guest_channel.c | 150 ++++++++++++++++++++++++++++++++++++\n lib/librte_power_vm/guest_channel.h |  89 +++++++++++++++++++++\n 2 files changed, 239 insertions(+)\n create mode 100644 lib/librte_power_vm/guest_channel.c\n create mode 100644 lib/librte_power_vm/guest_channel.h",
    "diff": "diff --git a/lib/librte_power_vm/guest_channel.c b/lib/librte_power_vm/guest_channel.c\nnew file mode 100644\nindex 0000000..8baa20a\n--- /dev/null\n+++ b/lib/librte_power_vm/guest_channel.c\n@@ -0,0 +1,150 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <unistd.h>\n+#include <signal.h>\n+#include <limits.h>\n+#include <fcntl.h>\n+#include <string.h>\n+#include <errno.h>\n+\n+\n+#include <rte_log.h>\n+#include <rte_config.h>\n+\n+#include \"guest_channel.h\"\n+#include \"channel_commands.h\"\n+\n+#define RTE_LOGTYPE_GUEST_CHANNEL RTE_LOGTYPE_USER1\n+\n+static int global_fds[RTE_MAX_LCORE];\n+\n+int\n+guest_channel_host_connect(const char *path, unsigned lcore_id)\n+{\n+\tint flags, ret;\n+\tstruct channel_packet pkt;\n+\tchar fd_path[PATH_MAX];\n+\tint fd = -1;\n+\n+\tif (lcore_id >= RTE_MAX_LCORE) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Channel(%u) is out of range 0...%d\\n\",\n+\t\t\t\tlcore_id, RTE_MAX_LCORE-1);\n+\t\treturn -1;\n+\t}\n+\t/* check if path is already open */\n+\tif (global_fds[lcore_id] != 0) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Channel(%u) is already open\\n\", lcore_id);\n+\t\treturn -1;\n+\t}\n+\n+\tsnprintf(fd_path, PATH_MAX, \"%s.%u\", path, lcore_id);\n+\tRTE_LOG(INFO, GUEST_CHANNEL, \"Opening channel '%s' for lcore %u\\n\",\n+\t\t\tfd_path, lcore_id);\n+\tfd = open(fd_path, O_RDWR);\n+\tif (fd < 0) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Unable to to connect to '%s' with error \"\n+\t\t\t\t\"%s\\n\", fd_path, strerror(errno));\n+\t\treturn -1;\n+\t}\n+\n+\tflags = fcntl(fd, F_GETFL, 0);\n+\tif (flags < 0) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Failed on fcntl get flags for file %s\\n\",\n+\t\t\t\tfd_path);\n+\t\treturn -1;\n+\t}\n+\n+\tflags |= O_NONBLOCK;\n+\tif (fcntl(fd, F_SETFL, flags) < 0) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Failed on setting non-blocking mode for \"\n+\t\t\t\t\"file %s\", fd_path);\n+\t\treturn -1;\n+\t}\n+\t/* QEMU needs a delay after connection */\n+\tsleep(1);\n+\n+\t/* Send a test packet, this command is ignored by the host, but a successful\n+\t *  send indicates that the host endpoint is monitoring.\n+\t */\n+\tpkt.command = CPU_POWER_CONNECT;\n+\tglobal_fds[lcore_id] = fd;\n+\tret = guest_channel_send_msg(&pkt, lcore_id);\n+\tif (ret != 0) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Error on channel '%s' communications \"\n+\t\t\t\t\"test: %s\\n\", fd_path, strerror(ret));\n+\t\tclose(fd);\n+\t\tglobal_fds[lcore_id] = 0;\n+\t\treturn -1;\n+\t}\n+\tRTE_LOG(INFO, GUEST_CHANNEL, \"Channel '%s' is now connected\\n\", fd_path);\n+\treturn 0;\n+}\n+\n+int\n+guest_channel_send_msg(struct channel_packet *pkt, unsigned lcore_id)\n+{\n+\tint ret, buffer_len = sizeof(*pkt);\n+\tvoid *buffer = pkt;\n+\n+\tif (global_fds[lcore_id] == 0) {\n+\t\tRTE_LOG(ERR, GUEST_CHANNEL, \"Channel is not connected\\n\");\n+\t\treturn -1;\n+\t}\n+\twhile (buffer_len > 0) {\n+\t\tret = write(global_fds[lcore_id], buffer, buffer_len);\n+\t\tif (ret == buffer_len)\n+\t\t\treturn 0;\n+\t\tif (ret == -1) {\n+\t\t\tif (errno == EINTR)\n+\t\t\t\tcontinue;\n+\t\t\treturn errno;\n+\t\t}\n+\t\tbuffer = (char *)buffer + ret;\n+\t\tbuffer_len -= ret;\n+\t}\n+\treturn 0;\n+}\n+\n+void\n+guest_channel_host_disconnect(unsigned lcore_id)\n+{\n+\tif (global_fds[lcore_id] == 0)\n+\t\treturn;\n+\tclose(global_fds[lcore_id]);\n+\tglobal_fds[lcore_id] = 0;\n+}\n+\n+\ndiff --git a/lib/librte_power_vm/guest_channel.h b/lib/librte_power_vm/guest_channel.h\nnew file mode 100644\nindex 0000000..9e18af5\n--- /dev/null\n+++ b/lib/librte_power_vm/guest_channel.h\n@@ -0,0 +1,89 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+#ifndef _GUEST_CHANNEL_H\n+#define _GUEST_CHANNEL_H\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+#include <channel_commands.h>\n+\n+/**\n+ * Connect to the Virtio-Serial VM end-point located in path. It is\n+ * thread safe for unique lcore_ids. This function must be only called once from\n+ * each lcore.\n+ *\n+ * @param path\n+ *  The path to the serial device on the filesystem\n+ * @param lcore_id\n+ *  lcore_id.\n+ *\n+ * @return\n+ *  - 0 on success.\n+ *  - Negative on error.\n+ */\n+int guest_channel_host_connect(const char *path, unsigned lcore_id);\n+\n+/**\n+ * Disconnect from an already connected Virtio-Serial Endpoint.\n+ *\n+ *\n+ * @param lcore_id\n+ *  lcore_id.\n+ *\n+ */\n+void guest_channel_host_disconnect(unsigned lcore_id);\n+\n+/**\n+ * Send a message contained in pkt over the Virtio-Serial to the host endpoint.\n+ *\n+ * @param pkt\n+ *  Pointer to a populated struct guest_agent_pkt\n+ *\n+ * @param lcore_id\n+ *  lcore_id.\n+ *\n+ * @return\n+ *  - 0 on success.\n+ *  - Negative on channel not connected.\n+ *  - errno on write to channel error.\n+ */\n+int guest_channel_send_msg(struct channel_packet *pkt, unsigned lcore_id);\n+\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif\n",
    "prefixes": [
        "dpdk-dev",
        "05/10"
    ]
}