Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com> (cherry picked from commit 9c3acba9915c23718ae8a806daa49022a73756eb)
77 lines
3.5 KiB
Diff
77 lines
3.5 KiB
Diff
From 1a4e5174a9abcc83c9ace0cf7cabbdaf03697ae3 Mon Sep 17 00:00:00 2001
|
|
From: shijiaqi1 <jiaqi@isrc.iscas.ac.cn>
|
|
Date: Wed, 8 Feb 2023 13:31:36 +0800
|
|
Subject: [PATCH 41/46] add hugepage_limit
|
|
|
|
---
|
|
.../cri/cri_container_manager_service_impl.cc | 19 +++++++++++++++++
|
|
src/daemon/entry/cri/cri_helpers.cc | 21 ++++++++++++++++++-
|
|
2 files changed, 39 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/daemon/entry/cri/cri_container_manager_service_impl.cc b/src/daemon/entry/cri/cri_container_manager_service_impl.cc
|
|
index 6278512f..5398c088 100644
|
|
--- a/src/daemon/entry/cri/cri_container_manager_service_impl.cc
|
|
+++ b/src/daemon/entry/cri/cri_container_manager_service_impl.cc
|
|
@@ -1226,6 +1226,25 @@ void ContainerManagerServiceImpl::UpdateContainerResources(const std::string &co
|
|
if (!resources.cpuset_mems().empty()) {
|
|
hostconfig->cpuset_mems = util_strdup_s(resources.cpuset_mems().c_str());
|
|
}
|
|
+ if (resources.hugepage_limits_size() != 0) {
|
|
+ hostconfig->hugetlbs = (host_config_hugetlbs_element **)util_smart_calloc_s(
|
|
+ sizeof(host_config_hugetlbs_element *), resources.hugepage_limits_size());
|
|
+ if (hostconfig->hugetlbs == nullptr) {
|
|
+ error.SetError("Out of memory");
|
|
+ return;
|
|
+ }
|
|
+ for (int i = 0; i < resources.hugepage_limits_size(); i++) {
|
|
+ hostconfig->hugetlbs[i] =
|
|
+ (host_config_hugetlbs_element *)util_common_calloc_s(sizeof(host_config_hugetlbs_element));
|
|
+ if (hostconfig->hugetlbs[i] == nullptr) {
|
|
+ error.SetError("Out of memory");
|
|
+ goto cleanup;
|
|
+ }
|
|
+ hostconfig->hugetlbs[i]->page_size = util_strdup_s(resources.hugepage_limits(i).page_size().c_str());
|
|
+ hostconfig->hugetlbs[i]->limit = resources.hugepage_limits(i).limit();
|
|
+ hostconfig->hugetlbs_len++;
|
|
+ }
|
|
+ }
|
|
|
|
request->host_config = host_config_generate_json(hostconfig, &ctx, &perror);
|
|
if (request->host_config == nullptr) {
|
|
diff --git a/src/daemon/entry/cri/cri_helpers.cc b/src/daemon/entry/cri/cri_helpers.cc
|
|
index ec14d0b2..e588b6c4 100644
|
|
--- a/src/daemon/entry/cri/cri_helpers.cc
|
|
+++ b/src/daemon/entry/cri/cri_helpers.cc
|
|
@@ -447,8 +447,27 @@ void UpdateCreateConfig(container_config *createConfig, host_config *hc,
|
|
hc->cpuset_mems = util_strdup_s(rOpts.cpuset_mems().c_str());
|
|
}
|
|
hc->oom_score_adj = rOpts.oom_score_adj();
|
|
- }
|
|
|
|
+ if (rOpts.hugepage_limits_size() != 0) {
|
|
+ hc->hugetlbs = (host_config_hugetlbs_element **)util_smart_calloc_s(sizeof(host_config_hugetlbs_element *),
|
|
+ rOpts.hugepage_limits_size());
|
|
+ if (hc->hugetlbs == nullptr) {
|
|
+ error.SetError("Out of memory");
|
|
+ return;
|
|
+ }
|
|
+ for (int i = 0; i < rOpts.hugepage_limits_size(); i++) {
|
|
+ hc->hugetlbs[i] =
|
|
+ (host_config_hugetlbs_element *)util_common_calloc_s(sizeof(host_config_hugetlbs_element));
|
|
+ if (hc->hugetlbs[i] == nullptr) {
|
|
+ error.SetError("Out of memory");
|
|
+ return;
|
|
+ }
|
|
+ hc->hugetlbs[i]->page_size = util_strdup_s(rOpts.hugepage_limits(i).page_size().c_str());
|
|
+ hc->hugetlbs[i]->limit = rOpts.hugepage_limits(i).limit();
|
|
+ hc->hugetlbs_len++;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
createConfig->open_stdin = config.stdin();
|
|
createConfig->tty = config.tty();
|
|
}
|
|
--
|
|
2.25.1
|
|
|