Show a patch.

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

{
    "id": 44722,
    "url": "http://patches.dpdk.org/api/patches/44722/?format=api",
    "web_url": "http://patches.dpdk.org/patch/44722/",
    "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"
    },
    "msgid": "<20180914135406.52190-2-david.hunt@intel.com>",
    "date": "2018-09-14T13:53:59",
    "name": "[v3,1/8] examples/power: add checks around hypervisor",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "648f0a3adc94cda539b294db8d0f7763fb18896e",
    "submitter": {
        "id": 342,
        "url": "http://patches.dpdk.org/api/people/342/?format=api",
        "name": "David Hunt",
        "email": "david.hunt@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/patch/44722/mbox/",
    "series": [
        {
            "id": 1322,
            "url": "http://patches.dpdk.org/api/series/1322/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1322",
            "date": "2018-09-14T13:53:58",
            "name": "add json power policy interface for containers",
            "version": 3,
            "mbox": "http://patches.dpdk.org/series/1322/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44722/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44722/checks/",
    "tags": {},
    "headers": {
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,373,1531810800\"; d=\"scan'208\";a=\"257257193\"",
        "X-Amp-File-Uploaded": "False",
        "Precedence": "list",
        "X-Mailman-Version": "2.1.15",
        "X-Original-To": "patchwork@dpdk.org",
        "List-Post": "<mailto:dev@dpdk.org>",
        "References": "<20180912144930.50578-1-david.hunt@intel.com>\n\t<20180914135406.52190-1-david.hunt@intel.com>",
        "X-BeenThere": "dev@dpdk.org",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH v3 1/8] examples/power: add checks around\n\thypervisor",
        "Sender": "\"dev\" <dev-bounces@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 65F0E5B1C;\n\tFri, 14 Sep 2018 15:54:15 +0200 (CEST)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby dpdk.org (Postfix) with ESMTP id D269258C4\n\tfor <dev@dpdk.org>; Fri, 14 Sep 2018 15:54:11 +0200 (CEST)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t14 Sep 2018 06:54:11 -0700",
            "from silpixa00399952.ir.intel.com (HELO\n\tsilpixa00399952.ger.corp.intel.com) ([10.237.223.64])\n\tby orsmga005.jf.intel.com with ESMTP; 14 Sep 2018 06:54:09 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "X-Mailer": "git-send-email 2.17.1",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "X-ExtLoop1": "1",
        "Date": "Fri, 14 Sep 2018 14:53:59 +0100",
        "To": "dev@dpdk.org",
        "From": "David Hunt <david.hunt@intel.com>",
        "In-Reply-To": "<20180914135406.52190-1-david.hunt@intel.com>",
        "Cc": "john.mcnamara@intel.com, stephen@networkplumber.org, lei.a.yao@intel.com,\n\tbruce.richardson@intel.com, David Hunt <david.hunt@intel.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Message-Id": "<20180914135406.52190-2-david.hunt@intel.com>",
        "Return-Path": "<dev-bounces@dpdk.org>"
    },
    "content": "Allow vm_power_manager to run without requiring qemu to be present\non the machine. This will be required for instances where the JSON\ninterface is used for commands and polices, without any VMs present.\nA use case for this is a container enviromnent.\n\nSigned-off-by: David Hunt <david.hunt@intel.com>\n---\n examples/vm_power_manager/channel_manager.c | 71 +++++++++++++--------\n examples/vm_power_manager/channel_monitor.c |  2 +-\n 2 files changed, 44 insertions(+), 29 deletions(-)",
    "diff": "diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c\nindex 927fc35ab..2e471d0c1 100644\n--- a/examples/vm_power_manager/channel_manager.c\n+++ b/examples/vm_power_manager/channel_manager.c\n@@ -43,7 +43,8 @@ static unsigned char *global_cpumaps;\n static virVcpuInfo *global_vircpuinfo;\n static size_t global_maplen;\n \n-static unsigned global_n_host_cpus;\n+static unsigned int global_n_host_cpus;\n+static bool global_hypervisor_available;\n \n /*\n  * Represents a single Virtual Machine\n@@ -198,7 +199,11 @@ get_pcpus_mask(struct channel_info *chan_info, unsigned vcpu)\n {\n \tstruct virtual_machine_info *vm_info =\n \t\t\t(struct virtual_machine_info *)chan_info->priv_info;\n-\treturn rte_atomic64_read(&vm_info->pcpu_mask[vcpu]);\n+\n+\tif (global_hypervisor_available && (vm_info != NULL))\n+\t\treturn rte_atomic64_read(&vm_info->pcpu_mask[vcpu]);\n+\telse\n+\t\treturn 0;\n }\n \n static inline int\n@@ -559,6 +564,8 @@ get_all_vm(int *num_vm, int *num_vcpu)\n \t\t\t\tVIR_CONNECT_LIST_DOMAINS_PERSISTENT;\n \tunsigned int domain_flag = VIR_DOMAIN_VCPU_CONFIG;\n \n+\tif (!global_hypervisor_available)\n+\t\treturn;\n \n \tmemset(global_cpumaps, 0, CHANNEL_CMDS_MAX_CPUS*global_maplen);\n \tif (virNodeGetInfo(global_vir_conn_ptr, &node_info)) {\n@@ -768,38 +775,42 @@ connect_hypervisor(const char *path)\n \t}\n \treturn 0;\n }\n-\n int\n-channel_manager_init(const char *path)\n+channel_manager_init(const char *path __rte_unused)\n {\n \tvirNodeInfo info;\n \n \tLIST_INIT(&vm_list_head);\n \tif (connect_hypervisor(path) < 0) {\n-\t\tRTE_LOG(ERR, CHANNEL_MANAGER, \"Unable to initialize channel manager\\n\");\n-\t\treturn -1;\n-\t}\n-\n-\tglobal_maplen = VIR_CPU_MAPLEN(CHANNEL_CMDS_MAX_CPUS);\n+\t\tglobal_n_host_cpus = 64;\n+\t\tglobal_hypervisor_available = 0;\n+\t\tRTE_LOG(INFO, CHANNEL_MANAGER, \"Unable to initialize channel manager\\n\");\n+\t} else {\n+\t\tglobal_hypervisor_available = 1;\n+\n+\t\tglobal_maplen = VIR_CPU_MAPLEN(CHANNEL_CMDS_MAX_CPUS);\n+\n+\t\tglobal_vircpuinfo = rte_zmalloc(NULL,\n+\t\t\t\tsizeof(*global_vircpuinfo) *\n+\t\t\t\tCHANNEL_CMDS_MAX_CPUS, RTE_CACHE_LINE_SIZE);\n+\t\tif (global_vircpuinfo == NULL) {\n+\t\t\tRTE_LOG(ERR, CHANNEL_MANAGER, \"Error allocating memory for CPU Info\\n\");\n+\t\t\tgoto error;\n+\t\t}\n+\t\tglobal_cpumaps = rte_zmalloc(NULL,\n+\t\t\t\tCHANNEL_CMDS_MAX_CPUS * global_maplen,\n+\t\t\t\tRTE_CACHE_LINE_SIZE);\n+\t\tif (global_cpumaps == NULL)\n+\t\t\tgoto error;\n \n-\tglobal_vircpuinfo = rte_zmalloc(NULL, sizeof(*global_vircpuinfo) *\n-\t\t\tCHANNEL_CMDS_MAX_CPUS, RTE_CACHE_LINE_SIZE);\n-\tif (global_vircpuinfo == NULL) {\n-\t\tRTE_LOG(ERR, CHANNEL_MANAGER, \"Error allocating memory for CPU Info\\n\");\n-\t\tgoto error;\n-\t}\n-\tglobal_cpumaps = rte_zmalloc(NULL, CHANNEL_CMDS_MAX_CPUS * global_maplen,\n-\t\t\tRTE_CACHE_LINE_SIZE);\n-\tif (global_cpumaps == NULL) {\n-\t\tgoto error;\n+\t\tif (virNodeGetInfo(global_vir_conn_ptr, &info)) {\n+\t\t\tRTE_LOG(ERR, CHANNEL_MANAGER, \"Unable to retrieve node Info\\n\");\n+\t\t\tgoto error;\n+\t\t}\n+\t\tglobal_n_host_cpus = (unsigned int)info.cpus;\n \t}\n \n-\tif (virNodeGetInfo(global_vir_conn_ptr, &info)) {\n-\t\tRTE_LOG(ERR, CHANNEL_MANAGER, \"Unable to retrieve node Info\\n\");\n-\t\tgoto error;\n-\t}\n \n-\tglobal_n_host_cpus = (unsigned)info.cpus;\n \n \tif (global_n_host_cpus > CHANNEL_CMDS_MAX_CPUS) {\n \t\tRTE_LOG(WARNING, CHANNEL_MANAGER, \"The number of host CPUs(%u) exceeds the \"\n@@ -811,7 +822,8 @@ channel_manager_init(const char *path)\n \n \treturn 0;\n error:\n-\tdisconnect_hypervisor();\n+\tif (global_hypervisor_available)\n+\t\tdisconnect_hypervisor();\n \treturn -1;\n }\n \n@@ -838,7 +850,10 @@ channel_manager_exit(void)\n \t\trte_free(vm_info);\n \t}\n \n-\trte_free(global_cpumaps);\n-\trte_free(global_vircpuinfo);\n-\tdisconnect_hypervisor();\n+\tif (global_hypervisor_available) {\n+\t\t/* Only needed if hypervisor available */\n+\t\trte_free(global_cpumaps);\n+\t\trte_free(global_vircpuinfo);\n+\t\tdisconnect_hypervisor();\n+\t}\n }\ndiff --git a/examples/vm_power_manager/channel_monitor.c b/examples/vm_power_manager/channel_monitor.c\nindex 7fa47ba97..f180d74e6 100644\n--- a/examples/vm_power_manager/channel_monitor.c\n+++ b/examples/vm_power_manager/channel_monitor.c\n@@ -66,7 +66,7 @@ static void\n core_share_status(int pNo)\n {\n \n-\tint noVms, noVcpus, z, x, t;\n+\tint noVms = 0, noVcpus = 0, z, x, t;\n \n \tget_all_vm(&noVms, &noVcpus);\n \n",
    "prefixes": [
        "v3",
        "1/8"
    ]
}