get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 44613,
    "url": "https://patches.dpdk.org/api/patches/44613/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20180912144930.50578-2-david.hunt@intel.com/",
    "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",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20180912144930.50578-2-david.hunt@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180912144930.50578-2-david.hunt@intel.com",
    "date": "2018-09-12T14:49:24",
    "name": "[v2,1/7] examples/power: add checks around hypervisor",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "648f0a3adc94cda539b294db8d0f7763fb18896e",
    "submitter": {
        "id": 342,
        "url": "https://patches.dpdk.org/api/people/342/?format=api",
        "name": "Hunt, David",
        "email": "david.hunt@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20180912144930.50578-2-david.hunt@intel.com/mbox/",
    "series": [
        {
            "id": 1295,
            "url": "https://patches.dpdk.org/api/series/1295/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=1295",
            "date": "2018-09-12T14:49:23",
            "name": "add json power policy interface for containers",
            "version": 2,
            "mbox": "https://patches.dpdk.org/series/1295/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/44613/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/44613/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 43F964CBB;\n\tWed, 12 Sep 2018 16:50:49 +0200 (CEST)",
            "from mga14.intel.com (mga14.intel.com [192.55.52.115])\n\tby dpdk.org (Postfix) with ESMTP id 6A4FD4CA1\n\tfor <dev@dpdk.org>; Wed, 12 Sep 2018 16:50:47 +0200 (CEST)",
            "from fmsmga005.fm.intel.com ([10.253.24.32])\n\tby fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t12 Sep 2018 07:50:46 -0700",
            "from silpixa00399952.ir.intel.com (HELO\n\tsilpixa00399952.ger.corp.intel.com) ([10.237.223.64])\n\tby fmsmga005.fm.intel.com with ESMTP; 12 Sep 2018 07:49:33 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.53,365,1531810800\"; d=\"scan'208\";a=\"261983210\"",
        "From": "David Hunt <david.hunt@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "john.mcnamara@intel.com, stephen@networkplumber.org, lei.a.yao@intel.com,\n\tDavid Hunt <david.hunt@intel.com>",
        "Date": "Wed, 12 Sep 2018 15:49:24 +0100",
        "Message-Id": "<20180912144930.50578-2-david.hunt@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20180912144930.50578-1-david.hunt@intel.com>",
        "References": "<20180830105422.1198-1-david.hunt@intel.com>\n\t<20180912144930.50578-1-david.hunt@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 1/7] examples/power: add checks around\n\thypervisor",
        "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": "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": [
        "v2",
        "1/7"
    ]
}