!255 sync from upstream

* sync from upstream
This commit is contained in:
jake 2023-09-19 02:57:15 +00:00 committed by haozi007
parent 85e8076a5a
commit d88219c525
27 changed files with 3101 additions and 837 deletions

View File

@ -1,71 +0,0 @@
From 83b3f2f2b114915c250bdc4500138a8531750192 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Mon, 6 Feb 2023 20:36:17 +0800
Subject: [PATCH] add libisula.pc
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
CMakeLists.txt | 7 +++++++
lcr.pc.in | 2 +-
libisula.pc.in | 12 ++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
create mode 100644 libisula.pc.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1acbab..8ee67c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,6 +75,11 @@ configure_file(
"${CMAKE_BINARY_DIR}/conf/lcr.pc"
)
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/libisula.pc.in"
+ "${CMAKE_BINARY_DIR}/conf/libisula.pc"
+)
+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
@@ -112,6 +117,8 @@ endif()
# install all files
install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc
DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_EXECUTE)
+install(FILES ${CMAKE_BINARY_DIR}/conf/libisula.pc
+ DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_EXECUTE)
install(FILES src/lcrcontainer.h
DESTINATION include/lcr)
diff --git a/lcr.pc.in b/lcr.pc.in
index e102dbb..419e187 100644
--- a/lcr.pc.in
+++ b/lcr.pc.in
@@ -7,6 +7,6 @@ Name: liblcr
Description: light-weighted container runtime library
Version: @LCR_VERSION@
URL: liblcr
-Libs: -L@CMAKE_INSTALL_PREFIX@/lib -llcr -lisula_libutils
+Libs: -L@CMAKE_INSTALL_PREFIX@/lib -llcr
Cflags: -I@CMAKE_INSTALL_PREFIX@/include
diff --git a/libisula.pc.in b/libisula.pc.in
new file mode 100644
index 0000000..2738dd3
--- /dev/null
+++ b/libisula.pc.in
@@ -0,0 +1,12 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_PREFIX@/lib
+localstatedir=@CMAKE_INSTALL_PREFIX@/var
+includedir=@CMAKE_INSTALL_PREFIX@/include
+
+Name: libisula
+Description: light-weighted container json and log libraries
+Version: @LCR_VERSION@
+URL: libisula
+Libs: -L@CMAKE_INSTALL_PREFIX@/lib -lisula_libutils
+Cflags: -I@CMAKE_INSTALL_PREFIX@/include
+
--
2.25.1

View File

@ -0,0 +1,37 @@
From 6646d4020ba6e1ea2bf4a129cd7188368e18d3bc Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Sat, 26 Aug 2023 10:54:02 +0800
Subject: [PATCH 1/8] support check symbols and compile code in cmake
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
cmake/checker.cmake | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/cmake/checker.cmake b/cmake/checker.cmake
index 13c1cdb..27a83d1 100644
--- a/cmake/checker.cmake
+++ b/cmake/checker.cmake
@@ -20,6 +20,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
+include(CheckFunctionExists)
+include(CheckCSourceCompiles)
+
# check depends library and headers
find_package(PkgConfig REQUIRED)
@@ -91,3 +94,9 @@ if (ENABLE_GCOV)
_CHECK(CMD_GENHTML "CMD_GENHTML-NOTFOUND" "genhtml")
endif()
+check_function_exists(strerror_r HAVE_STRERROR_R)
+
+check_c_source_compiles(
+ "#define _GNU_SOURCE\n#include <string.h>\nint main() { char err_str[128]; char *ptr = strerror_r(-2, err_str, 128); return ptr != (void *)0L; }"
+ STRERROR_R_CHAR_P
+)
--
2.34.1

View File

@ -1,51 +0,0 @@
From 9bd736bc14da91bfc6ca8bf38f05218e5703adf5 Mon Sep 17 00:00:00 2001
From: "ilya.kuksenok" <ilya.kuksenok@huawei.com>
Date: Tue, 7 Feb 2023 13:51:44 +0300
Subject: [PATCH 2/4] add unified and memory_swap_limit_in_bytes into
host-config
---
.gitignore | 2 ++
src/json/schema/host-config.json | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 0995486..973ceef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
*.pyc
build
.vscode
+.idea
+cmake-build-debug
diff --git a/src/json/schema/host-config.json b/src/json/schema/host-config.json
index c308558..0367a76 100644
--- a/src/json/schema/host-config.json
+++ b/src/json/schema/host-config.json
@@ -139,9 +139,15 @@
"Memory": {
"type": "int64"
},
+ "Unified": {
+ "$ref": "defs.json#/definitions/mapStringString"
+ },
"OomScoreAdj": {
"type": "integer"
},
+ "MemorySwapLimitInBytes":{
+ "type": "int64"
+ },
"BlkioWeight": {
"type": "uint16"
},
@@ -292,4 +298,4 @@
"type": "string"
}
}
-}
\ No newline at end of file
+}
--
2.25.1

View File

@ -0,0 +1,97 @@
From 24579633671fca855dd1c66a4d7614ccf2e7e388 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 5 Sep 2023 19:35:37 +0800
Subject: [PATCH 2/8] remove unnecessary strerror
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
src/runtime/lcrcontainer_execute.c | 3 +--
src/runtime/lcrcontainer_extend.c | 16 ++++++++--------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/runtime/lcrcontainer_execute.c b/src/runtime/lcrcontainer_execute.c
index 864c097..f2bb944 100644
--- a/src/runtime/lcrcontainer_execute.c
+++ b/src/runtime/lcrcontainer_execute.c
@@ -71,8 +71,7 @@
do \
{ \
SYSERROR("Error updating cgroup %s to %s", (item), (value)); \
- lcr_set_error_message(LCR_ERR_RUNTIME, "Error updating cgroup %s to %s: %s", (item), (value), \
- strerror(errno)); \
+ lcr_set_error_message(LCR_ERR_RUNTIME, "Error updating cgroup %s to %s.", (item), (value)); \
} while (0)
static inline void add_array_elem(char **array, size_t total, size_t *pos, const char *elem)
diff --git a/src/runtime/lcrcontainer_extend.c b/src/runtime/lcrcontainer_extend.c
index 2f3ae9f..8b5a85c 100644
--- a/src/runtime/lcrcontainer_extend.c
+++ b/src/runtime/lcrcontainer_extend.c
@@ -153,7 +153,7 @@ static int make_annotations(oci_runtime_spec *container, const struct lxc_contai
goto out;
}
if (lcr_util_ensure_path(&realpath, anno->values[fpos])) {
- ERROR("Invalid log path: %s, error: %s.", anno->values[fpos], strerror(errno));
+ SYSERROR("Invalid log path: %s.", anno->values[fpos]);
goto out;
}
ret = 0;
@@ -378,7 +378,7 @@ static int lcr_spec_write_seccomp_line(FILE *fp, const char *seccomp)
line[nret] = '\n';
if (fwrite(line, 1, len ,fp) != len) {
- ERROR("Write file failed: %s", strerror(errno));
+ SYSERROR("Write file failed");
goto cleanup;
}
@@ -743,8 +743,8 @@ static FILE *lcr_open_config_file(const char *bundle)
fd = lcr_util_open(real_config, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE);
if (fd == -1) {
- ERROR("Create file %s failed, %s", real_config, strerror(errno));
- lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed, %s", real_config, strerror(errno));
+ SYSERROR("Create file %s failed", real_config);
+ lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed", real_config);
goto out;
}
@@ -856,7 +856,7 @@ static int lcr_spec_write_config(FILE *fp, const struct lcr_list *lcr_conf)
line_encode[len] = '\n';
if (fwrite(line_encode, 1, len + 1, fp) != len + 1) {
- ERROR("Write file failed: %s", strerror(errno));
+ SYSERROR("Write file failed");
goto cleanup;
}
@@ -908,7 +908,7 @@ char *lcr_get_bundle(const char *lcrpath, const char *name)
ERROR("Bundle %s does not exist", bundle);
break;
default:
- ERROR("Access %s failed: %s\n", bundle, strerror(errno));
+ SYSERROR("Access %s failed", bundle);
}
goto cleanup;
}
@@ -995,7 +995,7 @@ static int lcr_write_file(const char *path, const char *data, size_t len)
}
if (write(fd, data, len) == -1) {
- ERROR("write data to %s failed: %s", real_path, strerror(errno));
+ SYSERROR("write data to %s failed", real_path);
goto out_free;
}
@@ -1023,7 +1023,7 @@ static bool lcr_write_ocihooks(const char *path, const oci_runtime_spec_hooks *h
}
if (lcr_write_file(path, json_hooks, strlen(json_hooks)) == -1) {
- ERROR("write json hooks failed: %s", strerror(errno));
+ SYSERROR("write json hooks failed");
goto out_free;
}
--
2.34.1

