get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1769,
    "url": "http://patches.dpdk.org/api/patches/1769/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1417687227-21854-1-git-send-email-michael.qiu@intel.com/",
    "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": "<1417687227-21854-1-git-send-email-michael.qiu@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1417687227-21854-1-git-send-email-michael.qiu@intel.com",
    "date": "2014-12-04T10:00:27",
    "name": "[dpdk-dev,v2] VFIO: Avoid to enable vfio while the module not loaded",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5a8ce77f3c8fb0fc3592aa8e7854ae5ba54b4c4f",
    "submitter": {
        "id": 127,
        "url": "http://patches.dpdk.org/api/people/127/?format=api",
        "name": "Michael Qiu",
        "email": "qdy220091330@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1417687227-21854-1-git-send-email-michael.qiu@intel.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/1769/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/1769/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 5E3347E1F;\n\tFri,  5 Dec 2014 07:50:13 +0100 (CET)",
            "from mail-pd0-f177.google.com (mail-pd0-f177.google.com\n\t[209.85.192.177]) by dpdk.org (Postfix) with ESMTP id A247A7DF4\n\tfor <dev@dpdk.org>; Fri,  5 Dec 2014 07:50:10 +0100 (CET)",
            "by mail-pd0-f177.google.com with SMTP id ft15so111065pdb.22\n\tfor <dev@dpdk.org>; Thu, 04 Dec 2014 22:50:10 -0800 (PST)",
            "from localhost.localdomain.localdomain ([180.99.188.137])\n\tby mx.google.com with ESMTPSA id\n\tdk5sm27878980pbc.9.2014.12.04.22.50.06 for <multiple recipients>\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tThu, 04 Dec 2014 22:50:09 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=tP8BFCJWvPv4Tul2ldZ2PIzyR5baTH4UQDvg7MWPYMg=;\n\tb=XQdJBR1F583NVxuZV2g+vp5XpfPVd25OKp3VulexZdwZfpCvjCMOw1NgW82z0r/ccE\n\tfVvUrXMoffiR+vT3GcYCR+p+iYPa7EQPxoax0/ittX7jmrTLiqPk/PzW5lxECbm7aQJw\n\ty2Pp8NU2+4tq+uIof2h3E7ZQ1R7kUrc7GoOQRx3lGHys5rrE+RqEfPZ35uw17REcpUKM\n\tlmP4/DjKLl3bRhC0kzGdnmPJbAF4immvYbIwwifc+yRPHs9Bv1MYoG/I62M/AVb/cRxK\n\tOG/fINzF6rxfhCJKjLUpMdAP/QQFdNCVxFAmcNmiQHrv7RJXX4ja8sizyg6dGOm6vAzJ\n\tuhSw==",
        "X-Received": "by 10.68.57.225 with SMTP id l1mr32217202pbq.87.1417762209870;\n\tThu, 04 Dec 2014 22:50:09 -0800 (PST)",
        "From": "Michael Qiu <qdy220091330@gmail.com>",
        "X-Google-Original-From": "Michael Qiu <michael.qiu@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Thu,  4 Dec 2014 18:00:27 +0800",
        "Message-Id": "<1417687227-21854-1-git-send-email-michael.qiu@intel.com>",
        "X-Mailer": "git-send-email 1.9.3",
        "In-Reply-To": "<1417664219-19679-1-git-send-email-michael.qiu@intel.com>",
        "References": "<1417664219-19679-1-git-send-email-michael.qiu@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2] VFIO: Avoid to enable vfio while the module\n\tnot loaded",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "When vfio module is not loaded when kernel support vfio feature,\nthe routine still try to open the container to get file\ndescription.\n\nThis action is not safe, and of cause got error messages:\n\nEAL: Detected 40 lcore(s)\nEAL:   unsupported IOMMU type!\nEAL: VFIO support could not be initialized\nEAL: Setting up memory...\n\nThis may make user confuse, this patch make it reasonable\nand much more soomth to user.\n\nSigned-off-by: Michael Qiu <michael.qiu@intel.com>\n\n---\n v2 --> v1:\n\t1. Move check_module() from rte_common.h to eal_private.h\n\t   and rename to rte_eal_check_module().\n\t   To make it linuxapp only.\n\t2. Some code clean up.\n\nTested in host and guest, the below is results in VM:\n\n1. VM | without patch | os: 3.11.10-301.fc20.x86_64 | VFIO not loaded\n\nEAL: Support maximum 64 logical core(s) by configuration.\nEAL: Detected 2 lcore(s)\nEAL:   cannot open VFIO container, error 2 (No such file or directory)\nEAL: VFIO support could not be initialized\nEAL: Setting up memory...\n\n2. VM | without patch | os: 3.11.10-301.fc20.x86_64 | VFIO loaded vfio_iommu_type1 not loaded\nmodprobe vfio\n\nlsmod | grep \"vfio\"\nvfio                   19626  0\n\nmodprobe vfio_iommu_type1\nmodprobe: ERROR: could not insert 'vfio_iommu_type1': No such device\n\nls /dev/vfio/vfio\n/dev/vfio/vfio\n\nEAL: Support maximum 64 logical core(s) by configuration.\nEAL: Detected 2 lcore(s)\nEAL:   unsupported IOMMU type!\nEAL: VFIO support could not be initialized\nEAL: Setting up memory...\n\n3. VM | with patch | os: 3.11.10-301.fc20.x86_64 | VFIO(vfio_iommu_type1 never can be loaded inside VM)\n\nEAL: Detected 2 lcore(s)\nEAL: VFIO modules not all loaded, skip VFIO support ...\nEAL: Setting up memory...\n\n lib/librte_eal/common/eal_private.h        | 36 ++++++++++++++++++++++++++++++\n lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 24 +++++++++++++++++---\n 2 files changed, 57 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h\nindex 232fcec..e741bdb 100644\n--- a/lib/librte_eal/common/eal_private.h\n+++ b/lib/librte_eal/common/eal_private.h\n@@ -35,6 +35,7 @@\n #define _EAL_PRIVATE_H_\n \n #include <stdio.h>\n+#include <string.h>\n \n /**\n  * Initialize the memzone subsystem (private to eal).\n@@ -203,4 +204,39 @@ int rte_eal_alarm_init(void);\n  */\n int rte_eal_dev_init(void);\n \n+/**\n+ * Function is to check if the kernel module(like, vfio, vfio_iommu_type1,\n+ * etc.) loaded.\n+ *\n+ * @param module_name\n+ *\tThe module's name which need to be checked\n+ *\n+ * @return\n+ * \t-1 means error happens(NULL pointer or open failure)\n+ * \t 0 means the module not loaded\n+ * \t 1 means the module loaded\n+ */\n+static inline int\n+rte_eal_check_module(const char *module_name)\n+{\n+\tchar mod_name[30]; /* Any module names can be longer than 30 bytes? */\n+\tint ret = 0;\n+\n+\tif (NULL == module_name)\n+\t\treturn -1;\n+\tFILE * fd = fopen(\"/proc/modules\", \"r\");\n+\tif (fd == NULL)\n+\t\treturn -1;\n+\twhile(!feof(fd)) {\n+\t\tfscanf(fd, \"%s %*[^\\n]\", mod_name);\n+\t\tif(!strcmp(mod_name, module_name)) {\n+\t\t\tret = 1;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\tfclose(fd);\n+\n+\treturn ret;\n+}\n+\n #endif /* _EAL_PRIVATE_H_ */\ndiff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\nindex c1246e8..52ab2d0 100644\n--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c\n@@ -44,6 +44,7 @@\n #include <rte_tailq.h>\n #include <rte_eal_memconfig.h>\n #include <rte_malloc.h>\n+#include <eal_private.h>\n \n #include \"eal_filesystem.h\"\n #include \"eal_pci_init.h\"\n@@ -339,10 +340,13 @@ pci_vfio_get_container_fd(void)\n \t\tret = ioctl(vfio_container_fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU);\n \t\tif (ret != 1) {\n \t\t\tif (ret < 0)\n-\t\t\t\tRTE_LOG(ERR, EAL, \"  could not get IOMMU type, \"\n-\t\t\t\t\t\t\"error %i (%s)\\n\", errno, strerror(errno));\n+\t\t\t\tRTE_LOG(ERR, EAL, \"  could not get IOMMU type,\"\n+\t\t\t\t\t\" error %i (%s)\\n\", errno,\n+\t\t\t\t\tstrerror(errno));\n \t\t\telse\n-\t\t\t\tRTE_LOG(ERR, EAL, \"  unsupported IOMMU type!\\n\");\n+\t\t\t\tRTE_LOG(ERR, EAL, \"  unsupported IOMMU type! \"\n+\t\t\t\t\t\"expect: VFIO_TYPE1_IOMMU, \"\n+\t\t\t\t\t\"actual: %d\\n\", ret);\n \t\t\tclose(vfio_container_fd);\n \t\t\treturn -1;\n \t\t}\n@@ -788,6 +792,20 @@ pci_vfio_enable(void)\n \t\tvfio_cfg.vfio_groups[i].fd = -1;\n \t\tvfio_cfg.vfio_groups[i].group_no = -1;\n \t}\n+\n+\t/* return error directly */\n+\tif (rte_eal_check_module(\"vfio\") == -1 ||\n+\t    rte_eal_check_module(\"vfio_iommu_type1\") == -1)\n+\t\treturn -1;\n+\n+\t/* return 0 if not all VFIO modules loaded */\n+\tif (rte_eal_check_module(\"vfio\") == 0 ||\n+\t    rte_eal_check_module(\"vfio_iommu_type1\") == 0) {\n+\t\tRTE_LOG(INFO, EAL, \"VFIO modules not all loaded,\"\n+\t\t\t\" skip VFIO support ...\\n\");\n+\t\treturn 0;\n+\t}\n+\n \tvfio_cfg.vfio_container_fd = pci_vfio_get_container_fd();\n \n \t/* check if we have VFIO driver enabled */\n",
    "prefixes": [
        "dpdk-dev",
        "v2"
    ]
}