From 9f4732160757d6f2af5c5fcd12cb4e4f3d41bfc2 Mon Sep 17 00:00:00 2001 From: jake Date: Mon, 11 Dec 2023 10:35:06 +0000 Subject: [PATCH] !272 sync from upstream * sync from upstream --- ...ked-and-readonly-path-in-host-config.patch | 2 +- ...79-sanbox-del-containers-in-metadata.patch | 2 +- ...dd-function-to-transfer-of-ownership.patch | 2 +- ...3-network-support-version-opt-result.patch | 4 +- ...r-process-state-and-add-needed-util-.patch | 2 +- 0006-add-unit-test-for-util-function.patch | 2 +- 0007-Restore-subnet-gateway-etc-in-ipam.patch | 36 ++++ 0008-improve-error-of-lcr-apis.patch | 169 ++++++++++++++++++ 0009-Add-ncurses-devel-for-gateway.patch | 33 ++++ ...-Add-declaration-macro-for-unit-test.patch | 69 +++++++ 0011-update-src-runtime-lcrcontainer.c.patch | 59 ++++++ ...292-add-blkio-info-for-runtime-stats.patch | 64 +++++++ ...dd-macro-for-define-cleanup-function.patch | 112 ++++++++++++ lcr.spec | 15 +- 14 files changed, 563 insertions(+), 8 deletions(-) create mode 100644 0007-Restore-subnet-gateway-etc-in-ipam.patch create mode 100644 0008-improve-error-of-lcr-apis.patch create mode 100644 0009-Add-ncurses-devel-for-gateway.patch create mode 100644 0010-293-Add-declaration-macro-for-unit-test.patch create mode 100644 0011-update-src-runtime-lcrcontainer.c.patch create mode 100644 0012-292-add-blkio-info-for-runtime-stats.patch create mode 100644 0013-296-Add-macro-for-define-cleanup-function.patch diff --git a/0001-280-Add-masked-and-readonly-path-in-host-config.patch b/0001-280-Add-masked-and-readonly-path-in-host-config.patch index b93994d..b021de1 100644 --- a/0001-280-Add-masked-and-readonly-path-in-host-config.patch +++ b/0001-280-Add-masked-and-readonly-path-in-host-config.patch @@ -1,7 +1,7 @@ From dcdc428e0e48333405966e6c1188e77f8d2f550b Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 8 Nov 2023 01:09:36 +0000 -Subject: [PATCH 1/6] !280 Add masked and readonly path in host config * Add +Subject: [PATCH 01/13] !280 Add masked and readonly path in host config * Add masked and readonly path in host config --- diff --git a/0002-279-sanbox-del-containers-in-metadata.patch b/0002-279-sanbox-del-containers-in-metadata.patch index da31f45..f442694 100644 --- a/0002-279-sanbox-del-containers-in-metadata.patch +++ b/0002-279-sanbox-del-containers-in-metadata.patch @@ -1,7 +1,7 @@ From 0372a70a82a39b69e07b0953a9e7f1d25aa84ad0 Mon Sep 17 00:00:00 2001 From: liuxu Date: Wed, 8 Nov 2023 01:10:05 +0000 -Subject: [PATCH 2/6] !279 sanbox:del containers in metadata * sanbox:del +Subject: [PATCH 02/13] !279 sanbox:del containers in metadata * sanbox:del containers in metadata --- diff --git a/0003-add-function-to-transfer-of-ownership.patch b/0003-add-function-to-transfer-of-ownership.patch index 64ca6f2..8e2eae7 100644 --- a/0003-add-function-to-transfer-of-ownership.patch +++ b/0003-add-function-to-transfer-of-ownership.patch @@ -1,7 +1,7 @@ From fd369e066c94ba19e4233dc36030441754220553 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Wed, 8 Nov 2023 10:32:43 +0800 -Subject: [PATCH 3/6] add function to transfer of ownership +Subject: [PATCH 03/13] add function to transfer of ownership Signed-off-by: haozi007 --- diff --git a/0004-283-network-support-version-opt-result.patch b/0004-283-network-support-version-opt-result.patch index e0dd5da..5d3fc57 100644 --- a/0004-283-network-support-version-opt-result.patch +++ b/0004-283-network-support-version-opt-result.patch @@ -1,8 +1,8 @@ From 73ed2ec4771fd79912f1683ce094fc6d1becbf58 Mon Sep 17 00:00:00 2001 From: liuxu Date: Fri, 10 Nov 2023 09:20:41 +0000 -Subject: [PATCH 4/6] !283 network:support version opt result * network:support - version opt result +Subject: [PATCH 04/13] !283 network:support version opt result * + network:support version opt result --- src/json/schema/cni/{version.json => version_info.json} | 3 +++ diff --git a/0005-add-attach-fd-for-process-state-and-add-needed-util-.patch b/0005-add-attach-fd-for-process-state-and-add-needed-util-.patch index 35daa82..1aad96c 100644 --- a/0005-add-attach-fd-for-process-state-and-add-needed-util-.patch +++ b/0005-add-attach-fd-for-process-state-and-add-needed-util-.patch @@ -1,7 +1,7 @@ From d8a706eb0e0ba937d8b99dadbbad2771469eef97 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Wed, 8 Nov 2023 15:40:01 +0800 -Subject: [PATCH 5/6] add attach fd for process state and add needed util +Subject: [PATCH 05/13] add attach fd for process state and add needed util function Signed-off-by: zhongtao diff --git a/0006-add-unit-test-for-util-function.patch b/0006-add-unit-test-for-util-function.patch index e17024c..5d5ee34 100644 --- a/0006-add-unit-test-for-util-function.patch +++ b/0006-add-unit-test-for-util-function.patch @@ -1,7 +1,7 @@ From e072071325b04d362b1eee69aed5c75199799fa5 Mon Sep 17 00:00:00 2001 From: zhongtao Date: Mon, 13 Nov 2023 15:20:05 +0800 -Subject: [PATCH 6/6] add unit test for util function +Subject: [PATCH 06/13] add unit test for util function Signed-off-by: zhongtao --- diff --git a/0007-Restore-subnet-gateway-etc-in-ipam.patch b/0007-Restore-subnet-gateway-etc-in-ipam.patch new file mode 100644 index 0000000..cc8df69 --- /dev/null +++ b/0007-Restore-subnet-gateway-etc-in-ipam.patch @@ -0,0 +1,36 @@ +From 90aa98210bdfdefc878efdc78b3e778bf5158026 Mon Sep 17 00:00:00 2001 +From: jikai +Date: Thu, 16 Nov 2023 10:25:27 +0800 +Subject: [PATCH 07/13] Restore subnet, gateway etc in ipam + +Signed-off-by: jikai +--- + src/json/schema/cni/net_conf.json | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/src/json/schema/cni/net_conf.json b/src/json/schema/cni/net_conf.json +index ccad8ba..ae8c8e4 100644 +--- a/src/json/schema/cni/net_conf.json ++++ b/src/json/schema/cni/net_conf.json +@@ -29,6 +29,18 @@ + "type": { + "type": "string" + }, ++ "subnet": { ++ "type": "string" ++ }, ++ "gateway": { ++ "type": "string" ++ }, ++ "rangeStart": { ++ "type": "string" ++ }, ++ "rangeEnd": { ++ "type": "string" ++ }, + "routes": { + "type": "array", + "items": { +-- +2.33.0 + diff --git a/0008-improve-error-of-lcr-apis.patch b/0008-improve-error-of-lcr-apis.patch new file mode 100644 index 0000000..1890c90 --- /dev/null +++ b/0008-improve-error-of-lcr-apis.patch @@ -0,0 +1,169 @@ +From 978f1df2f4e5317ce6f0ab8db29cc07d9c7fe30c Mon Sep 17 00:00:00 2001 +From: haozi007 +Date: Thu, 16 Nov 2023 10:58:52 +0800 +Subject: [PATCH 08/13] improve error of lcr apis + +Signed-off-by: haozi007 +--- + src/runtime/error.h | 1 + + src/runtime/lcrcontainer.c | 41 +++++++++++++++++++++++++------------- + 2 files changed, 28 insertions(+), 14 deletions(-) + +diff --git a/src/runtime/error.h b/src/runtime/error.h +index a778302..dee86ca 100644 +--- a/src/runtime/error.h ++++ b/src/runtime/error.h +@@ -52,6 +52,7 @@ extern __thread engine_error_t g_lcr_error; + XX(ERR_FORMAT, "Error message is too long") \ + XX(ERR_INPUT, "Invalid input parameter") \ + XX(ERR_INTERNAL, "Server internal error") \ ++ XX(ERR_CONFIG, "Invalid container config") \ + \ + /* err in runtime module */ \ + XX(ERR_RUNTIME, DEF_ERR_RUNTIME_STR) \ +diff --git a/src/runtime/lcrcontainer.c b/src/runtime/lcrcontainer.c +index a9b06c5..0b430ca 100644 +--- a/src/runtime/lcrcontainer.c ++++ b/src/runtime/lcrcontainer.c +@@ -355,7 +355,8 @@ bool lcr_kill(const char *name, const char *lcrpath, uint32_t signal) + + c = lxc_container_new(name, path); + if (c == NULL) { +- ERROR("Failed to stop container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for kill: %s", name); ++ ERROR("Failed to load config for kill: %s.", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -403,7 +404,8 @@ bool lcr_delete(const char *name, const char *lcrpath) + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, path); + if (c == NULL) { +- ERROR("Failed to delete container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for delete: %s", name); ++ ERROR("Failed to load config for delete: %s.", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -476,7 +478,8 @@ bool lcr_exec(const struct lcr_exec_request *request, int *exit_code) + + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to delete container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for exec: %s", name); ++ ERROR("Failed to load config for exec: %s.", name); + goto out; + } + +@@ -521,7 +524,8 @@ bool lcr_clean(const char *name, const char *lcrpath, const char *logpath, const + + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to delete container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for clean: %s", name); ++ ERROR("Failed to load config for clean: %s.", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -565,7 +569,8 @@ bool lcr_state(const char *name, const char *lcrpath, struct lcr_container_state + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failure to retrieve state infomation on %s", tmp_path); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for state: %s", name); ++ ERROR("Failed to load config %s for state: %s", tmp_path, name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -602,7 +607,8 @@ bool lcr_get_container_pids(const char *name, const char *lcrpath, pid_t **pids, + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failure to retrieve state infomation on %s", tmp_path); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for get pids of: %s", name); ++ ERROR("Failed to load config for get pids of: %s", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -653,7 +659,8 @@ bool lcr_pause(const char *name, const char *lcrpath) + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to pause container"); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for pause: %s", name); ++ ERROR("Failed to load config for pause: %s.", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -696,7 +703,8 @@ bool lcr_resume(const char *name, const char *lcrpath) + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to resume container"); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for resume: %s", name); ++ ERROR("Failed to load config for resume: %s.", name); + goto out; + } + +@@ -740,7 +748,8 @@ bool lcr_resize(const char *name, const char *lcrpath, unsigned int height, unsi + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to pause container"); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for resize: %s", name); ++ ERROR("Failed to load config for resize: %s", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -763,7 +772,7 @@ bool lcr_resize(const char *name, const char *lcrpath, unsigned int height, unsi + } + + if (!c->set_terminal_winch(c, height, width)) { +- ERROR("Failed to pause"); ++ ERROR("Failed to resize: %s", name); + bret = false; + goto out_put; + } +@@ -790,7 +799,8 @@ bool lcr_exec_resize(const char *name, const char *lcrpath, const char *suffix, + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to pause container"); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for exec resize: %s", name); ++ ERROR("Failed to load config for exec resize: %s.", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -839,7 +849,8 @@ bool lcr_console(const char *name, const char *lcrpath, const char *in_fifo, con + + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to create container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for attach: %s", name); ++ ERROR("Failed to load config for attach: %s.", name); + bresult = false; + goto out; + } +@@ -977,7 +988,8 @@ bool lcr_get_console_config(const char *name, const char *lcrpath, struct lcr_co + isula_libutils_set_log_prefix(name); + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to create container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for get console config of: %s", name); ++ ERROR("Failed to load config for get config of: %s.", name); + isula_libutils_free_log_prefix(); + return false; + } +@@ -1027,7 +1039,8 @@ bool lcr_update(const char *name, const char *lcrpath, const struct lcr_cgroup_r + + c = lxc_container_new(name, tmp_path); + if (c == NULL) { +- ERROR("Failed to new container."); ++ lcr_set_error_message(LCR_ERR_CONFIG, "Failed to load config for udpate: %s", name); ++ ERROR("Failed to load config for update: %s.", name); + goto out_free; + } + +-- +2.33.0 + diff --git a/0009-Add-ncurses-devel-for-gateway.patch b/0009-Add-ncurses-devel-for-gateway.patch new file mode 100644 index 0000000..2b2512d --- /dev/null +++ b/0009-Add-ncurses-devel-for-gateway.patch @@ -0,0 +1,33 @@ +From ad30ae4232ed8dfdf0b352997e09070b31592953 Mon Sep 17 00:00:00 2001 +From: xuxuepeng +Date: Thu, 23 Nov 2023 20:17:45 +0800 +Subject: [PATCH 09/13] Add ncurses-devel for gateway + +Signed-off-by: xuxuepeng +--- + CI/pr-gateway.sh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/CI/pr-gateway.sh b/CI/pr-gateway.sh +index 032b3f8..73c3bc5 100755 +--- a/CI/pr-gateway.sh ++++ b/CI/pr-gateway.sh +@@ -18,7 +18,7 @@ sed -i "s#http://repo.openeuler.org#https://repo.huaweicloud.com/openeuler#g" /e + + dnf update -y + +-dnf install -y python3-pip docbook2X doxygen gtest-devel gmock-devel diffutils cmake gcc-c++ yajl-devel patch make libtool libevent-devel libevhtp-devel grpc grpc-plugins grpc-devel protobuf-devel libcurl libcurl-devel sqlite-devel libarchive-devel device-mapper-devel http-parser-devel libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel systemd-devel git chrpath ++dnf install -y python3-pip docbook2X doxygen gtest-devel gmock-devel diffutils cmake gcc-c++ yajl-devel patch make libtool libevent-devel libevhtp-devel grpc grpc-plugins grpc-devel protobuf-devel libcurl libcurl-devel sqlite-devel libarchive-devel device-mapper-devel http-parser-devel libseccomp-devel libcap-devel libselinux-devel libwebsockets libwebsockets-devel systemd-devel git chrpath ncurses-devel + if [ $? -ne 0 ]; then + echo "install dependences failed" + exit 1 +@@ -78,4 +78,4 @@ pushd lcr + pushd build + ctest -V || exit 1 + popd +-popd +\ No newline at end of file ++popd +-- +2.33.0 + diff --git a/0010-293-Add-declaration-macro-for-unit-test.patch b/0010-293-Add-declaration-macro-for-unit-test.patch new file mode 100644 index 0000000..739f2d4 --- /dev/null +++ b/0010-293-Add-declaration-macro-for-unit-test.patch @@ -0,0 +1,69 @@ +From 87e8dc5ae7d6de1aa9f75f13a57fec769d9edae3 Mon Sep 17 00:00:00 2001 +From: xuxuepeng +Date: Thu, 23 Nov 2023 12:49:19 +0000 +Subject: [PATCH 10/13] !293 Add declaration macro for unit test * Add + declaration macro for unit test + +--- + CMakeLists.txt | 1 + + src/utils/utils_macro.h | 35 +++++++++++++++++++++++++++++++++++ + 2 files changed, 36 insertions(+) + create mode 100644 src/utils/utils_macro.h + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4bf5335..f61bc1f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -134,6 +134,7 @@ install(FILES src/utils/utils_buffer.h DESTINATION include/isula_libutils) + install(FILES src/utils/utils_convert.h DESTINATION include/isula_libutils) + install(FILES src/utils/utils_file.h DESTINATION include/isula_libutils) + install(FILES src/utils/utils_linked_list.h DESTINATION include/isula_libutils) ++install(FILES src/utils/utils_macro.h DESTINATION include/isula_libutils) + install(FILES src/utils/utils_mainloop.h DESTINATION include/isula_libutils) + install(FILES src/utils/utils_memory.h DESTINATION include/isula_libutils) + install(FILES src/utils/utils_string.h DESTINATION include/isula_libutils) +diff --git a/src/utils/utils_macro.h b/src/utils/utils_macro.h +new file mode 100644 +index 0000000..9e1bc0a +--- /dev/null ++++ b/src/utils/utils_macro.h +@@ -0,0 +1,35 @@ ++/****************************************************************************** ++ * isula: macro definitions for isula ++ * ++ * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved. ++ * ++ * Authors: ++ * xuxuepeng ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ++ ********************************************************************************/ ++ ++#ifndef _ISULA_UTILS_MACRO_H ++#define _ISULA_UTILS_MACRO_H ++ ++#ifndef UNIT_TEST ++#define STATIC static ++#define INLINE inline ++#else ++#define STATIC ++#define INLINE ++#endif ++ ++#endif // _ISULA_UTILS_MACRO_H +\ No newline at end of file +-- +2.33.0 + diff --git a/0011-update-src-runtime-lcrcontainer.c.patch b/0011-update-src-runtime-lcrcontainer.c.patch new file mode 100644 index 0000000..3e3e15c --- /dev/null +++ b/0011-update-src-runtime-lcrcontainer.c.patch @@ -0,0 +1,59 @@ +From 27ee841b8ee02a5e87c0d0754fb0bd13b1e986f8 Mon Sep 17 00:00:00 2001 +From: gaojiazhen +Date: Thu, 23 Nov 2023 18:23:10 +0000 +Subject: [PATCH 11/13] =?UTF-8?q?update=20src/runtime/lcrcontainer.c.=201?= + =?UTF-8?q?=E3=80=81=E4=BD=BF=E4=B8=8A=E4=B8=8B=E6=96=87=E7=9A=84=E5=8A=A8?= + =?UTF-8?q?=E8=AF=8D=E6=97=B6=E6=80=81=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= + =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=AD=A3114=E8=A1=8C=E7=9A=84=E2=80=9Cunlink?= + =?UTF-8?q?=E2=80=9D=E4=B8=BA=E2=80=9Cunlinking=E2=80=9D=E3=80=82=202?= + =?UTF-8?q?=E3=80=81=E8=A7=84=E8=8C=83SYSERROR=E5=86=85=E5=AE=B9=E7=9A=84?= + =?UTF-8?q?=E8=AF=AD=E6=B3=95=EF=BC=8C=E4=BF=AE=E6=AD=A3215=E8=A1=8C?= + =?UTF-8?q?=E7=9A=84=E2=80=9Callocated=E2=80=9D=E4=B8=BA=E2=80=9Callocated?= + =?UTF-8?q?=E2=80=9D=E3=80=82=203=E3=80=81=E4=BD=BF=E4=B8=8A=E4=B8=8B?= + =?UTF-8?q?=E6=96=87=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=E7=9A=84?= + =?UTF-8?q?=E7=94=A8=E6=B3=95=E4=B8=80=E8=87=B4=EF=BC=8C=E4=BF=AE=E6=AD=A3?= + =?UTF-8?q?241=E8=A1=8C=E7=9A=84=E2=80=9Cbegin"=E4=B8=BA=E2=80=9CBegin?= + =?UTF-8?q?=E2=80=9D=E3=80=82?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: gaojiazhen +--- + src/runtime/lcrcontainer.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/runtime/lcrcontainer.c b/src/runtime/lcrcontainer.c +index 0b430ca..f93afb8 100644 +--- a/src/runtime/lcrcontainer.c ++++ b/src/runtime/lcrcontainer.c +@@ -111,7 +111,7 @@ static void remove_partial(const struct lxc_container *c) + goto out_free; + } + if (unlink(path) < 0) { +- SYSERROR("Error unlink partial file %s", path); ++ SYSERROR("Error unlinking partial file %s", path); + } + + out_free: +@@ -212,7 +212,7 @@ static bool lcr_start_check_config(const char *lcrpath, const char *name) + + nret = snprintf(config, sizeof(config), "%s/%s/config", lcrpath, name); + if (nret < 0 || (size_t)nret >= sizeof(config)) { +- SYSERROR("Failed to allocated memory"); ++ SYSERROR("Failed to allocate memory"); + return false; + } + +@@ -238,7 +238,7 @@ static bool wait_start_pid(pid_t pid, int rfd, const char *name, const char *pat + // set default error + lcr_set_error_message(LCR_ERR_RUNTIME, "runtime error"); + +- INFO("begin to stop container\n"); ++ INFO("Begin to stop container\n"); + if (!lcr_kill(name, path, SIGKILL)) { + ERROR("Failed to stop container"); + } +-- +2.33.0 + diff --git a/0012-292-add-blkio-info-for-runtime-stats.patch b/0012-292-add-blkio-info-for-runtime-stats.patch new file mode 100644 index 0000000..64a3dab --- /dev/null +++ b/0012-292-add-blkio-info-for-runtime-stats.patch @@ -0,0 +1,64 @@ +From 9b3b233ddcddbe83f5e7f8bc658f9cd3e6a5c674 Mon Sep 17 00:00:00 2001 +From: zhongtao +Date: Wed, 29 Nov 2023 09:33:13 +0000 +Subject: [PATCH 12/13] !292 add blkio info for runtime-stats * add blkio info + for runtime-stats + +--- + src/json/schema/defs.json | 17 +++++++++++++++++ + src/json/schema/shim/client/runtime-stats.json | 11 +++++++++++ + 2 files changed, 28 insertions(+) + +diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json +index ad6f6d8..22683c2 100644 +--- a/src/json/schema/defs.json ++++ b/src/json/schema/defs.json +@@ -128,6 +128,23 @@ + } + } + }, ++ "BlkioEntry": { ++ "type": "object", ++ "properties": { ++ "major": { ++ "$ref": "#/definitions/uint64" ++ }, ++ "minor": { ++ "$ref": "#/definitions/uint64" ++ }, ++ "op": { ++ "type": "string" ++ }, ++ "value": { ++ "$ref": "#/definitions/uint64" ++ } ++ } ++ }, + "ArrayOfBlkioWeightDevice": { + "type": "array", + "items": { +diff --git a/src/json/schema/shim/client/runtime-stats.json b/src/json/schema/shim/client/runtime-stats.json +index 6fdc579..35cfe64 100644 +--- a/src/json/schema/shim/client/runtime-stats.json ++++ b/src/json/schema/shim/client/runtime-stats.json +@@ -65,6 +65,17 @@ + } + } + } ++ }, ++ "blkio": { ++ "type": "object", ++ "properties": { ++ "ioServiceBytesRecursive": { ++ "type": "array", ++ "items": { ++ "$ref": "../../defs.json#/definitions/BlkioEntry" ++ } ++ } ++ } + } + } + } +-- +2.33.0 + diff --git a/0013-296-Add-macro-for-define-cleanup-function.patch b/0013-296-Add-macro-for-define-cleanup-function.patch new file mode 100644 index 0000000..442028a --- /dev/null +++ b/0013-296-Add-macro-for-define-cleanup-function.patch @@ -0,0 +1,112 @@ +From 0f372e949a554b06210bca5a09fff3264ea4be1c Mon Sep 17 00:00:00 2001 +From: xuxuepeng +Date: Thu, 30 Nov 2023 07:42:18 +0000 +Subject: [PATCH 13/13] !296 Add macro for define cleanup function * Add macro + for define cleanup function + +--- + src/auto_cleanup.h | 23 +++++++++++++------ + tests/auto_cleanup_ut.cpp | 48 ++++++++++++++++++++++++++++++++++++++- + 2 files changed, 63 insertions(+), 8 deletions(-) + +diff --git a/src/auto_cleanup.h b/src/auto_cleanup.h +index 6d04372..95b6294 100644 +--- a/src/auto_cleanup.h ++++ b/src/auto_cleanup.h +@@ -57,20 +57,29 @@ extern "C" { + #define auto_cleanup_tag(name) __attribute__((__cleanup__(name##_cb))) + + // define all used auto tags +-#define __isula_auto_free auto_cleanup_tag(free_pointer) ++#define __isula_auto_free auto_cleanup_tag(free) + #define __isula_auto_file auto_cleanup_tag(close_file) + #define __isula_auto_dir auto_cleanup_tag(close_dir) + #define __isula_auto_close auto_cleanup_tag(auto_close) + #define __isula_auto_pm_unlock auto_cleanup_tag(auto_pm_unlock) + #define __isula_auto_prw_unlock auto_cleanup_tag(auto_prw_unlock) + +-static inline void free_pointer_cb(void *ptr) +-{ +- void *real = *(void **)ptr; +- if (real != NULL) { +- free(real); ++/* ++ * define auto cleanup callback for the type free function. ++ * _cleanup_func: the type free function, must be void type and ++ * accept one parameter with type _type *. ++ * _type: the type of the pointer to be cleaned up. ++ */ ++#define define_auto_cleanup_callback(_cleanup_func, _type) \ ++ static inline void _cleanup_func##_cb(void *p) \ ++ { \ ++ _type *_p = *(_type **)p; \ ++ if (_p != NULL) { \ ++ _cleanup_func(_p); \ ++ } \ + } +-} ++ ++define_auto_cleanup_callback(free, void) + + static inline void close_file_cb(FILE **p) + { +diff --git a/tests/auto_cleanup_ut.cpp b/tests/auto_cleanup_ut.cpp +index 2600d56..760f0dd 100644 +--- a/tests/auto_cleanup_ut.cpp ++++ b/tests/auto_cleanup_ut.cpp +@@ -248,4 +248,50 @@ TEST(autocleanup_testcase, test__isula_auto_close) + inner_fd = open("/proc/self/cmdline", 0444); + openfd = inner_fd; + } +-} +\ No newline at end of file ++} ++ ++static bool g_test_auto_cleanup_callback_called = false; ++ ++typedef struct foo { ++ int *a; ++ int *b; ++} foo_t; ++ ++void foo_free(foo_t *f) ++{ ++ if (f == nullptr) { ++ return; ++ } ++ if (f->a != nullptr) { ++ free(f->a); ++ f->a = nullptr; ++ } ++ if (f->b != nullptr) { ++ free(f->b); ++ f->b = nullptr; ++ } ++ g_test_auto_cleanup_callback_called = true; ++ free(f); ++} ++ ++define_auto_cleanup_callback(foo_free, foo_t); ++#define __isula_auto_foo_t auto_cleanup_tag(foo_free) ++ ++void do_auto_cleanup_callback() ++{ ++ __isula_auto_foo_t foo_t *f = nullptr; ++ ++ f = static_cast(malloc(sizeof(foo_t))); ++ f->a = static_cast(malloc(sizeof(int))); ++ f->b = static_cast(malloc(sizeof(int))); ++ *(f->a) = 1; ++ *(f->b) = 2; ++} ++ ++TEST(autocleanup_testcase, test_define_auto_cleanup_callback) ++{ ++ g_test_auto_cleanup_callback_called = false; ++ do_auto_cleanup_callback(); ++ // check if the callback function is called ++ ASSERT_EQ(g_test_auto_cleanup_callback_called, true); ++} +-- +2.33.0 + diff --git a/lcr.spec b/lcr.spec index c672e59..66ed790 100644 --- a/lcr.spec +++ b/lcr.spec @@ -1,5 +1,5 @@ %global _version 2.1.3 -%global _release 2 +%global _release 3 %global _inner_name isula_libutils %global enable_lxc 1 @@ -19,6 +19,13 @@ Patch0003: 0003-add-function-to-transfer-of-ownership.patch Patch0004: 0004-283-network-support-version-opt-result.patch Patch0005: 0005-add-attach-fd-for-process-state-and-add-needed-util-.patch Patch0006: 0006-add-unit-test-for-util-function.patch +Patch0007: 0007-Restore-subnet-gateway-etc-in-ipam.patch +Patch0008: 0008-improve-error-of-lcr-apis.patch +Patch0009: 0009-Add-ncurses-devel-for-gateway.patch +Patch0010: 0010-293-Add-declaration-macro-for-unit-test.patch +Patch0011: 0011-update-src-runtime-lcrcontainer.c.patch +Patch0012: 0012-292-add-blkio-info-for-runtime-stats.patch +Patch0013: 0013-296-Add-macro-for-define-cleanup-function.patch %define lxcver_lower 4.0.3-2022102400 %define lxcver_upper 5.0.3 @@ -134,6 +141,12 @@ rm -rf %{buildroot} %{_includedir}/lcr/utils_compile.h %changelog +* Mon Dec 11 2023 jikai - 2.1.3-3 +- Type:enhancement +- CVE:NA +- SUG:NA +- DESC:sync from upstream + * Wed Nov 15 2023 jikai - 2.1.3-2 - Type:enhancement - CVE:NA