View File

@ -1,35 +0,0 @@
From d332dbb9050510f91445625b56952fd533ec530a Mon Sep 17 00:00:00 2001
From: songbuhuang <544824346@qq.com>
Date: Wed, 8 Feb 2023 10:53:25 +0800
Subject: [PATCH 3/4] fix update cpu-rt period failed
Signed-off-by: songbuhuang <544824346@qq.com>
---
src/lcrcontainer_execute.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c
index 3f5860f..ff4685b 100644
--- a/src/lcrcontainer_execute.c
+++ b/src/lcrcontainer_execute.c
@@ -360,13 +360,14 @@ static bool update_resources_cpu_v1(struct lxc_container *c, const struct lcr_cg
goto err_out;
}
- if (update_resources_cpu_rt_period(c, cr) != 0) {
- goto err_out;
- }
if (update_resources_cpu_rt_runtime(c, cr) != 0) {
goto err_out;
}
+ if (update_resources_cpu_rt_period(c, cr) != 0) {
+ goto err_out;
+ }
+
ret = true;
err_out:
return ret;
--
2.25.1

View File

@ -0,0 +1,82 @@
From 19810333a97614619a1e2c945c253c964ef02d3b Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Wed, 6 Sep 2023 14:22:21 +0800
Subject: [PATCH 3/8] improve code of function in log
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
src/runtime/lcrcontainer_execute.c | 4 ++--
src/third_party/log.c | 6 +++---
src/third_party/log.h | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/runtime/lcrcontainer_execute.c b/src/runtime/lcrcontainer_execute.c
index f2bb944..e91ff27 100644
--- a/src/runtime/lcrcontainer_execute.c
+++ b/src/runtime/lcrcontainer_execute.c
@@ -883,7 +883,7 @@ static void execute_lxc_attach(const char *name, const char *path, const struct
execvp("lxc-attach", params);
- COMMAND_ERROR("Failed to exec lxc-attach: %s", strerror(errno));
+ CMD_SYSERROR("Failed to exec lxc-attach");
free(params);
exit(EXIT_FAILURE);
}
@@ -1027,6 +1027,6 @@ void execute_lxc_start(const char *name, const char *path, const struct lcr_star
execvp("lxc-start", params);
- COMMAND_ERROR("Failed to exec lxc-start: %s.", strerror(errno));
+ CMD_SYSERROR("Failed to exec lxc-start.");
exit(EXIT_FAILURE);
}
diff --git a/src/third_party/log.c b/src/third_party/log.c
index 5ba638b..5097eb8 100644
--- a/src/third_party/log.c
+++ b/src/third_party/log.c
@@ -309,18 +309,18 @@ static int open_fifo(const char *fifo_path)
nret = mknod(fifo_path, S_IFIFO | S_IRUSR | S_IWUSR, (dev_t)0);
if (nret && errno != EEXIST) {
- COMMAND_ERROR("Mknod failed: %s", strerror(errno));
+ CMD_SYSERROR("Mknod failed");
return nret;
}
fifo_fd = lcr_util_open(fifo_path, O_RDWR | O_NONBLOCK, 0);
if (fifo_fd == -1) {
- COMMAND_ERROR("Open fifo %s failed: %s", fifo_path, strerror(errno));
+ CMD_SYSERROR("Open fifo %s failed", fifo_path);
return -1;
}
if (fcntl(fifo_fd, F_SETPIPE_SZ, LOG_FIFO_SIZE) == -1) {
- COMMAND_ERROR("Set fifo buffer size failed: %s", strerror(errno));
+ CMD_SYSERROR("Set fifo buffer size failed");
close(fifo_fd);
return -1;
}
diff --git a/src/third_party/log.h b/src/third_party/log.h
index 3462b17..d0e5fa8 100644
--- a/src/third_party/log.h
+++ b/src/third_party/log.h
@@ -417,13 +417,13 @@ lxc_log_priority_define(&g_lxc_log_category_lxc, FATAL);
#define CMD_SYSERROR(format, ...) \
do { \
lxc_log_strerror_r; \
- fprintf(stderr, "%s - " format, ptr, ##__VA_ARGS__); \
+ fprintf(stderr, "%s - " format "\n", ptr, ##__VA_ARGS__); \
} while (0)
#define CMD_SYSINFO(format, ...) \
do { \
lxc_log_strerror_r; \
- printf("%s - " format, ptr, ##__VA_ARGS__); \
+ printf("%s - " format "\n", ptr, ##__VA_ARGS__); \
} while (0)
#define COMMAND_ERROR(fmt, args...) \
--
2.34.1

View File

@ -1,40 +0,0 @@
From 4df2c0f530bfa62b98e22ea87a01fa567cf01ef3 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Thu, 9 Feb 2023 10:18:01 +0800
Subject: [PATCH 4/4] fix writing config line with wrong length
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/lcrcontainer_extend.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/lcrcontainer_extend.c b/src/lcrcontainer_extend.c
index f6d1465..fb43b22 100644
--- a/src/lcrcontainer_extend.c
+++ b/src/lcrcontainer_extend.c
@@ -841,7 +841,6 @@ static int lcr_spec_write_config(FILE *fp, const struct lcr_list *lcr_conf)
}
nret = snprintf(line, len, "%s = %s", item->name, item->value);
-
if (nret < 0 || (size_t)nret >= len) {
ERROR("Sprintf failed");
goto cleanup;
@@ -853,11 +852,10 @@ static int lcr_spec_write_config(FILE *fp, const struct lcr_list *lcr_conf)
goto cleanup;
}
- nret = strlen(line_encode);
-
- line_encode[nret] = '\n';
+ len = strlen(line_encode);
+ line_encode[len] = '\n';
- if (fwrite(line_encode, 1, len, fp) != len) {
+ if (fwrite(line_encode, 1, len + 1, fp) != len + 1) {
ERROR("Write file failed: %s", strerror(errno));
goto cleanup;
}
--
2.25.1

View File

@ -0,0 +1,338 @@
From ed36936f30525704f71e3b7444c1d25ffe50ab2f Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 12 Sep 2023 10:27:05 +0800
Subject: [PATCH 4/8] support visibility of compiler
use visibility for liblcr
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
CMakeLists.txt | 4 +--
src/CMakeLists.txt | 1 +
src/runtime/lcrcontainer.h | 68 ++++++++++++++++++++------------------
src/utils/utils_compile.h | 50 ++++++++++++++++++++++++++++
4 files changed, 88 insertions(+), 35 deletions(-)
create mode 100644 src/utils/utils_compile.h
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a51ac7d..e00dc96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,8 +117,8 @@ install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc
DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_EXECUTE)
install(FILES ${CMAKE_BINARY_DIR}/conf/libisula.pc
DESTINATION ${LIB_INSTALL_DIR_DEFAULT}/pkgconfig PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE WORLD_READ WORLD_EXECUTE)
-install(FILES src/runtime/lcrcontainer.h
- DESTINATION include/lcr)
+install(FILES src/runtime/lcrcontainer.h DESTINATION include/lcr)
+install(FILES src/utils/utils_compile.h DESTINATION include/lcr)
install(FILES src/third_party/log.h DESTINATION include/isula_libutils)
install(FILES src/third_party/go_crc64.h DESTINATION include/isula_libutils)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2bf468f..c423dd7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -124,6 +124,7 @@ target_include_directories(liblcr
# set liblcr compile flags
set_target_properties(liblcr PROPERTIES PREFIX "")
target_link_libraries(liblcr ${check_libs} isula_libutils)
+target_compile_options(liblcr PRIVATE -fvisibility=hidden)
if (CMAKE_TOOLCHAIN_FILE)
target_link_directories(liblcr PUBLIC ${CMAKE_LIBRARY_PATH})
diff --git a/src/runtime/lcrcontainer.h b/src/runtime/lcrcontainer.h
index edfc869..6add8c4 100644
--- a/src/runtime/lcrcontainer.h
+++ b/src/runtime/lcrcontainer.h
@@ -32,13 +32,15 @@
#include <stdbool.h>
#include <sys/types.h>
+#include "utils_compile.h"
+
#ifdef __cplusplus
extern "C" {
#endif
/* define console log config */
-struct lcr_console_config {
+__EXPORT__ struct lcr_console_config {
char *log_path;
unsigned int log_rotate;
char *log_file_size;
@@ -47,7 +49,7 @@ struct lcr_console_config {
/*
* Store lcr container info
*/
-struct lcr_container_info {
+__EXPORT__ struct lcr_container_info {
/* Name of container. */
char *name;
/* State of container. */
@@ -62,7 +64,7 @@ struct lcr_container_info {
bool running;
};
-struct blkio_stats {
+__EXPORT__ struct blkio_stats {
uint64_t read;
uint64_t write;
uint64_t total;
@@ -71,7 +73,7 @@ struct blkio_stats {
/*
* Store lcr container state
*/
-struct lcr_container_state {
+__EXPORT__ struct lcr_container_state {
/* Name of container */
char *name;
/* State of container */
@@ -108,14 +110,14 @@ typedef enum {
lcr_msg_exit_code,
} lcr_msg_type_t;
-struct lcr_msg {
+__EXPORT__ struct lcr_msg {
lcr_msg_type_t type;
char name[NAME_MAX + 1];
int value;
int pid;
};
-struct lcr_cgroup_resources {
+__EXPORT__ struct lcr_cgroup_resources {
uint64_t blkio_weight;
uint64_t cpu_shares;
uint64_t cpu_period;
@@ -134,23 +136,23 @@ struct lcr_cgroup_resources {
* Get one container info for a given lcrpath.
* return struct of container info, or NULL on error.
*/
-struct lcr_container_info *lcr_container_info_get(const char *name, const char *lcrpath);
+__EXPORT__ struct lcr_container_info *lcr_container_info_get(const char *name, const char *lcrpath);
/*
* Free lcr_container_info returned lcr_container_info_get
*/
-void lcr_container_info_free(struct lcr_container_info *info);
+__EXPORT__ void lcr_container_info_free(struct lcr_container_info *info);
/*
* Get a complete list of all containers for a given lcrpath.
* return Number of containers, or -1 on error.
*/
-int lcr_list_all_containers(const char *lcrpath, struct lcr_container_info **info_arr);
+__EXPORT__ int lcr_list_all_containers(const char *lcrpath, struct lcr_container_info **info_arr);
/*
* Free lcr_container_info array returned by lcr_list_{active,all}_containers
*/
-void lcr_containers_info_free(struct lcr_container_info **info_arr, size_t size);
+__EXPORT__ void lcr_containers_info_free(struct lcr_container_info **info_arr, size_t size);
/*
* Create a container
@@ -158,7 +160,7 @@ void lcr_containers_info_free(struct lcr_container_info **info_arr, size_t size)
* param lcrpath : container path
* param oci_json_data : json string of oci config data
*/
-bool lcr_create_from_ocidata(const char *name, const char *lcrpath, const void *oci_json_data);
+__EXPORT__ bool lcr_create_from_ocidata(const char *name, const char *lcrpath, const void *oci_json_data);
/*
* Create a container
@@ -166,7 +168,7 @@ bool lcr_create_from_ocidata(const char *name, const char *lcrpath, const void *
* param lcrpath : container path
* param oci_config : pointer of struct oci config
*/
-bool lcr_create(const char *name, const char *lcrpath, void *oci_config);
+__EXPORT__ bool lcr_create(const char *name, const char *lcrpath, void *oci_config);
/*
* Start a container
@@ -188,7 +190,7 @@ bool lcr_create(const char *name, const char *lcrpath, void *oci_config);
* gid : user in which group
* additional_gids : Add additional groups to join
*/
-struct lcr_start_request {
+__EXPORT__ struct lcr_start_request {
const char *name;
const char *lcrpath;
@@ -204,7 +206,7 @@ struct lcr_start_request {
const char *exit_fifo;
bool image_type_oci;
};
-bool lcr_start(const struct lcr_start_request *request);
+__EXPORT__ bool lcr_start(const struct lcr_start_request *request);
/*
* Stop a container
@@ -212,7 +214,7 @@ bool lcr_start(const struct lcr_start_request *request);
* param lcrpath : container path, set to NULL if you want use default lcrpath.
* param signal : signal to send to the container.
*/
-bool lcr_kill(const char *name, const char *lcrpath, uint32_t signal);
+__EXPORT__ bool lcr_kill(const char *name, const char *lcrpath, uint32_t signal);
/*
* Delete a container
@@ -220,9 +222,9 @@ bool lcr_kill(const char *name, const char *lcrpath, uint32_t signal);
* param lcrpath : container path, set to NULL if you want use default lcrpath.
* param force : force to delete container
*/
-bool lcr_delete(const char *name, const char *lcrpath);
+__EXPORT__ bool lcr_delete(const char *name, const char *lcrpath);
-bool lcr_clean(const char *name, const char *lcrpath, const char *logpath, const char *loglevel, pid_t pid);
+__EXPORT__ bool lcr_clean(const char *name, const char *lcrpath, const char *logpath, const char *loglevel, pid_t pid);
/*
* Get state of the container
@@ -230,26 +232,26 @@ bool lcr_clean(const char *name, const char *lcrpath, const char *logpath, const
* param lcrpath : container path, set to NULL if you want use default lcrpath.
* param lcs : returned contaiener state
*/
-bool lcr_state(const char *name, const char *lcrpath, struct lcr_container_state *lcs);
+__EXPORT__ bool lcr_state(const char *name, const char *lcrpath, struct lcr_container_state *lcs);
/*
* Pause a container
* param name : container name, required.
* param lcrpath : container path, set to NULL if you want use default lcrpath.
*/
-bool lcr_pause(const char *name, const char *lcrpath);
+__EXPORT__ bool lcr_pause(const char *name, const char *lcrpath);
/*
* Resume a container
* param name : container name, required.
* param lcrpath : container path, set to NULL if you want use default lcrpath.
*/
-bool lcr_resume(const char *name, const char *lcrpath);
+__EXPORT__ bool lcr_resume(const char *name, const char *lcrpath);
/*
* Free lcr_container_state returned by lcr_state
*/
-void lcr_container_state_free(struct lcr_container_state *lcs);
+__EXPORT__ void lcr_container_state_free(struct lcr_container_state *lcs);
/*
* console function
@@ -259,7 +261,7 @@ void lcr_container_state_free(struct lcr_container_state *lcs);
* param out_fifo : fifo names of output FIFO
* Returns false if the console FIFOs add failed, true if success
*/
-bool lcr_console(const char *name, const char *lcrpath, const char *in_fifo, const char *out_fifo,
+__EXPORT__ bool lcr_console(const char *name, const char *lcrpath, const char *in_fifo, const char *out_fifo,
const char *err_fifo);
/*
@@ -268,14 +270,14 @@ bool lcr_console(const char *name, const char *lcrpath, const char *in_fifo, con
* param lcrpath : container path, set to NULL if you want use default lcrpath.
* param config : use to store container console configs, cannot be NULL
*/
-bool lcr_get_console_config(const char *name, const char *lcrpath, struct lcr_console_config *config);
+__EXPORT__ bool lcr_get_console_config(const char *name, const char *lcrpath, struct lcr_console_config *config);
-void lcr_free_console_config(struct lcr_console_config *config);
+__EXPORT__ void lcr_free_console_config(struct lcr_console_config *config);
-int lcr_log_init(const char *name, const char *file, const char *priority,
+__EXPORT__ int lcr_log_init(const char *name, const char *file, const char *priority,
const char *prefix, int quiet, const char *lcrpath);
-struct lcr_exec_request {
+__EXPORT__ struct lcr_exec_request {
const char *name;
const char *lcrpath;
@@ -303,18 +305,18 @@ struct lcr_exec_request {
/*
* Execute process inside a container
*/
-bool lcr_exec(const struct lcr_exec_request *request, int *exit_code);
+__EXPORT__ bool lcr_exec(const struct lcr_exec_request *request, int *exit_code);
-bool lcr_update(const char *name, const char *lcrpath, const struct lcr_cgroup_resources *cr);
+__EXPORT__ bool lcr_update(const char *name, const char *lcrpath, const struct lcr_cgroup_resources *cr);
-const char *lcr_get_errmsg();
+__EXPORT__ const char *lcr_get_errmsg();
-void lcr_free_errmsg();
+__EXPORT__ void lcr_free_errmsg();
-bool lcr_get_container_pids(const char *name, const char *lcrpath, pid_t **pids, size_t *pids_len);
+__EXPORT__ bool lcr_get_container_pids(const char *name, const char *lcrpath, pid_t **pids, size_t *pids_len);
-bool lcr_resize(const char *name, const char *lcrpath, unsigned int height, unsigned int width);
-bool lcr_exec_resize(const char *name, const char *lcrpath, const char *suffix, unsigned int height,
+__EXPORT__ bool lcr_resize(const char *name, const char *lcrpath, unsigned int height, unsigned int width);
+__EXPORT__ bool lcr_exec_resize(const char *name, const char *lcrpath, const char *suffix, unsigned int height,
unsigned int width);
#ifdef __cplusplus
}
diff --git a/src/utils/utils_compile.h b/src/utils/utils_compile.h
new file mode 100644
index 0000000..3bdb24e
--- /dev/null
+++ b/src/utils/utils_compile.h
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * isula: compile utils
+ *
+ * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
+ *
+ * Authors:
+ * Haozi007 <liuhao27@huawei.com>
+ *
+ * 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_UTILS_COMPILE_H
+#define _ISULA_UTILS_UTILS_COMPILE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#ifndef __HIDDEN__
+#define __HIDDEN__ __attribute__((visibility("hidden")))
+#endif
+
+#ifndef __EXPORT__
+#define __EXPORT__ __attribute__((visibility("default")))
+#endif
+
+#else
+#define __HIDDEN__
+#ifndef __EXPORT__
+#endif
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ISULA_UTILS_UTILS_COMPILE_H */
\ No newline at end of file
--
2.34.1

View File

@ -1,38 +0,0 @@
From 3acca1f09f56d871fe38c741917822b96636b540 Mon Sep 17 00:00:00 2001
From: "ilya.kuksenok" <ilya.kuksenok@huawei.com>
Date: Wed, 8 Feb 2023 15:59:18 +0300
Subject: [PATCH 5/8] Add memory related fields
---
src/json/schema/container/info.json | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json
index 8ce10af5..1db0ccf4 100644
--- a/src/json/schema/container/info.json
+++ b/src/json/schema/container/info.json
@@ -17,6 +17,21 @@
"cpu_use_user": {
"type": "uint64"
},
+ "avaliable_bytes": {
+ "type": "uint64"
+ },
+ "usage_bytes": {
+ "type": "uint64"
+ },
+ "rss_bytes": {
+ "type": "uint64"
+ },
+ "page_faults": {
+ "type": "uint64"
+ },
+ "major_page_faults": {
+ "type": "uint64"
+ },
"cpu_use_kernel": {
"type": "uint64"
},
--
2.25.1

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,34 @@
From 2d3f4ef95a3c4d4e87ce71c5ced43f3d8e81cc9e Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Thu, 14 Sep 2023 09:00:05 +0000
Subject: [PATCH 6/8] !264 Support both C++11 and C++17 * Support both C++11
and C++17
---
cmake/set_build_flags.cmake | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake
index 3b6842a..7d4c9fc 100644
--- a/cmake/set_build_flags.cmake
+++ b/cmake/set_build_flags.cmake
@@ -24,8 +24,15 @@
set(CMAKE_C_FLAGS "-fPIC -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall -fPIE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
if (ENABLE_UT)
- set(CMAKE_CXX_FLAGS "-fPIC -std=c++11 -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall")
+ set(CMAKE_CXX_VERSION "-std=c++11")
+ if (COMPILER_SUPPORTS_CXX17)
+ message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++17 support.")
+ set(CMAKE_CXX_VERSION "-std=c++17")
+ endif()
+ set(CMAKE_CXX_FLAGS "-fPIC ${CMAKE_CXX_VERSION} -fstack-protector-all -D_FORTIFY_SOURCE=2 -O2 -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -shared -pthread")
--
2.34.1

View File

@ -1,28 +0,0 @@
From aa7af4993648e2d1fe002fabf2c103ae728d5888 Mon Sep 17 00:00:00 2001
From: "ilya.kuksenok" <ilya.kuksenok@huawei.com>
Date: Tue, 14 Feb 2023 14:01:46 +0300
Subject: [PATCH 6/8] mod headers
---
src/lcrcontainer.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h
index 5134b59d..a222ac97 100644
--- a/src/lcrcontainer.h
+++ b/src/lcrcontainer.h
@@ -90,6 +90,11 @@ struct lcr_container_state {
/* Memory usage */
uint64_t mem_used;
uint64_t mem_limit;
+ uint64_t avaliable_bytes;
+ uint64_t usage_bytes;
+ uint64_t rss_bytes;
+ uint64_t page_faults;
+ uint64_t major_page_faults;
/* Kernel Memory usage */
uint64_t kmem_used;
uint64_t kmem_limit;
--
2.25.1

File diff suppressed because it is too large Load Diff

View File

@ -1,100 +0,0 @@
From 6ca6e250fc0cc10290c6e495168b29e09e2a70e9 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 15 Feb 2023 16:05:39 +0800
Subject: [PATCH 7/8] add cgroup resources json schema for isula update
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
.../schema/shim/client/cgroup-resources.json | 58 +++++++++++++++++++
.../schema/shim/client/process-state.json | 1 +
.../schema/shim/client/runtime-stats.json | 1 +
3 files changed, 60 insertions(+)
create mode 100644 src/json/schema/shim/client/cgroup-resources.json
diff --git a/src/json/schema/shim/client/cgroup-resources.json b/src/json/schema/shim/client/cgroup-resources.json
new file mode 100644
index 00000000..10310710
--- /dev/null
+++ b/src/json/schema/shim/client/cgroup-resources.json
@@ -0,0 +1,58 @@
+{
+ "_comment": "third party depend: runc",
+ "description": "cgroup resources",
+ "type": "object",
+ "properties": {
+ "blockIO": {
+ "type": "object",
+ "properties": {
+ "weight": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ }
+ }
+ },
+ "cpu": {
+ "type": "object",
+ "properties": {
+ "shares": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "period": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "quota": {
+ "$ref": "../../defs.json#/definitions/int64"
+ },
+ "realtimeRuntime": {
+ "$ref": "../../defs.json#/definitions/int64"
+ },
+ "realtimePeriod": {
+ "$ref": "../../defs.json#/definitions/int64"
+ },
+ "cpus": {
+ "type": "string"
+ },
+ "mems": {
+ "type": "string"
+ }
+ }
+ },
+ "memory": {
+ "type": "object",
+ "properties": {
+ "limit": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "swap": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "reservation": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "kernel": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ }
+ }
+ }
+ }
+}
diff --git a/src/json/schema/shim/client/process-state.json b/src/json/schema/shim/client/process-state.json
index 05f55fc5..f07d14f1 100644
--- a/src/json/schema/shim/client/process-state.json
+++ b/src/json/schema/shim/client/process-state.json
@@ -1,4 +1,5 @@
{
+ "_comment": "third party depend: runc",
"description": "process state info",
"type": "object",
"required": [
diff --git a/src/json/schema/shim/client/runtime-stats.json b/src/json/schema/shim/client/runtime-stats.json
index 6ed9473d..ae77e9db 100644
--- a/src/json/schema/shim/client/runtime-stats.json
+++ b/src/json/schema/shim/client/runtime-stats.json
@@ -1,4 +1,5 @@
{
+ "_comment": "third party depend: runc",
"description": "runtime stats",
"type": "object",
"properties": {
--
2.25.1

View File

@ -0,0 +1,30 @@
From ac0e25d39dc0eaaf492ea626e1c1bbf3b5f2999f Mon Sep 17 00:00:00 2001
From: jake <jikai11@huawei.com>
Date: Mon, 18 Sep 2023 11:08:22 +0000
Subject: [PATCH 8/8] !266 set env to avoid invoke lxc binary directly * set
env to avoid invoke lxc binary directly
---
src/runtime/lcrcontainer.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/runtime/lcrcontainer.c b/src/runtime/lcrcontainer.c
index 4270902..ad6dc66 100644
--- a/src/runtime/lcrcontainer.c
+++ b/src/runtime/lcrcontainer.c
@@ -289,6 +289,12 @@ bool lcr_start(const struct lcr_start_request *request)
close(pipefd[0]);
dup2(pipefd[1], 2);
+ // should set LXC_MEMFD_REXEC=1 before lxc_start
+ // to improve the security of launching containers
+ if (setenv("LXC_MEMFD_REXEC", "1", true) != 0) {
+ exit(1);
+ }
+
execute_lxc_start(request->name, path, request);
}
--
2.34.1

View File

@ -1,27 +0,0 @@
From 825554c1318b94edd29d4f22a9c5cbc3270cf277 Mon Sep 17 00:00:00 2001
From: "Neil.wrz" <wangrunze13@huawei.com>
Date: Wed, 15 Feb 2023 19:11:45 -0800
Subject: [PATCH 8/8] add field for isulad daemon configs
Signed-off-by: Neil.wrz <wangrunze13@huawei.com>
---
src/json/schema/isulad-daemon-configs.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/json/schema/isulad-daemon-configs.json b/src/json/schema/isulad-daemon-configs.json
index b1f60cf1..9ac8ee04 100644
--- a/src/json/schema/isulad-daemon-configs.json
+++ b/src/json/schema/isulad-daemon-configs.json
@@ -46,6 +46,9 @@
"storage-opts": {
"type": "ArrayOfStrings"
},
+ "storage-enable-remote-layer": {
+ "type": "boolean"
+ },
"pidfile": {
"type": "string"
},
--
2.25.1

View File

@ -1,33 +0,0 @@
From cd4ce196a2b144327f050269a14d8391a88e9920 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 6 Mar 2023 15:28:43 +0800
Subject: [PATCH 09/15] adapt to repo of openeuler url changed
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
CI/pr-gateway.sh | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/CI/pr-gateway.sh b/CI/pr-gateway.sh
index df345bd..66c2074 100755
--- a/CI/pr-gateway.sh
+++ b/CI/pr-gateway.sh
@@ -14,7 +14,15 @@
##- @Create: 2021-12-20
#######################################################################
+sed -i "s#http://repo.openeuler.org#https://repo.huaweicloud.com/openeuler#g" /etc/yum.repos.d/openEuler.repo
+
+dnf update -y
+
dnf install -y 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
+if [ $? -ne 0 ]; then
+ echo "install dependences failed"
+ exit 1
+fi
cd ~
--
2.25.1

View File

@ -1,97 +0,0 @@
From edb2ec1336f59ad8ca093f8cf2b2e092ff62575e Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Wed, 8 Mar 2023 10:33:40 +0800
Subject: [PATCH 10/15] add call timeout check macro
1. add macro for check call function timeout, and output a log;
2. add testcase for call timeout check macro;
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
tests/log_ut.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
third_party/log.h | 11 +++++++++++
2 files changed, 51 insertions(+)
diff --git a/tests/log_ut.cpp b/tests/log_ut.cpp
index 8cf6599..2638e85 100644
--- a/tests/log_ut.cpp
+++ b/tests/log_ut.cpp
@@ -166,6 +166,8 @@ TEST(log_testcases, test_isula_libutils_log_enable)
DEBUG("debug log");
check_log(fd, false, false, "debug log");
isula_libutils_log_disable();
+
+ unlink(fname);
}
TEST(log_testcases, test_isula_libutils_log_prefix)
@@ -202,5 +204,43 @@ TEST(log_testcases, test_isula_libutils_log_prefix)
isula_libutils_set_log_prefix("");
INFO("fake log");
check_log(fd, true, true, default_prefix);
+
+ isula_libutils_log_disable();
+ unlink(fname);
+}
+
+static int do_sleep(int time)
+{
+ sleep(time);
+ return 1;
}
+TEST(log_testcases, test_call_check_timeout)
+{
+ struct isula_libutils_log_config tconf = {0};
+ const char *default_prefix = "iSula";
+ const char *prio = "INFO";
+ const char *fname = "/tmp/fake.fifo";
+ int fd = -1;
+ int nret;
+
+ tconf.driver = ISULA_LOG_DRIVER_FIFO;
+ tconf.priority = prio;
+ tconf.file = fname;
+ isula_libutils_log_enable(&tconf);
+
+ fd = isula_libutils_get_log_fd();
+ ASSERT_GE(fd, 0);
+
+ // not timeout, will no log
+ CALL_CHECK_TIMEOUT(2, do_sleep(1));
+ check_log(fd, false, false, default_prefix);
+
+ // timeout, should have log
+ CALL_CHECK_TIMEOUT(1, nret = do_sleep(2));
+ check_log(fd, true, true, "use 1 sec, timeout!!");
+ ASSERT_EQ(nret, 1);
+
+ isula_libutils_log_disable();
+ unlink(fname);
+}
\ No newline at end of file
diff --git a/third_party/log.h b/third_party/log.h
index 2db0d98..fad04a1 100644
--- a/third_party/log.h
+++ b/third_party/log.h
@@ -452,6 +452,17 @@ void isula_libutils_log_disable();
int isula_libutils_get_log_fd(void);
+#define CALL_CHECK_TIMEOUT(timeout, caller) \
+ do { \
+ struct timespec tbeg, tend; \
+ (void)clock_gettime(CLOCK_REALTIME, &tbeg); \
+ caller; \
+ (void)clock_gettime(CLOCK_REALTIME, &tend); \
+ if (tend.tv_sec - tbeg.tv_sec >= (timeout)) { \
+ ERROR("Call: "#caller" use %d sec, timeout!!", timeout); \
+ } \
+ } while (0)
+
#ifdef __cplusplus
}
#endif
--
2.25.1

View File

@ -1,37 +0,0 @@
From de9dad87ccd54bd2beceb0d8dbb6bd5c442270ff Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sat, 8 Apr 2023 11:38:50 +0800
Subject: [PATCH 11/15] add files_limit to oci spec
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/defs.json | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json
index cfbaa19..58c56fe 100644
--- a/src/json/schema/defs.json
+++ b/src/json/schema/defs.json
@@ -989,6 +989,19 @@
"limit"
]
},
+ "files": {
+ "id": "https://opencontainers.org/schema/bundle/linux/resources/files",
+ "type": "object",
+ "properties": {
+ "limit": {
+ "id": "https://opencontainers.org/schema/bundle/linux/resources/files/limit",
+ "$ref": "#/definitions/int64"
+ }
+ },
+ "required": [
+ "limit"
+ ]
+ },
"blockIO": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/blockIO",
"type": "object",
--
2.25.1

View File

@ -1,76 +0,0 @@
From 85a5823c87f8b0e5d5b2172aa5e4564f50fbc011 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Fri, 21 Apr 2023 09:51:16 +0800
Subject: [PATCH 12/15] add memory info from runtime
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/json/schema/container/info.json | 2 +-
src/json/schema/shim/client/runtime-stats.json | 9 +++++++++
src/lcrcontainer.h | 2 --
src/lcrcontainer_execute.c | 3 +++
4 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json
index 1db0ccf..19107a1 100644
--- a/src/json/schema/container/info.json
+++ b/src/json/schema/container/info.json
@@ -20,7 +20,7 @@
"avaliable_bytes": {
"type": "uint64"
},
- "usage_bytes": {
+ "workingset_bytes": {
"type": "uint64"
},
"rss_bytes": {
diff --git a/src/json/schema/shim/client/runtime-stats.json b/src/json/schema/shim/client/runtime-stats.json
index ae77e9d..6fdc579 100644
--- a/src/json/schema/shim/client/runtime-stats.json
+++ b/src/json/schema/shim/client/runtime-stats.json
@@ -52,6 +52,15 @@
"properties": {
"total_inactive_file": {
"$ref": "../../defs.json#/definitions/uint64"
+ },
+ "rss": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "pgfault": {
+ "$ref": "../../defs.json#/definitions/uint64"
+ },
+ "pgmajfault": {
+ "$ref": "../../defs.json#/definitions/uint64"
}
}
}
diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h
index a222ac9..edfc869 100644
--- a/src/lcrcontainer.h
+++ b/src/lcrcontainer.h
@@ -90,8 +90,6 @@ struct lcr_container_state {
/* Memory usage */
uint64_t mem_used;
uint64_t mem_limit;
- uint64_t avaliable_bytes;
- uint64_t usage_bytes;
uint64_t rss_bytes;
uint64_t page_faults;
uint64_t major_page_faults;
diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c
index ff4685b..4d72050 100644
--- a/src/lcrcontainer_execute.c
+++ b/src/lcrcontainer_execute.c
@@ -789,6 +789,9 @@ void do_lcr_state(struct lxc_container *c, struct lcr_container_state *lcs)
lcs->mem_limit = lxc_metrics.mem_limit;
lcs->kmem_used = lxc_metrics.kmem_used;
lcs->kmem_limit = lxc_metrics.kmem_limit;
+ lcs->rss_bytes = lxc_metrics.rss_bytes;
+ lcs->page_faults = lxc_metrics.page_faults;
+ lcs->major_page_faults = lxc_metrics.major_page_faults;
lcs->cache = lxc_metrics.cache;
lcs->cache_total = lxc_metrics.cache_total;
--
2.25.1

View File

@ -1,59 +0,0 @@
From 1839c09872b1e5a19109992c6ab52d9b45655ac6 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Wed, 26 Apr 2023 17:08:04 +0800
Subject: [PATCH 13/15] add unified resources and remove useless
MemorySwapLimitInBytes
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
src/json/schema/defs.json | 4 ++++
src/json/schema/host-config.json | 3 ---
src/json/schema/shim/client/cgroup-resources.json | 3 +++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json
index 58c56fe..d96ac4c 100644
--- a/src/json/schema/defs.json
+++ b/src/json/schema/defs.json
@@ -969,6 +969,10 @@
"id": "https://opencontainers.org/schema/bundle/linux/resources",
"type": "object",
"properties": {
+ "unified": {
+ "id": "https://opencontainers.org/schema/bundle/linux/resources/unified",
+ "$ref": "#/definitions/mapStringString"
+ },
"devices": {
"id": "https://opencontainers.org/schema/bundle/linux/resources/devices",
"type": "array",
diff --git a/src/json/schema/host-config.json b/src/json/schema/host-config.json
index 0367a76..302a537 100644
--- a/src/json/schema/host-config.json
+++ b/src/json/schema/host-config.json
@@ -145,9 +145,6 @@
"OomScoreAdj": {
"type": "integer"
},
- "MemorySwapLimitInBytes":{
- "type": "int64"
- },
"BlkioWeight": {
"type": "uint16"
},
diff --git a/src/json/schema/shim/client/cgroup-resources.json b/src/json/schema/shim/client/cgroup-resources.json
index 1031071..693bcf0 100644
--- a/src/json/schema/shim/client/cgroup-resources.json
+++ b/src/json/schema/shim/client/cgroup-resources.json
@@ -53,6 +53,9 @@
"$ref": "../../defs.json#/definitions/uint64"
}
}
+ },
+ "unified": {
+ "$ref": "../../defs.json#/definitions/mapStringString"
}
}
}
--
2.25.1

View File

@ -1,61 +0,0 @@
From e76e5dec8ca66102fc883e1f4a9a1a4d9b102ada Mon Sep 17 00:00:00 2001
From: xuepeng <xuxuepeng1@huawei.com>
Date: Fri, 28 Apr 2023 04:58:21 +0800
Subject: [PATCH 14/15] Add resources info to pod inspection
Signed-off-by: xuepeng <xuxuepeng1@huawei.com>
---
src/json/schema/container/inspect.json | 37 ++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/json/schema/container/inspect.json b/src/json/schema/container/inspect.json
index d6dc8c3..9c76c33 100644
--- a/src/json/schema/container/inspect.json
+++ b/src/json/schema/container/inspect.json
@@ -54,6 +54,43 @@
}
}
},
+ "Resources": {
+ "type": "object",
+ "properties": {
+ "CPUPeriod": {
+ "type": "int64"
+ },
+ "CPUQuota": {
+ "type": "int64"
+ },
+ "CPUShares": {
+ "type": "int64"
+ },
+ "Memory": {
+ "type": "int64"
+ },
+ "MemorySwap": {
+ "type": "int64"
+ },
+ "Hugetlbs": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "PageSize": {
+ "type": "string"
+ },
+ "Limit": {
+ "type": "uint64"
+ }
+ }
+ }
+ },
+ "unified": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ }
+ }
+ },
"Image": {
"type": "string"
},
--
2.25.1

View File

@ -1,38 +0,0 @@
From 9335aa89a00618814ca957dd2617d502a955f598 Mon Sep 17 00:00:00 2001
From: xuepeng <xuxuepeng1@huawei.com>
Date: Fri, 5 May 2023 08:06:22 +0800
Subject: [PATCH 15/15] Add timestamp and calculated cpu usage for cpu usage
support
Signed-off-by: xuepeng <xuxuepeng1@huawei.com>
---
src/json/schema/container/info.json | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json
index 19107a1..53d8a91 100644
--- a/src/json/schema/container/info.json
+++ b/src/json/schema/container/info.json
@@ -14,6 +14,9 @@
"cpu_use_nanos": {
"type": "uint64"
},
+ "cpu_use_nanos_per_second": {
+ "type": "uint64"
+ },
"cpu_use_user": {
"type": "uint64"
},
@@ -73,6 +76,9 @@
},
"inactive_file_total": {
"type": "uint64"
+ },
+ "timestamp": {
+ "type": "uint64"
}
}
}
--
2.25.1

127
lcr.spec
View File

@ -1,6 +1,7 @@
%global _version 2.1.1
%global _release 7
%global _version 2.1.2
%global _release 4
%global _inner_name isula_libutils
%global enable_lxc 1
Name: lcr
Version: %{_version}
@ -12,21 +13,14 @@ Group: Applications/System
License: LGPLv2.1+
BuildRoot: %{_tmppath}/lcr-%{version}
Patch0001: 0001-add-libisula.pc.patch
Patch0002: 0002-add-unified-and-memory_swap_limit_in_bytes-into-host.patch
Patch0003: 0003-fix-update-cpu-rt-period-failed.patch
Patch0004: 0004-fix-writing-config-line-with-wrong-length.patch
Patch0005: 0005-Add-memory-related-fields.patch
Patch0006: 0006-mod-headers.patch
Patch0007: 0007-add-cgroup-resources-json-schema-for-isula-update.patch
Patch0008: 0008-add-field-for-isulad-daemon-configs.patch
Patch0009: 0009-adapt-to-repo-of-openeuler-url-changed.patch
Patch0010: 0010-add-call-timeout-check-macro.patch
Patch0011: 0011-add-files_limit-to-oci-spec.patch
Patch0012: 0012-add-memory-info-from-runtime.patch
Patch0013: 0013-add-unified-resources-and-remove-useless-MemorySwapL.patch
Patch0014: 0014-Add-resources-info-to-pod-inspection.patch
Patch0015: 0015-Add-timestamp-and-calculated-cpu-usage-for-cpu-usage.patch
Patch0001: 0001-support-check-symbols-and-compile-code-in-cmake.patch
Patch0002: 0002-remove-unnecessary-strerror.patch
Patch0003: 0003-improve-code-of-function-in-log.patch
Patch0004: 0004-support-visibility-of-compiler.patch
Patch0005: 0005-refactor-util-buffer-and-add-ut.patch
Patch0006: 0006-264-Support-both-C-11-and-C-17.patch
Patch0007: 0007-262-Fix-empty-pointer-and-overflow.patch
Patch0008: 0008-266-set-env-to-avoid-invoke-lxc-binary-directly.patch
%define lxcver_lower 4.0.3-2022102400
%define lxcver_upper 4.0.3-2022102500
@ -75,24 +69,31 @@ the libisula-devel package contains json, log and utils headers for developing p
%build
mkdir -p build
cd build
%cmake -DDEBUG=ON -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} ../
%if 0%{?enable_lxc}
%cmake -DDEBUG=ON -DENABLE_LIBLCR=ON -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} ../
%else
%cmake -DDEBUG=ON -DENABLE_LIBLCR=OFF -DCMAKE_SKIP_RPATH=TRUE -DLIB_INSTALL_DIR=%{_libdir} ../
%endif
%make_build
%install
rm -rf %{buildroot}
cd build
mkdir -p %{buildroot}/{%{_libdir},%{_libdir}/pkgconfig,%{_includedir}/lcr,%{_bindir}}
%if 0%{?enable_lxc}
install -m 0644 ./src/liblcr.so %{buildroot}/%{_libdir}/liblcr.so
install -m 0644 ./conf/lcr.pc %{buildroot}/%{_libdir}/pkgconfig/lcr.pc
install -m 0644 ../src/lcrcontainer.h %{buildroot}/%{_includedir}/lcr/lcrcontainer.h
install -m 0644 ../src/runtime/lcrcontainer.h %{buildroot}/%{_includedir}/lcr/lcrcontainer.h
chmod +x %{buildroot}/%{_libdir}/liblcr.so
%endif
install -m 0644 ./src/libisula_libutils.so %{buildroot}/%{_libdir}/libisula_libutils.so
install -m 0644 ./conf/libisula.pc %{buildroot}/%{_libdir}/pkgconfig/libisula.pc
install -d $RPM_BUILD_ROOT/%{_includedir}/%{_inner_name}
install -m 0644 ../build/json/*.h %{buildroot}/%{_includedir}/%{_inner_name}/
install -m 0644 ../src/json/*.h %{buildroot}/%{_includedir}/%{_inner_name}/
install -m 0644 ../third_party/*.h %{buildroot}/%{_includedir}/%{_inner_name}/
install -m 0644 ../src/third_party/*.h %{buildroot}/%{_includedir}/%{_inner_name}/
install -m 0644 ../src/auto_cleanup.h %{buildroot}/%{_includedir}/%{_inner_name}/
chmod +x %{buildroot}/%{_libdir}/libisula_libutils.so
find %{buildroot} -type f -name '*.la' -exec rm -f {} ';'
@ -108,6 +109,7 @@ rm -rf %{buildroot}
%postun -p /sbin/ldconfig
%if 0%{?enable_lxc}
%files
%defattr(-,root,root,-)
%{_libdir}/liblcr.so
@ -116,6 +118,7 @@ rm -rf %{buildroot}
%files devel
%defattr(-,root,root,-)
%{_includedir}/lcr/lcrcontainer.h
%endif
%files -n libisula
%defattr(-,root,root,-)
@ -127,6 +130,42 @@ rm -rf %{buildroot}
%{_includedir}/%{_inner_name}/*.h
%changelog
* Mon Sep 18 2023 jikai<jikai11@huawei.com> - 2.1.2-4
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:sync from upstream
* Mon Sep 11 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.2-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:rollback dependent library lxc version
* Tue Aug 29 2023 xuxuepeng<xuxuepeng1@huawei.com> - 2.1.2-2
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:add auto_cleanup.h to include path
* Tue Aug 29 2023 xuxuepeng<xuxuepeng1@huawei.com> - 2.1.2-1
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:upgrade to v2.1.2
* Mon Aug 07 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.1-9
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:disable liblcr
* Sat Aug 05 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.1-8
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:update dependent library lxc version
* Mon Jun 19 2023 laokz <zhangkai@iscas.ac.cn> - 2.1.1-7
- Type:enhancement
- CVE:NA
@ -137,26 +176,38 @@ rm -rf %{buildroot}
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:upgrade to 2.1.1
- DESC:upgrade from upstream
* Mon Apr 24 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.0.9-4
* Tue Feb 21 2023 wangrunze <wangrunze13@loongson.cn> - 2.1.1-5
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:support update resources, remote-layer and files limit
- DESC:update from upstream to include feature remote ro
* Tue Feb 21 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.0.9-3
- Type:bugfix
- CVE:NA
- SUG:NA
- DESC:fix update cpu-rt period failed and fix layer size type as int64
* Thu Feb 16 2023 Wenlong Zhang<zhangwenlong@loongson.cn> - 2.0.9-2
* Tue Feb 21 2023 Wenlong Zhang<zhangwenlong@loongson.cn> - 2.1.1-4
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:Add loongarch64 support
* Tue Feb 21 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.1-3
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:upgrade from upstream
* Tue Feb 07 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.1-2
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:split libisula package from lcr
* Mon Feb 06 2023 zhangxiaoyu<zhangxiaoyu58@huawei.com> - 2.1.1-1
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:update version to v2.1.1
* Sat Dec 17 2022 wangrunze<wangrunze13@huawei.com> - 2.0.9-1
- Type:enhancement
- CVE:NA
@ -275,9 +326,21 @@ rm -rf %{buildroot}
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: update to 2.0.6
- DESC: sync from upstream
* Wed Nov 10 2021 gaohuatao <gaohuatao@huawei.com> - 2.0.6-2
* Tue Nov 16 2021 wujing <wujing50@huawei.com> - 2.0.6-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: remove build platform restrictions
* Tue Nov 09 2021 gaohuatao <gaohuatao@huawei.com> - 2.0.6-2
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: update source
* Tue Nov 09 2021 gaohuatao <gaohuatao@huawei.com> - 2.0.6-1
- Type:enhancement
- ID:NA
- SUG:NA

View File

@ -1,3 +1,7 @@
#!/bin/bash
#
# usage
# ./update-version.sh
#######################################################################
# lcr: utils library for iSula
#
@ -21,18 +25,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
#######################################################################
#!/bin/bash
#
# usage
# ./update-version.bash
topDir=$(git rev-parse --show-toplevel)
specfile="${topDir}/lcr.spec"
CMakefile="${topDir}/CMakeLists.txt"
old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'})
first_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $1'})
second_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $2'})
third_old_version=$(cat ${specfile} | grep "%global" | grep "_version" | awk {'print $3'} | awk -F "." {'print $3'})
read -p "Which level version do you want to upgrade?[1/2/3/d/N](default:N) select:" choice
read -p "Which level version do you want to upgrade?[1/2/3/r/N](default:N) select:" choice
if [[ ! -n "${choice}" || ${choice} == "N" ]]; then
echo "The version number has not been modified, it is still ${old_version}"
exit 0
@ -51,15 +50,9 @@ fi
new_version=${first_old_version}.${second_old_version}.${third_old_version}
echo "The version number has been modified: ${old_version} => ${new_version}"
old_release=$(cat ${specfile} | grep "%global" | grep "_release" | awk {'print $3'})
commit_id_long=`git log --pretty=oneline -1 | awk {'print $1'}`
commit_id=${commit_id_long:0:8}
new_release=`date "+%Y%m%d"`.`date "+%H%M%S"`.git$commit_id
echo "The relase version has been modified, it is ${new_release}"
sed -i "s/set(LCR_VERSION \"${old_version}\")/set(LCR_VERSION \"${new_version}\")/g" ${CMakefile}
new_release=$(($old_release+1))
sed -i "s/^\%global _version ${old_version}$/\%global _version ${new_version}/g" ${specfile}
sed -i "s/^\%global _release ${old_release}$/\%global _release ${new_release}/g" ${specfile}
echo "The release number has been modified: ${old_release} => ${new_release}"
echo "The release version has been modified: ${old_version}-${old_release} => ${new_version}-${new_release}"

Binary file not shown.

BIN
v2.1.2.tar.gz Normal file

Binary file not shown.