Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
4097122df7
!391 [sync] PR-388: sync from upstream
From: @openeuler-sync-bot 
Reviewed-by: @taotao-sauce 
Signed-off-by: @taotao-sauce
2025-05-14 08:34:30 +00:00
dongyuzhen
76de15dd1e sync from upstream
(cherry picked from commit 7fdf2c7f150be6dd38ff289f4128f41c3d78c643)
2025-05-13 20:16:07 +08:00
openeuler-ci-bot
3a251f7d5e
!367 [sync] PR-364: lcr: sync from upstream
From: @openeuler-sync-bot 
Reviewed-by: @taotao-sauce 
Signed-off-by: @taotao-sauce
2024-11-25 11:37:01 +00:00
liuxu
afb705c076 lcr: sync from upstream
Signed-off-by: liuxu <liuxu156@huawei.com>
(cherry picked from commit a31b7e00909a434144979f31851b3040b5881ac3)
2024-11-25 17:22:18 +08:00
openeuler-ci-bot
3d953d2658
!357 unify nri variable format and Align the release version
From: @wu-jichao123 
Reviewed-by: @taotao-sauce 
Signed-off-by: @taotao-sauce
2024-10-21 11:16:47 +00:00
武积超
e8e4e8fcb2 unify nri variable format and Align the release version 2024-10-17 19:56:48 +08:00
openeuler-ci-bot
30110a5975
!344 backport(rm attribute "visibility" before struct),add -Wno-error,fix changelog ,support clang build
From: @yuncang123 
Reviewed-by: @taotao-sauce, @xuxuepeng 
Signed-off-by: @taotao-sauce
2024-09-04 02:44:19 +00:00
yuncang123
24876de49d rm attribute visibility before struct,fix spec,support clang 2024-09-03 10:35:09 +08:00
openeuler-ci-bot
b2b90f41c3
!331 [sync] PR-325: sync from upstream
From: @openeuler-sync-bot 
Reviewed-by: @taotao-sauce 
Signed-off-by: @taotao-sauce
2024-06-11 12:04:42 +00:00
jikai
754dcd5242 sync from upstream
Signed-off-by: jikai <jikai11@huawei.com>
(cherry picked from commit 35815058031561339484cdbdff29d3c4beef7a99)
2024-06-11 19:20:32 +08:00
28 changed files with 2839 additions and 11 deletions

View File

@ -1,7 +1,7 @@
From 3bcb8f3f60abb6ab6cde999cadb6a836744d4104 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Thu, 11 Jan 2024 19:00:19 +0800
Subject: [PATCH 01/10] add systemd-cgroup field in isulad and shim config
Subject: [PATCH 01/14] add systemd-cgroup field in isulad and shim config
Signed-off-by: jikai <jikai11@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 30558b07c80895e748e4754010d3bfa99f1a52da Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Mon, 19 Feb 2024 23:41:50 +0800
Subject: [PATCH 02/10] Add http-parser as third party component
Subject: [PATCH 02/14] Add http-parser as third party component
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 19655a5df138acda0a57b0411bc69f82511a32b4 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Wed, 13 Mar 2024 15:21:09 +0800
Subject: [PATCH 03/10] add enable pod events field
Subject: [PATCH 03/14] add enable pod events field
Signed-off-by: jikai <jikai11@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 299f54b13a85855540e6d28e9c9bfefb7bc66f14 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Fri, 12 Jan 2024 11:30:34 +0800
Subject: [PATCH 04/10] add swap usage fields in shim stats and container info
Subject: [PATCH 04/14] add swap usage fields in shim stats and container info
Signed-off-by: jikai <jikai11@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 5adb5c82cb48f55fec1d6750e0648a0ffc5a372c Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Mon, 18 Mar 2024 20:23:58 +0800
Subject: [PATCH 05/10] Add oomkilled field in inspect.json
Subject: [PATCH 05/14] Add oomkilled field in inspect.json
Signed-off-by: jikai <jikai11@huawei.com>
---

View File

@ -1,7 +1,7 @@
From ffe13775740957f55c4a87cdee63481b1e6f4adb Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 8 Apr 2024 11:38:21 +0800
Subject: [PATCH 06/10] add runtime in process-state
Subject: [PATCH 06/14] add runtime in process-state
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---

View File

@ -1,7 +1,7 @@
From 27b2deef3e4d64b44a7a4cdfd76ac99bfad80f64 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 9 Apr 2024 10:34:32 +0800
Subject: [PATCH 07/10] restore bufsize to prevent log loss
Subject: [PATCH 07/14] restore bufsize to prevent log loss
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---

View File

@ -1,7 +1,7 @@
From f1d0acce748fdccb750424b75f5de8fd760fb98e Mon Sep 17 00:00:00 2001
From: luofeng14 <luofeng13@huawei.com>
Date: Wed, 10 Apr 2024 11:29:29 +0800
Subject: [PATCH 08/10] support clang build
Subject: [PATCH 08/14] support clang build
---
cmake/set_build_flags.cmake | 2 +-

View File

@ -1,7 +1,7 @@
From 63b48aafaa17616d75f79f7cfe54fc0f2827692d Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Tue, 5 Mar 2024 22:20:43 +0800
Subject: [PATCH 09/10] support cdi spec
Subject: [PATCH 09/14] support cdi spec
---
src/json/schema/cdi/container_edits.json | 28 ++++++++++++++++

View File

@ -1,7 +1,7 @@
From e7db434109376a88013d739c81c71dd1db86e3a5 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Fri, 19 Apr 2024 04:04:12 +0000
Subject: [PATCH 10/10] remove file mode check in ut
Subject: [PATCH 10/14] remove file mode check in ut
Signed-off-by: jikai <jikai11@huawei.com>
---

View File

@ -0,0 +1,103 @@
From d059f53cad4f3063df4f7f93107ad2fbffdb301c Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Fri, 26 Apr 2024 03:46:43 +0000
Subject: [PATCH 11/14] remove lcr-created spec only if create failed
Signed-off-by: jikai <jikai11@huawei.com>
---
src/runtime/lcrcontainer.c | 8 +++---
src/runtime/lcrcontainer_extend.c | 44 +++++++++++++++++++++++++++++++
src/runtime/lcrcontainer_extend.h | 2 ++
3 files changed, 49 insertions(+), 5 deletions(-)
diff --git a/src/runtime/lcrcontainer.c b/src/runtime/lcrcontainer.c
index 2f0c9dd..c6959aa 100644
--- a/src/runtime/lcrcontainer.c
+++ b/src/runtime/lcrcontainer.c
@@ -186,15 +186,13 @@ bool lcr_create(const char *name, const char *lcrpath, void *oci_config)
bret = true;
out_unlock:
+ if (!bret) {
+ lcr_delete_spec(c, oci_spec);
+ }
if (partial_fd >= 0) {
close(partial_fd);
remove_partial(c);
}
- if (!bret) {
- if (!c->destroy(c)) {
- WARN("Unable to clean lxc resources");
- }
- }
lxc_container_put(c);
isula_libutils_free_log_prefix();
return bret;
diff --git a/src/runtime/lcrcontainer_extend.c b/src/runtime/lcrcontainer_extend.c
index 1409ea4..0b420d2 100644
--- a/src/runtime/lcrcontainer_extend.c
+++ b/src/runtime/lcrcontainer_extend.c
@@ -999,3 +999,47 @@ out_free_conf:
return ret;
}
+static void delete_specific_spec(const char *bundle, const char *name)
+{
+ char filepath[PATH_MAX] = { 0 };
+ int nret = snprintf(filepath, sizeof(filepath), "%s/%s", bundle, name);
+ if (nret < 0 || (size_t)nret >= sizeof(filepath)) {
+ ERROR("Failed to print string");
+ return;
+ }
+
+ if (unlink(filepath) != 0) {
+ SYSERROR("Failed to delete %s", filepath);
+ return;
+ }
+}
+
+void lcr_delete_spec(const struct lxc_container *c, oci_runtime_spec *container)
+{
+ const char *path = NULL;
+ const char *name = NULL;
+ char *bundle = NULL;
+
+ if (c == NULL || c->name == NULL || container == NULL) {
+ ERROR("Invalid arguments");
+ return;
+ }
+
+ path = c->config_path ? c->config_path : LCRPATH;
+ name = c->name;
+ bundle = lcr_get_bundle(path, name);
+ if (bundle == NULL) {
+ return;
+ }
+
+ if (container->hooks != NULL) {
+ delete_specific_spec(bundle, OCIHOOKSFILE);
+ }
+
+ delete_specific_spec(bundle, "config");
+
+ // There might not exist seccomp file, try to delete anyway
+ delete_specific_spec(bundle, "seccomp");
+
+ free(bundle);
+}
diff --git a/src/runtime/lcrcontainer_extend.h b/src/runtime/lcrcontainer_extend.h
index 539747c..c286450 100644
--- a/src/runtime/lcrcontainer_extend.h
+++ b/src/runtime/lcrcontainer_extend.h
@@ -76,6 +76,8 @@ bool lcr_save_spec(const char *name, const char *lcrpath, const struct isula_lin
bool translate_spec(const struct lxc_container *c, oci_runtime_spec *container);
+void lcr_delete_spec(const struct lxc_container *c, oci_runtime_spec *container);
+
#ifdef __cplusplus
}
#endif
--
2.34.1

View File

@ -0,0 +1,26 @@
From d5805dda2500ff4b0676e30c800a188c93a7d59d Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Fri, 3 May 2024 04:07:30 +0800
Subject: [PATCH 12/14] Fix info inproper data type for timestamp
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
src/json/schema/container/info.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json
index 3bf1033..d7209db 100644
--- a/src/json/schema/container/info.json
+++ b/src/json/schema/container/info.json
@@ -78,7 +78,7 @@
"type": "uint64"
},
"timestamp": {
- "type": "uint64"
+ "type": "int64"
},
"swap_used": {
"type": "uint64"
--
2.34.1

View File

@ -0,0 +1,208 @@
From fef260da5d0acf8d730ad6a809382989c521b0ef Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Thu, 9 May 2024 12:28:44 +0000
Subject: [PATCH 13/14] fix bug for potential config/seccomp/ocihook write
error
Signed-off-by: jikai <jikai11@huawei.com>
---
src/runtime/lcrcontainer_extend.c | 62 +++++++++++++++----------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/src/runtime/lcrcontainer_extend.c b/src/runtime/lcrcontainer_extend.c
index 0b420d2..93ec60f 100644
--- a/src/runtime/lcrcontainer_extend.c
+++ b/src/runtime/lcrcontainer_extend.c
@@ -347,12 +347,13 @@ out:
return ret;
}
-static int lcr_spec_write_seccomp_line(FILE *fp, const char *seccomp)
+static int lcr_spec_write_seccomp_line(int fd, const char *seccomp)
{
size_t len;
char *line = NULL;
int ret = -1;
int nret;
+ ssize_t nwritten = -1;
if (strlen(seccomp) > SIZE_MAX - strlen("lxc.seccomp.profile") - 3 - 1) {
ERROR("the length of lxc.seccomp is too long!");
@@ -378,7 +379,8 @@ static int lcr_spec_write_seccomp_line(FILE *fp, const char *seccomp)
}
line[nret] = '\n';
- if (fwrite(line, 1, len ,fp) != len) {
+ nwritten = isula_file_total_write_nointr(fd, line, len);
+ if (nwritten < 0 || (size_t)nwritten != len) {
SYSERROR("Write file failed");
goto cleanup;
}
@@ -395,7 +397,7 @@ static char *lcr_save_seccomp_file(const char *bundle, const char *seccomp_conf)
char *real_seccomp = NULL;
int fd = -1;
int nret;
- ssize_t written_cnt;
+ ssize_t nwritten = -1;
nret = snprintf(seccomp, sizeof(seccomp), "%s/seccomp", bundle);
if (nret < 0 || (size_t)nret >= sizeof(seccomp)) {
@@ -414,9 +416,9 @@ static char *lcr_save_seccomp_file(const char *bundle, const char *seccomp_conf)
goto cleanup;
}
- written_cnt = write(fd, seccomp_conf, strlen(seccomp_conf));
+ nwritten = isula_file_total_write_nointr(fd, seccomp_conf, strlen(seccomp_conf));
close(fd);
- if (written_cnt == -1) {
+ if (nwritten < 0 || (size_t)nwritten != strlen(seccomp_conf)) {
SYSERROR("write seccomp_conf failed");
goto cleanup;
}
@@ -609,14 +611,12 @@ out_free:
return NULL;
}
-
-static FILE *lcr_open_config_file(const char *bundle)
+static int lcr_open_config_file(const char *bundle)
{
char config[PATH_MAX] = { 0 };
char *real_config = NULL;
int fd = -1;
int nret;
- FILE *fp = NULL;
nret = snprintf(config, sizeof(config), "%s/config", bundle);
if (nret < 0 || (size_t)nret >= sizeof(config)) {
@@ -636,15 +636,9 @@ static FILE *lcr_open_config_file(const char *bundle)
goto out;
}
- fp = fdopen(fd, "w");
- if(fp == NULL){
- ERROR("FILE open failed");
- goto out;
- }
-
out:
free(real_config);
- return fp;
+ return fd;
}
// escape_string_encode unzip some escape characters
@@ -710,17 +704,19 @@ static char *escape_string_encode(const char *src)
return dst;
}
-static int lcr_spec_write_config(FILE *fp, const struct isula_linked_list *lcr_conf)
+static int lcr_spec_write_config(int fd, const struct isula_linked_list *lcr_conf)
{
size_t len;
- int ret = -1;
+ char *line = NULL;
struct isula_linked_list *it = NULL;
char *line_encode = NULL;
- char *line = NULL;
+ int ret = -1;
isula_linked_list_for_each(it, lcr_conf) {
lcr_config_item_t *item = it->elem;
int nret;
+ size_t encode_len;
+ ssize_t nwritten = -1;
if (item != NULL) {
if (strlen(item->value) > ((SIZE_MAX - strlen(item->name)) - 4)) {
goto cleanup;
@@ -733,6 +729,7 @@ static int lcr_spec_write_config(FILE *fp, const struct isula_linked_list *lcr_c
}
nret = snprintf(line, len, "%s = %s", item->name, item->value);
+
if (nret < 0 || (size_t)nret >= len) {
ERROR("Sprintf failed");
goto cleanup;
@@ -744,10 +741,11 @@ static int lcr_spec_write_config(FILE *fp, const struct isula_linked_list *lcr_c
goto cleanup;
}
- len = strlen(line_encode);
- line_encode[len] = '\n';
+ encode_len = strlen(line_encode);
- if (fwrite(line_encode, 1, len + 1, fp) != len + 1) {
+ line_encode[encode_len] = '\n';
+ nwritten = isula_file_total_write_nointr(fd, line_encode, encode_len + 1);
+ if (nwritten < 0 || (size_t)nwritten != encode_len + 1) {
SYSERROR("Write file failed");
goto cleanup;
}
@@ -816,7 +814,7 @@ bool lcr_save_spec(const char *name, const char *lcrpath, const struct isula_lin
const char *path = lcrpath ? lcrpath : LCRPATH;
char *bundle = NULL;
char *seccomp = NULL;
- FILE *fp = NULL;
+ int fd = -1;
int nret = 0;
if (name == NULL) {
@@ -841,17 +839,17 @@ bool lcr_save_spec(const char *name, const char *lcrpath, const struct isula_lin
}
}
- fp = lcr_open_config_file(bundle);
- if (fp == NULL) {
+ fd = lcr_open_config_file(bundle);
+ if (fd == -1) {
goto out_free;
}
- if (lcr_spec_write_config(fp, lcr_conf)) {
+ if (lcr_spec_write_config(fd, lcr_conf)) {
goto out_free;
}
if (seccomp_conf != NULL) {
- nret = lcr_spec_write_seccomp_line(fp, seccomp);
+ nret = lcr_spec_write_seccomp_line(fd, seccomp);
if (nret) {
goto out_free;
}
@@ -860,11 +858,11 @@ bool lcr_save_spec(const char *name, const char *lcrpath, const struct isula_lin
bret = true;
out_free:
- if (fp != NULL) {
- fclose(fp);
- }
- free(seccomp);
free(bundle);
+ free(seccomp);
+ if (fd != -1) {
+ close(fd);
+ }
return bret;
}
@@ -874,6 +872,7 @@ static int lcr_write_file(const char *path, const char *data, size_t len)
char *real_path = NULL;
int fd = -1;
int ret = -1;
+ ssize_t nwritten = -1;
if (path == NULL || strlen(path) == 0 || data == NULL || len == 0) {
return -1;
@@ -891,7 +890,8 @@ static int lcr_write_file(const char *path, const char *data, size_t len)
goto out_free;
}
- if (write(fd, data, len) == -1) {
+ nwritten = isula_file_total_write_nointr(fd, data, len);
+ if (nwritten < 0 || (size_t)nwritten != len) {
SYSERROR("write data to %s failed", real_path);
goto out_free;
}
--
2.34.1

View File

@ -0,0 +1,250 @@
From c215d7911baf0c17181dda3f2d613bedab11cb88 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 14 May 2024 07:50:38 +0000
Subject: [PATCH 14/14] add codecheck fix
Signed-off-by: jikai <jikai11@huawei.com>
---
src/runtime/conf.c | 2 +-
src/runtime/conf.h | 2 +-
src/runtime/error.c | 1 -
src/utils/utils_array.h | 6 +++---
src/utils/utils_cgroup.c | 2 +-
src/utils/utils_cgroup.h | 5 +++--
src/utils/utils_convert.c | 2 +-
src/utils/utils_convert.h | 2 +-
src/utils/utils_file.c | 16 ++++++++--------
src/utils/utils_mainloop.c | 2 +-
src/utils/utils_memory.h | 1 -
src/utils/utils_string.h | 2 +-
12 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/src/runtime/conf.c b/src/runtime/conf.c
index de07353..5cf6e3f 100644
--- a/src/runtime/conf.c
+++ b/src/runtime/conf.c
@@ -3242,7 +3242,7 @@ static int add_needed_net_conf(struct isula_linked_list *conf)
}
/* get needed lxc conf */
-struct isula_linked_list *get_needed_lxc_conf()
+struct isula_linked_list *get_needed_lxc_conf(void)
{
struct isula_linked_list *conf = isula_common_calloc_s(sizeof(*conf));
if (conf == NULL) {
diff --git a/src/runtime/conf.h b/src/runtime/conf.h
index 7ee8184..45cee0a 100644
--- a/src/runtime/conf.h
+++ b/src/runtime/conf.h
@@ -117,7 +117,7 @@ struct isula_linked_list *trans_annotations(const json_map_string_string *anno);
/*
* Get other lxc needed configurations
*/
-struct isula_linked_list *get_needed_lxc_conf();
+struct isula_linked_list *get_needed_lxc_conf(void);
bool is_system_container(const oci_runtime_spec *container);
diff --git a/src/runtime/error.c b/src/runtime/error.c
index d0bfcce..52561b1 100644
--- a/src/runtime/error.c
+++ b/src/runtime/error.c
@@ -27,7 +27,6 @@
#include "utils_memory.h"
#include "utils_string.h"
-#include "constants.h"
// record the lcr error
__thread engine_error_t g_lcr_error = {
diff --git a/src/utils/utils_array.h b/src/utils/utils_array.h
index 1fc167d..527b0f4 100644
--- a/src/utils/utils_array.h
+++ b/src/utils/utils_array.h
@@ -29,11 +29,11 @@
extern "C" {
#endif
-void isula_free_array(void **array);
+void isula_free_array(void **orig_array);
-int isula_grow_array(void ***array, size_t *capacity, size_t new_size, size_t capacity_increment);
+int isula_grow_array(void ***orig_array, size_t *orig_capacity, size_t size, size_t increment);
-size_t isula_array_len(void **array);
+size_t isula_array_len(void **orig_array);
typedef void *(*clone_cb)(const void *src);
int isula_array_append(void ***array, const void *element, clone_cb cb);
diff --git a/src/utils/utils_cgroup.c b/src/utils/utils_cgroup.c
index bd3bc42..71fcc1b 100644
--- a/src/utils/utils_cgroup.c
+++ b/src/utils/utils_cgroup.c
@@ -81,7 +81,7 @@ uint64_t lcr_util_trans_blkio_weight_to_io_bfq_weight(int weight)
return (uint64_t)(1 + ((uint64_t)weight - 10) * 999 / 990);
}
-int lcr_util_get_cgroup_version()
+int lcr_util_get_cgroup_version(void)
{
struct statfs fs = {0};
diff --git a/src/utils/utils_cgroup.h b/src/utils/utils_cgroup.h
index 18b404b..e82adfb 100644
--- a/src/utils/utils_cgroup.h
+++ b/src/utils/utils_cgroup.h
@@ -23,9 +23,10 @@
#ifndef _ISULA_UTILS_UTILS_CGROUP_H
#define _ISULA_UTILS_UTILS_CGROUP_H
+#include <stdint.h>
+
#include <sys/types.h>
#include <linux/magic.h>
-#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@@ -54,7 +55,7 @@ int lcr_util_get_real_swap(int64_t memory, int64_t memory_swap, int64_t *swap);
int lcr_util_trans_cpushare_to_cpuweight(int64_t cpu_share);
uint64_t lcr_util_trans_blkio_weight_to_io_weight(int weight);
uint64_t lcr_util_trans_blkio_weight_to_io_bfq_weight(int weight);
-int lcr_util_get_cgroup_version();
+int lcr_util_get_cgroup_version(void);
#ifdef __cplusplus
}
diff --git a/src/utils/utils_convert.c b/src/utils/utils_convert.c
index f3e38c4..6bdeb04 100644
--- a/src/utils/utils_convert.c
+++ b/src/utils/utils_convert.c
@@ -325,7 +325,7 @@ int isula_parse_byte_size_string(const char *s, int64_t *converted)
}
ret = parse_unit_multiple(pmlt, &mltpl);
- if (ret) {
+ if (ret != 0) {
return ret;
}
diff --git a/src/utils/utils_convert.h b/src/utils/utils_convert.h
index 47d37e7..ac34772 100644
--- a/src/utils/utils_convert.h
+++ b/src/utils/utils_convert.h
@@ -43,7 +43,7 @@ int isula_safe_strto_uint16(const char *numstr, uint16_t *converted);
int isula_safe_strto_uint64(const char *numstr, uint64_t *converted);
-int isula_safe_strto_int(const char *numstr, int *converted);
+int isula_safe_strto_int(const char *num_str, int *converted);
int isula_safe_strto_uint(const char *numstr, unsigned int *converted);
diff --git a/src/utils/utils_file.c b/src/utils/utils_file.c
index d7ff4af..b742d20 100644
--- a/src/utils/utils_file.c
+++ b/src/utils/utils_file.c
@@ -62,12 +62,12 @@ static int do_clean_path(const char *respath, const char *limit_respath, const c
char *dest = *dst;
const char *endpos = stpos;
- for (; *stpos; stpos = endpos) {
+ for (; *stpos != '\0'; stpos = endpos) {
while (ISSLASH(*stpos)) {
++stpos;
}
- for (endpos = stpos; *endpos && !ISSLASH(*endpos); ++endpos) {
+ for (endpos = stpos; (*endpos != '\0') && !ISSLASH(*endpos); ++endpos) {
}
if (endpos - stpos == 0) {
@@ -139,7 +139,7 @@ char *isula_clean_path(const char *path, char *realpath, size_t realpath_len)
stpos = path;
}
- if (do_clean_path(respath, limit_respath, stpos, &dest)) {
+ if (do_clean_path(respath, limit_respath, stpos, &dest) != 0) {
return NULL;
}
@@ -243,7 +243,7 @@ static void util_rmdir_one(const char *dirpath, const struct dirent *pdirent, in
}
nret = lstat(fname, &fstat);
- if (nret) {
+ if (nret != 0) {
ERROR("Failed to stat %s", fname);
*failure = -1;
return;
@@ -405,9 +405,9 @@ int isula_dir_build(const char *name)
continue;
}
set_char_to_terminator(p);
- if (access(n, F_OK)) {
+ if (access(n, F_OK) != 0) {
nret = mkdir(n, DEFAULT_SECURE_DIRECTORY_MODE);
- if (nret && (errno != EEXIST || !isula_dir_exists(n))) {
+ if (nret != 0 && (errno != EEXIST || !isula_dir_exists(n))) {
ERROR("failed to create directory '%s'.", n);
free(n);
return -1;
@@ -451,7 +451,7 @@ int isula_dir_recursive_mk(const char *dir, mode_t mode)
ERROR("strndup failed");
return -1;
}
- if (*cur_dir) {
+ if (*cur_dir != '\0') {
ret = mkdir(cur_dir, mode);
if (ret != 0 && (errno != EEXIST || !isula_dir_exists(cur_dir))) {
SYSERROR("failed to create directory '%s'", cur_dir);
@@ -536,7 +536,7 @@ static int append_new_content_to_file(FILE *fp, const char *content)
return -1;
}
util_trim_newline(line);
- if (!strcmp(content, line)) {
+ if (strcmp(content, line) == 0) {
need_append = false;
break;
}
diff --git a/src/utils/utils_mainloop.c b/src/utils/utils_mainloop.c
index cc6a8ae..c45b32c 100644
--- a/src/utils/utils_mainloop.c
+++ b/src/utils/utils_mainloop.c
@@ -142,7 +142,7 @@ int isula_epoll_remove_handler(isula_epoll_descr_t *descr, int fd)
epoll_handler = index->elem;
if (fd == epoll_handler->cbfd) {
- if (epoll_ctl(descr->fd, EPOLL_CTL_DEL, fd, NULL)) {
+ if (epoll_ctl(descr->fd, EPOLL_CTL_DEL, fd, NULL) != 0) {
return -1;
}
diff --git a/src/utils/utils_memory.h b/src/utils/utils_memory.h
index 4749622..7b9528c 100644
--- a/src/utils/utils_memory.h
+++ b/src/utils/utils_memory.h
@@ -23,7 +23,6 @@
#ifndef _ISULA_UTILS_UTILS_MEMORY_H
#define _ISULA_UTILS_UTILS_MEMORY_H
-#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
diff --git a/src/utils/utils_string.h b/src/utils/utils_string.h
index 5a25531..407158c 100644
--- a/src/utils/utils_string.h
+++ b/src/utils/utils_string.h
@@ -48,7 +48,7 @@ char *isula_string_append(const char *pre, const char *add_str);
/*
* Replace 'needle' in string haystack with 'replacement';
*/
-char *isula_string_replace(const char *needle, const char *replacement, const char *haystack);
+char *isula_string_replace(const char *needle, const char *replace, const char *haystack);
struct __isula_string_array;
--
2.34.1

View File

@ -0,0 +1,32 @@
From 402f757eb53038d17c4b5ec48dbdd86df7006957 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Mon, 8 Jul 2024 12:05:46 +0000
Subject: [PATCH 15/20] fix invalid args len set in execute_lxc_attach
Signed-off-by: jikai <jikai11@huawei.com>
---
src/runtime/lcrcontainer_execute.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/runtime/lcrcontainer_execute.c b/src/runtime/lcrcontainer_execute.c
index 251fb85..e4cdcc1 100644
--- a/src/runtime/lcrcontainer_execute.c
+++ b/src/runtime/lcrcontainer_execute.c
@@ -836,7 +836,13 @@ static void execute_lxc_attach(const char *name, const char *path, const struct
exit(EXIT_FAILURE);
}
- args_len = args_len + request->args_len + request->env_len;
+ if (args_len > SIZE_MAX - request->args_len || request->env_len > SIZE_MAX / 2
+ || args_len + request->args_len > SIZE_MAX - request->env_len * 2) {
+ COMMAND_ERROR("Too many arguments");
+ exit(EXIT_FAILURE);
+ }
+
+ args_len = args_len + request->args_len + request->env_len * 2;
params = isula_smart_calloc_s(sizeof(char *), args_len);
if (params == NULL) {
--
2.33.0

View File

@ -0,0 +1,985 @@
From 2560ee5a4765d7e378eb906da2e84dc1d3202e30 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Sat, 6 Jul 2024 03:14:43 +0000
Subject: [PATCH 16/20] add nri definitions
Signed-off-by: jikai <jikai11@huawei.com>
---
src/json/schema/nri/configure-request.json | 15 ++++++
src/json/schema/nri/configure-response.json | 9 ++++
src/json/schema/nri/container-adjustment.json | 33 ++++++++++++
src/json/schema/nri/container-eviction.json | 12 +++++
src/json/schema/nri/container-update.json | 15 ++++++
src/json/schema/nri/container.json | 51 +++++++++++++++++++
.../schema/nri/create-container-request.json | 12 +++++
.../schema/nri/create-container-response.json | 21 ++++++++
src/json/schema/nri/hook.json | 18 +++++++
src/json/schema/nri/hooks.json | 42 +++++++++++++++
src/json/schema/nri/hugepage-limit.json | 12 +++++
src/json/schema/nri/key-value.json | 12 +++++
.../nri/linux-container-adjustment.json | 18 +++++++
.../schema/nri/linux-container-update.json | 9 ++++
src/json/schema/nri/linux-container.json | 27 ++++++++++
src/json/schema/nri/linux-cpu.json | 27 ++++++++++
src/json/schema/nri/linux-device-cgroup.json | 21 ++++++++
src/json/schema/nri/linux-device.json | 27 ++++++++++
src/json/schema/nri/linux-memory.json | 30 +++++++++++
src/json/schema/nri/linux-namespace.json | 12 +++++
src/json/schema/nri/linux-pod-sandbox.json | 27 ++++++++++
src/json/schema/nri/linux-resources.json | 33 ++++++++++++
src/json/schema/nri/mount.json | 18 +++++++
src/json/schema/nri/pod-sandbox.json | 33 ++++++++++++
src/json/schema/nri/posix-rlimit.json | 15 ++++++
.../schema/nri/register-plugin-request.json | 12 +++++
src/json/schema/nri/state-change-event.json | 15 ++++++
.../schema/nri/stop-container-request.json | 12 +++++
.../schema/nri/stop-container-response.json | 12 +++++
src/json/schema/nri/synchronize-request.json | 18 +++++++
src/json/schema/nri/synchronize-response.json | 12 +++++
.../schema/nri/update-container-request.json | 15 ++++++
.../schema/nri/update-container-response.json | 18 +++++++
.../schema/nri/update-containers-request.json | 18 +++++++
.../nri/update-containers-response.json | 12 +++++
35 files changed, 693 insertions(+)
create mode 100644 src/json/schema/nri/configure-request.json
create mode 100644 src/json/schema/nri/configure-response.json
create mode 100644 src/json/schema/nri/container-adjustment.json
create mode 100644 src/json/schema/nri/container-eviction.json
create mode 100644 src/json/schema/nri/container-update.json
create mode 100644 src/json/schema/nri/container.json
create mode 100644 src/json/schema/nri/create-container-request.json
create mode 100644 src/json/schema/nri/create-container-response.json
create mode 100644 src/json/schema/nri/hook.json
create mode 100644 src/json/schema/nri/hooks.json
create mode 100644 src/json/schema/nri/hugepage-limit.json
create mode 100644 src/json/schema/nri/key-value.json
create mode 100644 src/json/schema/nri/linux-container-adjustment.json
create mode 100644 src/json/schema/nri/linux-container-update.json
create mode 100644 src/json/schema/nri/linux-container.json
create mode 100644 src/json/schema/nri/linux-cpu.json
create mode 100644 src/json/schema/nri/linux-device-cgroup.json
create mode 100644 src/json/schema/nri/linux-device.json
create mode 100644 src/json/schema/nri/linux-memory.json
create mode 100644 src/json/schema/nri/linux-namespace.json
create mode 100644 src/json/schema/nri/linux-pod-sandbox.json
create mode 100644 src/json/schema/nri/linux-resources.json
create mode 100644 src/json/schema/nri/mount.json
create mode 100644 src/json/schema/nri/pod-sandbox.json
create mode 100644 src/json/schema/nri/posix-rlimit.json
create mode 100644 src/json/schema/nri/register-plugin-request.json
create mode 100644 src/json/schema/nri/state-change-event.json
create mode 100644 src/json/schema/nri/stop-container-request.json
create mode 100644 src/json/schema/nri/stop-container-response.json
create mode 100644 src/json/schema/nri/synchronize-request.json
create mode 100644 src/json/schema/nri/synchronize-response.json
create mode 100644 src/json/schema/nri/update-container-request.json
create mode 100644 src/json/schema/nri/update-container-response.json
create mode 100644 src/json/schema/nri/update-containers-request.json
create mode 100644 src/json/schema/nri/update-containers-response.json
diff --git a/src/json/schema/nri/configure-request.json b/src/json/schema/nri/configure-request.json
new file mode 100644
index 0000000..895d565
--- /dev/null
+++ b/src/json/schema/nri/configure-request.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "config": {
+ "type": "string"
+ },
+ "runtime_name": {
+ "type": "string"
+ },
+ "runtime_version": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/configure-response.json b/src/json/schema/nri/configure-response.json
new file mode 100644
index 0000000..e18ef06
--- /dev/null
+++ b/src/json/schema/nri/configure-response.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "events": {
+ "$ref": "../defs.json#/definitions/int32"
+ }
+ }
+}
diff --git a/src/json/schema/nri/container-adjustment.json b/src/json/schema/nri/container-adjustment.json
new file mode 100644
index 0000000..e656e66
--- /dev/null
+++ b/src/json/schema/nri/container-adjustment.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "annotations": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "mounts": {
+ "type": "array",
+ "items": {
+ "$ref": "mount.json"
+ }
+ },
+ "env": {
+ "type": "array",
+ "items": {
+ "$ref": "key-value.json"
+ }
+ },
+ "hooks": {
+ "$ref": "hooks.json"
+ },
+ "linux": {
+ "$ref": "linux-container-adjustment.json"
+ },
+ "rlimits": {
+ "type": "array",
+ "items": {
+ "$ref": "posix-rlimit.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/container-eviction.json b/src/json/schema/nri/container-eviction.json
new file mode 100644
index 0000000..c7530c3
--- /dev/null
+++ b/src/json/schema/nri/container-eviction.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "container_id": {
+ "type": "string"
+ },
+ "reason": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/container-update.json b/src/json/schema/nri/container-update.json
new file mode 100644
index 0000000..b1fb034
--- /dev/null
+++ b/src/json/schema/nri/container-update.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "container_id": {
+ "type": "string"
+ },
+ "linux": {
+ "$ref": "linux-container-update.json"
+ },
+ "ignore_failure": {
+ "$ref": "../defs.json#/definitions/uint8"
+ }
+ }
+}
diff --git a/src/json/schema/nri/container.json b/src/json/schema/nri/container.json
new file mode 100644
index 0000000..9a48765
--- /dev/null
+++ b/src/json/schema/nri/container.json
@@ -0,0 +1,51 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "pod_sandbox_id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "state": {
+ "$ref": "../defs.json#/definitions/int32"
+ },
+ "labels": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "annotations": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "args": {
+ "$ref": "../defs.json#/definitions/ArrayOfStrings"
+ },
+ "env": {
+ "$ref": "../defs.json#/definitions/ArrayOfStrings"
+ },
+ "mounts": {
+ "type": "array",
+ "items": {
+ "$ref": "mount.json"
+ }
+ },
+ "hooks": {
+ "$ref": "hooks.json"
+ },
+ "linux": {
+ "$ref": "linux-container.json"
+ },
+ "pid": {
+ "$ref": "../defs.json#/definitions/uint32"
+ },
+ "rlimits": {
+ "type": "array",
+ "items": {
+ "$ref": "posix-rlimit.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/create-container-request.json b/src/json/schema/nri/create-container-request.json
new file mode 100644
index 0000000..1a9d17c
--- /dev/null
+++ b/src/json/schema/nri/create-container-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "pod": {
+ "$ref": "pod-sandbox.json"
+ },
+ "container": {
+ "$ref": "container.json"
+ }
+ }
+}
diff --git a/src/json/schema/nri/create-container-response.json b/src/json/schema/nri/create-container-response.json
new file mode 100644
index 0000000..5f82ae5
--- /dev/null
+++ b/src/json/schema/nri/create-container-response.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "adjust": {
+ "$ref": "container-adjustment.json"
+ },
+ "update": {
+ "type": "array",
+ "items": {
+ "$ref": "container-update.json"
+ }
+ },
+ "evict": {
+ "type": "array",
+ "items": {
+ "$ref": "container-eviction.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/hook.json b/src/json/schema/nri/hook.json
new file mode 100644
index 0000000..b7bb093
--- /dev/null
+++ b/src/json/schema/nri/hook.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "args": {
+ "$ref": "../defs.json#/definitions/ArrayOfStrings"
+ },
+ "env": {
+ "$ref": "../defs.json#/definitions/ArrayOfStrings"
+ },
+ "timeout": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ }
+ }
+}
diff --git a/src/json/schema/nri/hooks.json b/src/json/schema/nri/hooks.json
new file mode 100644
index 0000000..c2a42a9
--- /dev/null
+++ b/src/json/schema/nri/hooks.json
@@ -0,0 +1,42 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "prestart": {
+ "type": "array",
+ "items": {
+ "$ref": "hook.json"
+ }
+ },
+ "create_runtime": {
+ "type": "array",
+ "items": {
+ "$ref": "hook.json"
+ }
+ },
+ "create_container": {
+ "type": "array",
+ "items": {
+ "$ref": "hook.json"
+ }
+ },
+ "start_container": {
+ "type": "array",
+ "items": {
+ "$ref": "hook.json"
+ }
+ },
+ "poststart": {
+ "type": "array",
+ "items": {
+ "$ref": "hook.json"
+ }
+ },
+ "poststop": {
+ "type": "array",
+ "items": {
+ "$ref": "hook.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/hugepage-limit.json b/src/json/schema/nri/hugepage-limit.json
new file mode 100644
index 0000000..ce909ef
--- /dev/null
+++ b/src/json/schema/nri/hugepage-limit.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "page_size": {
+ "type": "string"
+ },
+ "limit": {
+ "$ref": "../defs.json#/definitions/uint64"
+ }
+ }
+}
diff --git a/src/json/schema/nri/key-value.json b/src/json/schema/nri/key-value.json
new file mode 100644
index 0000000..f6eedc6
--- /dev/null
+++ b/src/json/schema/nri/key-value.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string"
+ },
+ "value": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-container-adjustment.json b/src/json/schema/nri/linux-container-adjustment.json
new file mode 100644
index 0000000..54d16e7
--- /dev/null
+++ b/src/json/schema/nri/linux-container-adjustment.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "devices": {
+ "type": "array",
+ "items": {
+ "$ref": "linux-device.json"
+ }
+ },
+ "resources": {
+ "$ref": "linux-resources.json"
+ },
+ "cgroups-path": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-container-update.json b/src/json/schema/nri/linux-container-update.json
new file mode 100644
index 0000000..ddc627d
--- /dev/null
+++ b/src/json/schema/nri/linux-container-update.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "resources": {
+ "$ref": "linux-resources.json"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-container.json b/src/json/schema/nri/linux-container.json
new file mode 100644
index 0000000..72978db
--- /dev/null
+++ b/src/json/schema/nri/linux-container.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "namespaces": {
+ "type": "array",
+ "items": {
+ "$ref": "linux-namespace.json"
+ }
+ },
+ "devices": {
+ "type": "array",
+ "items": {
+ "$ref": "linux-device.json"
+ }
+ },
+ "resources": {
+ "$ref": "linux-resources.json"
+ },
+ "oom_score_adj": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "cgroups_path": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-cpu.json b/src/json/schema/nri/linux-cpu.json
new file mode 100644
index 0000000..c8cdf95
--- /dev/null
+++ b/src/json/schema/nri/linux-cpu.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "shares": {
+ "$ref": "../defs.json#/definitions/uint64Pointer"
+ },
+ "quota": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "period": {
+ "$ref": "../defs.json#/definitions/uint64Pointer"
+ },
+ "realtime_runtime": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "realtime_period": {
+ "$ref": "../defs.json#/definitions/uint64Pointer"
+ },
+ "cpus": {
+ "type": "string"
+ },
+ "mems": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-device-cgroup.json b/src/json/schema/nri/linux-device-cgroup.json
new file mode 100644
index 0000000..feac3c8
--- /dev/null
+++ b/src/json/schema/nri/linux-device-cgroup.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "allow": {
+ "$ref": "../defs.json#/definitions/uint8"
+ },
+ "type": {
+ "type": "string"
+ },
+ "major": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "minor": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "access": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-device.json b/src/json/schema/nri/linux-device.json
new file mode 100644
index 0000000..a7db26e
--- /dev/null
+++ b/src/json/schema/nri/linux-device.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "path": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "major": {
+ "$ref": "../defs.json#/definitions/int64"
+ },
+ "minor": {
+ "$ref": "../defs.json#/definitions/int64"
+ },
+ "file_mode": {
+ "$ref": "../defs.json#/definitions/uint32Pointer"
+ },
+ "uid": {
+ "$ref": "../defs.json#/definitions/uint32Pointer"
+ },
+ "gid": {
+ "$ref": "../defs.json#/definitions/uint32Pointer"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-memory.json b/src/json/schema/nri/linux-memory.json
new file mode 100644
index 0000000..a5a841f
--- /dev/null
+++ b/src/json/schema/nri/linux-memory.json
@@ -0,0 +1,30 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "limit": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "reservation": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "swap": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "kernel": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "kernel_tcp": {
+ "$ref": "../defs.json#/definitions/int64Pointer"
+ },
+ "swappiness": {
+ "$ref": "../defs.json#/definitions/uint64Pointer"
+ },
+ "disable_oom_killer": {
+ "$ref": "../defs.json#/definitions/uint8Pointer"
+ },
+ "use_hierarchy": {
+ "$ref": "../defs.json#/definitions/uint8Pointer"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-namespace.json b/src/json/schema/nri/linux-namespace.json
new file mode 100644
index 0000000..9e1e386
--- /dev/null
+++ b/src/json/schema/nri/linux-namespace.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-pod-sandbox.json b/src/json/schema/nri/linux-pod-sandbox.json
new file mode 100644
index 0000000..0c963be
--- /dev/null
+++ b/src/json/schema/nri/linux-pod-sandbox.json
@@ -0,0 +1,27 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "pod_overhead": {
+ "$ref": "linux-resources.json"
+ },
+ "pod_resources": {
+ "$ref": "linux-resources.json"
+ },
+ "cgroup_parent": {
+ "type": "string"
+ },
+ "cgroups_path": {
+ "type": "string"
+ },
+ "namespaces": {
+ "type": "array",
+ "items": {
+ "$ref": "linux-namespace.json"
+ }
+ },
+ "resources": {
+ "$ref": "linux-resources.json"
+ }
+ }
+}
diff --git a/src/json/schema/nri/linux-resources.json b/src/json/schema/nri/linux-resources.json
new file mode 100644
index 0000000..1d16960
--- /dev/null
+++ b/src/json/schema/nri/linux-resources.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "memory": {
+ "$ref": "linux-memory.json"
+ },
+ "cpu": {
+ "$ref": "linux-cpu.json"
+ },
+ "hugepage_limits": {
+ "type": "array",
+ "items": {
+ "$ref": "hugepage-limit.json"
+ }
+ },
+ "blockio_class": {
+ "type": "string"
+ },
+ "rdt_class": {
+ "type": "string"
+ },
+ "unified": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "devices": {
+ "type": "array",
+ "items": {
+ "$ref": "linux-device-cgroup.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/mount.json b/src/json/schema/nri/mount.json
new file mode 100644
index 0000000..ae9c666
--- /dev/null
+++ b/src/json/schema/nri/mount.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "destination": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ },
+ "options": {
+ "$ref": "../defs.json#/definitions/ArrayOfStrings"
+ }
+ }
+}
diff --git a/src/json/schema/nri/pod-sandbox.json b/src/json/schema/nri/pod-sandbox.json
new file mode 100644
index 0000000..85a1284
--- /dev/null
+++ b/src/json/schema/nri/pod-sandbox.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "uid": {
+ "type": "string"
+ },
+ "_namespace": {
+ "type": "string"
+ },
+ "labels": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "annotations": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "runtime_handler": {
+ "type": "string"
+ },
+ "linux": {
+ "$ref": "linux-pod-sandbox.json"
+ },
+ "pid": {
+ "$ref": "../defs.json#/definitions/uint32"
+ }
+ }
+}
diff --git a/src/json/schema/nri/posix-rlimit.json b/src/json/schema/nri/posix-rlimit.json
new file mode 100644
index 0000000..1ba8e20
--- /dev/null
+++ b/src/json/schema/nri/posix-rlimit.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "hard": {
+ "$ref": "../defs.json#/definitions/uint64"
+ },
+ "soft": {
+ "$ref": "../defs.json#/definitions/uint64"
+ }
+ }
+}
diff --git a/src/json/schema/nri/register-plugin-request.json b/src/json/schema/nri/register-plugin-request.json
new file mode 100644
index 0000000..436264a
--- /dev/null
+++ b/src/json/schema/nri/register-plugin-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "plugin_name": {
+ "type": "string"
+ },
+ "plugin_idx": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/nri/state-change-event.json b/src/json/schema/nri/state-change-event.json
new file mode 100644
index 0000000..0131aeb
--- /dev/null
+++ b/src/json/schema/nri/state-change-event.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "event": {
+ "$ref": "../defs.json#/definitions/int32"
+ },
+ "pod": {
+ "$ref": "pod-sandbox.json"
+ },
+ "container": {
+ "$ref": "container.json"
+ }
+ }
+}
diff --git a/src/json/schema/nri/stop-container-request.json b/src/json/schema/nri/stop-container-request.json
new file mode 100644
index 0000000..1a9d17c
--- /dev/null
+++ b/src/json/schema/nri/stop-container-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "pod": {
+ "$ref": "pod-sandbox.json"
+ },
+ "container": {
+ "$ref": "container.json"
+ }
+ }
+}
diff --git a/src/json/schema/nri/stop-container-response.json b/src/json/schema/nri/stop-container-response.json
new file mode 100644
index 0000000..bf535f6
--- /dev/null
+++ b/src/json/schema/nri/stop-container-response.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "update": {
+ "type": "array",
+ "items": {
+ "$ref": "container-update.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/synchronize-request.json b/src/json/schema/nri/synchronize-request.json
new file mode 100644
index 0000000..689baff
--- /dev/null
+++ b/src/json/schema/nri/synchronize-request.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "pods": {
+ "type": "array",
+ "items": {
+ "$ref": "pod-sandbox.json"
+ }
+ },
+ "containers": {
+ "type": "array",
+ "items": {
+ "$ref": "container.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/synchronize-response.json b/src/json/schema/nri/synchronize-response.json
new file mode 100644
index 0000000..bf535f6
--- /dev/null
+++ b/src/json/schema/nri/synchronize-response.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "update": {
+ "type": "array",
+ "items": {
+ "$ref": "container-update.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/update-container-request.json b/src/json/schema/nri/update-container-request.json
new file mode 100644
index 0000000..782481c
--- /dev/null
+++ b/src/json/schema/nri/update-container-request.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "pod": {
+ "$ref": "pod-sandbox.json"
+ },
+ "container": {
+ "$ref": "container.json"
+ },
+ "linux_resources": {
+ "$ref": "linux-resources.json"
+ }
+ }
+}
diff --git a/src/json/schema/nri/update-container-response.json b/src/json/schema/nri/update-container-response.json
new file mode 100644
index 0000000..affee62
--- /dev/null
+++ b/src/json/schema/nri/update-container-response.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "update": {
+ "type": "array",
+ "items": {
+ "$ref": "container-update.json"
+ }
+ },
+ "evict": {
+ "type": "array",
+ "items": {
+ "$ref": "container-eviction.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/update-containers-request.json b/src/json/schema/nri/update-containers-request.json
new file mode 100644
index 0000000..affee62
--- /dev/null
+++ b/src/json/schema/nri/update-containers-request.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "update": {
+ "type": "array",
+ "items": {
+ "$ref": "container-update.json"
+ }
+ },
+ "evict": {
+ "type": "array",
+ "items": {
+ "$ref": "container-eviction.json"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/nri/update-containers-response.json b/src/json/schema/nri/update-containers-response.json
new file mode 100644
index 0000000..361e134
--- /dev/null
+++ b/src/json/schema/nri/update-containers-response.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "failed": {
+ "type": "array",
+ "items": {
+ "$ref": "container-update.json"
+ }
+ }
+ }
+}
--
2.33.0

View File

@ -0,0 +1,60 @@
From 0f032f9748bdf676355520fdd4d2e89f7a1c4c2f Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Fri, 14 Jun 2024 15:47:08 +0800
Subject: [PATCH 17/20] add struct for nri
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/container/create-request.json | 3 +++
src/json/schema/isulad-daemon-configs.json | 21 +++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/src/json/schema/container/create-request.json b/src/json/schema/container/create-request.json
index 4d9d1ff..e19394d 100644
--- a/src/json/schema/container/create-request.json
+++ b/src/json/schema/container/create-request.json
@@ -20,6 +20,9 @@
"sandbox": {
"$ref": "sandbox-info.json"
},
+ "adjust": {
+ "$ref": "../nri/container-adjustment.json"
+ },
"hostconfig": {
"type": "string"
},
diff --git a/src/json/schema/isulad-daemon-configs.json b/src/json/schema/isulad-daemon-configs.json
index cd8948a..7b148bd 100644
--- a/src/json/schema/isulad-daemon-configs.json
+++ b/src/json/schema/isulad-daemon-configs.json
@@ -100,6 +100,27 @@
"cni-conf-dir": {
"type": "string"
},
+ "nri-support" : {
+ "type": "boolean"
+ },
+ "disable-connections" : {
+ "type": "boolean"
+ },
+ "plugin_config_path": {
+ "type": "string"
+ },
+ "plugin_path": {
+ "type": "string"
+ },
+ "nri_socket_path": {
+ "type": "string"
+ },
+ "plugin_registration_timeout": {
+ "type": "uint64"
+ },
+ "plugin_requst_timeout": {
+ "type": "uint64"
+ },
"image-layer-check": {
"type": "boolean"
},
--
2.33.0

View File

@ -0,0 +1,59 @@
From 86c8f125b55993be85ca6d0982d3036452481479 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sun, 18 Aug 2024 04:31:18 +0800
Subject: [PATCH 18/20] add nri def in host config
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/host-config.json | 35 ++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/json/schema/host-config.json b/src/json/schema/host-config.json
index 6af8021..a9679bd 100644
--- a/src/json/schema/host-config.json
+++ b/src/json/schema/host-config.json
@@ -311,6 +311,41 @@
"items": {
"type": "string"
}
+ },
+ "NriDevices": {
+ "id": "https://opencontainers.org/schema/bundle/linux/devices",
+ "type": "array",
+ "items": {
+ "$ref": "defs.json#/definitions/Device"
+ }
+ },
+ "NriRlimits": {
+ "id": "https://opencontainers.org/schema/bundle/linux/rlimits",
+ "type": "array",
+ "items": {
+ "id": "https://opencontainers.org/schema/bundle/linux/rlimits/0",
+ "type": "object",
+ "required": [
+ "type",
+ "soft",
+ "hard"
+ ],
+ "properties": {
+ "hard": {
+ "id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/hard",
+ "$ref": "defs.json#/definitions/uint64"
+ },
+ "soft": {
+ "id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/soft",
+ "$ref": "defs.json#/definitions/uint64"
+ },
+ "type": {
+ "id": "https://opencontainers.org/schema/bundle/linux/rlimits/0/type",
+ "type": "string",
+ "pattern": "^RLIMIT_[A-Z]+$"
+ }
+ }
+ }
}
}
}
--
2.33.0

View File

@ -0,0 +1,76 @@
From 57d2fe1b26429490b61d09dc8402024dc51b4386 Mon Sep 17 00:00:00 2001
From: yuncang123 <1050706328@qq.com>
Date: Tue, 27 Aug 2024 14:39:33 +0800
Subject: [PATCH 19/20] fix invalid usage of arrtibute'visibility'
---
src/runtime/lcrcontainer.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/runtime/lcrcontainer.h b/src/runtime/lcrcontainer.h
index d4cef39..4eedec9 100644
--- a/src/runtime/lcrcontainer.h
+++ b/src/runtime/lcrcontainer.h
@@ -40,13 +40,13 @@ extern "C" {
/* define console log config */
-__EXPORT__ struct lcr_console_config {
+struct lcr_console_config {
char *log_path;
unsigned int log_rotate;
char *log_file_size;
};
-__EXPORT__ struct blkio_stats {
+struct blkio_stats {
uint64_t read;
uint64_t write;
uint64_t total;
@@ -55,7 +55,7 @@ __EXPORT__ struct blkio_stats {
/*
* Store lcr container state
*/
-__EXPORT__ struct lcr_container_state {
+struct lcr_container_state {
/* Name of container */
char *name;
/* State of container */
@@ -92,14 +92,14 @@ typedef enum {
lcr_msg_exit_code,
} lcr_msg_type_t;
-__EXPORT__ struct lcr_msg {
+struct lcr_msg {
lcr_msg_type_t type;
char name[NAME_MAX + 1];
int value;
int pid;
};
-__EXPORT__ struct lcr_cgroup_resources {
+struct lcr_cgroup_resources {
uint64_t blkio_weight;
uint64_t cpu_shares;
uint64_t cpu_period;
@@ -150,7 +150,7 @@ __EXPORT__ bool lcr_create(const char *name, const char *lcrpath, void *oci_conf
* gid : user in which group
* additional_gids : Add additional groups to join
*/
-__EXPORT__ struct lcr_start_request {
+struct lcr_start_request {
const char *name;
const char *lcrpath;
@@ -237,7 +237,7 @@ __EXPORT__ void lcr_free_console_config(struct lcr_console_config *config);
__EXPORT__ int lcr_log_init(const char *name, const char *file, const char *priority,
const char *prefix, int quiet, const char *lcrpath);
-__EXPORT__ struct lcr_exec_request {
+struct lcr_exec_request {
const char *name;
const char *lcrpath;
--
2.33.0

View File

@ -0,0 +1,42 @@
From 6fd7cdec3c383461695f45e96d59353c68ecf286 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 4 Sep 2024 10:38:08 +0800
Subject: [PATCH 20/20] unify nri variable format
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/isulad-daemon-configs.json | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/json/schema/isulad-daemon-configs.json b/src/json/schema/isulad-daemon-configs.json
index 7b148bd..e21c3cf 100644
--- a/src/json/schema/isulad-daemon-configs.json
+++ b/src/json/schema/isulad-daemon-configs.json
@@ -106,19 +106,19 @@
"disable-connections" : {
"type": "boolean"
},
- "plugin_config_path": {
+ "plugin-config-path": {
"type": "string"
},
- "plugin_path": {
+ "plugin-path": {
"type": "string"
},
- "nri_socket_path": {
+ "nri-socket-path": {
"type": "string"
},
- "plugin_registration_timeout": {
+ "plugin-registration-timeout": {
"type": "uint64"
},
- "plugin_requst_timeout": {
+ "plugin-requst-timeout": {
"type": "uint64"
},
"image-layer-check": {
--
2.33.0

View File

@ -0,0 +1,134 @@
From 85cca2ea57f44639fdd55e3f3eeada93e7548adc Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Wed, 18 Sep 2024 11:55:24 +0800
Subject: [PATCH 21/25] sandbox:sandbox api update
Signed-off-by: liuxu <liuxu156@huawei.com>
---
src/json/schema/sandbox/mount.json | 19 ++++++++++++++++
src/json/schema/sandbox/process.json | 22 ++++++++++++++++++
src/json/schema/sandbox/task.json | 34 ++++++++++++++++++++++++++++
src/json/schema/sandbox/tasks.json | 12 ++++++++++
4 files changed, 87 insertions(+)
create mode 100644 src/json/schema/sandbox/mount.json
create mode 100644 src/json/schema/sandbox/process.json
create mode 100644 src/json/schema/sandbox/task.json
create mode 100644 src/json/schema/sandbox/tasks.json
diff --git a/src/json/schema/sandbox/mount.json b/src/json/schema/sandbox/mount.json
new file mode 100644
index 0000000..f8fcb73
--- /dev/null
+++ b/src/json/schema/sandbox/mount.json
@@ -0,0 +1,19 @@
+{
+ "_comment": "github.com/containerd/containerd/api/types/mount.proto",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string"
+ },
+ "source": {
+ "type": "string"
+ },
+ "target": {
+ "type": "string"
+ },
+ "options": {
+ "$ref": "../defs.json#/definitions/ArrayOfStrings"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/json/schema/sandbox/process.json b/src/json/schema/sandbox/process.json
new file mode 100644
index 0000000..c440236
--- /dev/null
+++ b/src/json/schema/sandbox/process.json
@@ -0,0 +1,22 @@
+{
+ "_comment": "sandbox api depend: update",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "exec_id": {
+ "type": "string"
+ },
+ "spec": {
+ "$ref": "../defs.json#/definitions/process"
+ },
+ "stdin": {
+ "type": "string"
+ },
+ "stdout": {
+ "type": "string"
+ },
+ "stderr": {
+ "type": "string"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/json/schema/sandbox/task.json b/src/json/schema/sandbox/task.json
new file mode 100644
index 0000000..ace8fad
--- /dev/null
+++ b/src/json/schema/sandbox/task.json
@@ -0,0 +1,34 @@
+{
+ "_comment": "sandbox api depend: update",
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "task_id": {
+ "type": "string"
+ },
+ "spec": {
+ "$ref": "../oci/runtime/spec.json"
+ },
+ "rootfs": {
+ "type": "array",
+ "items": {
+ "$ref": "mount.json"
+ }
+ },
+ "stdin": {
+ "type": "string"
+ },
+ "stdout": {
+ "type": "string"
+ },
+ "stderr": {
+ "type": "string"
+ },
+ "processes": {
+ "type": "array",
+ "items": {
+ "$ref": "process.json"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/json/schema/sandbox/tasks.json b/src/json/schema/sandbox/tasks.json
new file mode 100644
index 0000000..9924122
--- /dev/null
+++ b/src/json/schema/sandbox/tasks.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "tasks": {
+ "type": "array",
+ "items": {
+ "$ref": "task.json"
+ }
+ }
+ }
+}
--
2.34.1

View File

@ -0,0 +1,475 @@
From 20e71717d730f65b2f922477e4aaf7fef9f6dcb4 Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Tue, 5 Nov 2024 23:10:59 +0800
Subject: [PATCH 22/25] json schema for sandbox api
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
src/json/schema/defs.json | 16 +++++++
src/json/schema/sandbox/create-request.json | 33 ++++++++++++++
src/json/schema/sandbox/create-response.json | 9 ++++
src/json/schema/sandbox/metrics-request.json | 12 +++++
src/json/schema/sandbox/metrics-response.json | 18 ++++++++
src/json/schema/sandbox/platform-request.json | 12 +++++
.../schema/sandbox/platform-response.json | 15 +++++++
src/json/schema/sandbox/sandbox.json | 44 +++++++++++++++++++
src/json/schema/sandbox/shutdown-request.json | 12 +++++
src/json/schema/sandbox/start-request.json | 12 +++++
src/json/schema/sandbox/start-response.json | 24 ++++++++++
src/json/schema/sandbox/status-request.json | 15 +++++++
src/json/schema/sandbox/status-response.json | 36 +++++++++++++++
src/json/schema/sandbox/stop-request.json | 15 +++++++
src/json/schema/sandbox/update-request.json | 21 +++++++++
src/json/schema/sandbox/wait-request.json | 12 +++++
src/json/schema/sandbox/wait-response.json | 15 +++++++
17 files changed, 321 insertions(+)
create mode 100644 src/json/schema/sandbox/create-request.json
create mode 100644 src/json/schema/sandbox/create-response.json
create mode 100644 src/json/schema/sandbox/metrics-request.json
create mode 100644 src/json/schema/sandbox/metrics-response.json
create mode 100644 src/json/schema/sandbox/platform-request.json
create mode 100644 src/json/schema/sandbox/platform-response.json
create mode 100644 src/json/schema/sandbox/sandbox.json
create mode 100644 src/json/schema/sandbox/shutdown-request.json
create mode 100644 src/json/schema/sandbox/start-request.json
create mode 100644 src/json/schema/sandbox/start-response.json
create mode 100644 src/json/schema/sandbox/status-request.json
create mode 100644 src/json/schema/sandbox/status-response.json
create mode 100644 src/json/schema/sandbox/stop-request.json
create mode 100644 src/json/schema/sandbox/update-request.json
create mode 100644 src/json/schema/sandbox/wait-request.json
create mode 100644 src/json/schema/sandbox/wait-response.json
diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json
index 22683c2..854a816 100644
--- a/src/json/schema/defs.json
+++ b/src/json/schema/defs.json
@@ -406,6 +406,22 @@
}
}
},
+ "mapStringObjectByteArray": {
+ "type": "object",
+ "patternProperties": {
+ ".{1,}": {
+ "type": "object",
+ "properties": {
+ "Element": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ }
+ }
+ }
+ }
+ },
"digest": {
"type": "string",
"pattern": "^[a-z0-9]+(?:[+._-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$"
diff --git a/src/json/schema/sandbox/create-request.json b/src/json/schema/sandbox/create-request.json
new file mode 100644
index 0000000..2e5a06d
--- /dev/null
+++ b/src/json/schema/sandbox/create-request.json
@@ -0,0 +1,33 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "rootfs": {
+ "type": "array",
+ "items": {
+ "$ref": "mount.json"
+ }
+ },
+ "options": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ },
+ "netns_path": {
+ "type": "string"
+ },
+ "annotations": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "sandbox":{
+ "$ref": "sandbox.json"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/create-response.json b/src/json/schema/sandbox/create-response.json
new file mode 100644
index 0000000..54d0eae
--- /dev/null
+++ b/src/json/schema/sandbox/create-response.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/metrics-request.json b/src/json/schema/sandbox/metrics-request.json
new file mode 100644
index 0000000..c54006b
--- /dev/null
+++ b/src/json/schema/sandbox/metrics-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/metrics-response.json b/src/json/schema/sandbox/metrics-response.json
new file mode 100644
index 0000000..b0a255d
--- /dev/null
+++ b/src/json/schema/sandbox/metrics-response.json
@@ -0,0 +1,18 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "timestamp": {
+ "type": "uint64"
+ },
+ "id": {
+ "type": "string"
+ },
+ "data": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/platform-request.json b/src/json/schema/sandbox/platform-request.json
new file mode 100644
index 0000000..c54006b
--- /dev/null
+++ b/src/json/schema/sandbox/platform-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/platform-response.json b/src/json/schema/sandbox/platform-response.json
new file mode 100644
index 0000000..c469d8d
--- /dev/null
+++ b/src/json/schema/sandbox/platform-response.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "os": {
+ "type": "string"
+ },
+ "architecture": {
+ "type": "string"
+ },
+ "variant": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/sandbox.json b/src/json/schema/sandbox/sandbox.json
new file mode 100644
index 0000000..786ac1f
--- /dev/null
+++ b/src/json/schema/sandbox/sandbox.json
@@ -0,0 +1,44 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "runtime": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "options": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ }
+ }
+ },
+ "spec": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ },
+ "labels": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "created_at": {
+ "type": "uint64"
+ },
+ "updated_at": {
+ "type": "uint64"
+ },
+ "extensions": {
+ "$ref": "../defs.json#/definitions/mapStringObjectByteArray"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/shutdown-request.json b/src/json/schema/sandbox/shutdown-request.json
new file mode 100644
index 0000000..c54006b
--- /dev/null
+++ b/src/json/schema/sandbox/shutdown-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/start-request.json b/src/json/schema/sandbox/start-request.json
new file mode 100644
index 0000000..c54006b
--- /dev/null
+++ b/src/json/schema/sandbox/start-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/start-response.json b/src/json/schema/sandbox/start-response.json
new file mode 100644
index 0000000..19d94de
--- /dev/null
+++ b/src/json/schema/sandbox/start-response.json
@@ -0,0 +1,24 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "pid": {
+ "type": "uint32"
+ },
+ "created_at": {
+ "type": "uint64"
+ },
+ "labels": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "address": {
+ "type": "string"
+ },
+ "version": {
+ "type": "uint32"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/json/schema/sandbox/status-request.json b/src/json/schema/sandbox/status-request.json
new file mode 100644
index 0000000..023abe8
--- /dev/null
+++ b/src/json/schema/sandbox/status-request.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "verbose": {
+ "type": "boolean"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/status-response.json b/src/json/schema/sandbox/status-response.json
new file mode 100644
index 0000000..779a35d
--- /dev/null
+++ b/src/json/schema/sandbox/status-response.json
@@ -0,0 +1,36 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "pid": {
+ "type": "uint32"
+ },
+ "state": {
+ "type": "string"
+ },
+ "info": {
+ "$ref": "../defs.json#/definitions/mapStringString"
+ },
+ "created_at": {
+ "type": "uint64"
+ },
+ "exited_at": {
+ "type": "uint64"
+ },
+ "extra": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ },
+ "address": {
+ "type": "string"
+ },
+ "version": {
+ "type": "uint32"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/stop-request.json b/src/json/schema/sandbox/stop-request.json
new file mode 100644
index 0000000..ee7c8ac
--- /dev/null
+++ b/src/json/schema/sandbox/stop-request.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "timeout_secs": {
+ "type": "uint32"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/update-request.json b/src/json/schema/sandbox/update-request.json
new file mode 100644
index 0000000..60c44a2
--- /dev/null
+++ b/src/json/schema/sandbox/update-request.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "sandboxer": {
+ "type": "string"
+ },
+ "sandbox": {
+ "$ref": "sandbox.json"
+ },
+ "fields": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+}
diff --git a/src/json/schema/sandbox/wait-request.json b/src/json/schema/sandbox/wait-request.json
new file mode 100644
index 0000000..3b77d39
--- /dev/null
+++ b/src/json/schema/sandbox/wait-request.json
@@ -0,0 +1,12 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "sandboxer": {
+ "type": "string"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/json/schema/sandbox/wait-response.json b/src/json/schema/sandbox/wait-response.json
new file mode 100644
index 0000000..49a42f1
--- /dev/null
+++ b/src/json/schema/sandbox/wait-response.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "type": "object",
+ "properties": {
+ "sandbox_id": {
+ "type": "string"
+ },
+ "exit_status": {
+ "type": "uint32"
+ },
+ "exited_at": {
+ "type": "uint64"
+ }
+ }
+}
--
2.34.1

View File

@ -0,0 +1,41 @@
From 80037cd8257e5b5702c729953a6c9ef56b4354f4 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 6 Nov 2024 15:35:02 +0800
Subject: [PATCH 23/25] add no pivot root config
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/host-config.json | 3 +++
src/json/schema/shim/client/process-state.json | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/json/schema/host-config.json b/src/json/schema/host-config.json
index a9679bd..f9e2d4c 100644
--- a/src/json/schema/host-config.json
+++ b/src/json/schema/host-config.json
@@ -306,6 +306,9 @@
"type": "string"
}
},
+ "NoPivotRoot": {
+ "type": "boolean"
+ },
"CdiRequestedDevices": {
"type": "array",
"items": {
diff --git a/src/json/schema/shim/client/process-state.json b/src/json/schema/shim/client/process-state.json
index bfa8416..f35ee6a 100644
--- a/src/json/schema/shim/client/process-state.json
+++ b/src/json/schema/shim/client/process-state.json
@@ -188,7 +188,7 @@
}
},
"noPivotRoot": {
- "tyoe": "boolean"
+ "type": "boolean"
},
"checkpoint": {
"type": "string"
--
2.34.1

View File

@ -0,0 +1,165 @@
From d47d27c70b7bdb4f2d63d260daa05b20c85c4117 Mon Sep 17 00:00:00 2001
From: xuxuepeng <xuxuepeng1@huawei.com>
Date: Thu, 7 Nov 2024 14:46:01 +0800
Subject: [PATCH 24/25] Use any type instead of bytearray
Signed-off-by: xuxuepeng <xuxuepeng1@huawei.com>
---
src/json/schema/defs.json | 35 +++++++++----------
src/json/schema/sandbox/create-request.json | 5 +--
src/json/schema/sandbox/metrics-response.json | 5 +--
src/json/schema/sandbox/sandbox.json | 12 ++-----
src/json/schema/sandbox/status-response.json | 5 +--
5 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json
index 854a816..b313103 100644
--- a/src/json/schema/defs.json
+++ b/src/json/schema/defs.json
@@ -226,6 +226,20 @@
"type": "string"
}
},
+ "any": {
+ "type": "object",
+ "properties": {
+ "type_url": {
+ "type": "string"
+ },
+ "value": {
+ "type": "array",
+ "items": {
+ "type": "byte"
+ }
+ }
+ }
+ },
"mapStringString": {
"type": "object",
"patternProperties": {
@@ -406,17 +420,14 @@
}
}
},
- "mapStringObjectByteArray": {
+ "mapStringObjectAny": {
"type": "object",
"patternProperties": {
".{1,}": {
"type": "object",
"properties": {
"Element": {
- "type": "array",
- "items": {
- "type": "byte"
- }
+ "$ref": "#/definitions/any"
}
}
}
@@ -498,20 +509,6 @@
}
}
},
- "any": {
- "type": "object",
- "properties": {
- "type_url": {
- "type": "string"
- },
- "value": {
- "type": "array",
- "items": {
- "type": "byte"
- }
- }
- }
- },
"zone": {
"type": "object",
"properties": {
diff --git a/src/json/schema/sandbox/create-request.json b/src/json/schema/sandbox/create-request.json
index 2e5a06d..27accf6 100644
--- a/src/json/schema/sandbox/create-request.json
+++ b/src/json/schema/sandbox/create-request.json
@@ -12,10 +12,7 @@
}
},
"options": {
- "type": "array",
- "items": {
- "type": "byte"
- }
+ "$ref": "../defs.json#/definitions/any"
},
"netns_path": {
"type": "string"
diff --git a/src/json/schema/sandbox/metrics-response.json b/src/json/schema/sandbox/metrics-response.json
index b0a255d..53afd1f 100644
--- a/src/json/schema/sandbox/metrics-response.json
+++ b/src/json/schema/sandbox/metrics-response.json
@@ -9,10 +9,7 @@
"type": "string"
},
"data": {
- "type": "array",
- "items": {
- "type": "byte"
- }
+ "$ref": "../defs.json#/definitions/any"
}
}
}
diff --git a/src/json/schema/sandbox/sandbox.json b/src/json/schema/sandbox/sandbox.json
index 786ac1f..9725a30 100644
--- a/src/json/schema/sandbox/sandbox.json
+++ b/src/json/schema/sandbox/sandbox.json
@@ -12,18 +12,12 @@
"type": "string"
},
"options": {
- "type": "array",
- "items": {
- "type": "byte"
- }
+ "$ref": "../defs.json#/definitions/any"
}
}
},
"spec": {
- "type": "array",
- "items": {
- "type": "byte"
- }
+ "$ref": "../defs.json#/definitions/any"
},
"labels": {
"$ref": "../defs.json#/definitions/mapStringString"
@@ -35,7 +29,7 @@
"type": "uint64"
},
"extensions": {
- "$ref": "../defs.json#/definitions/mapStringObjectByteArray"
+ "$ref": "../defs.json#/definitions/mapStringObjectAny"
},
"sandboxer": {
"type": "string"
diff --git a/src/json/schema/sandbox/status-response.json b/src/json/schema/sandbox/status-response.json
index 779a35d..efac831 100644
--- a/src/json/schema/sandbox/status-response.json
+++ b/src/json/schema/sandbox/status-response.json
@@ -21,10 +21,7 @@
"type": "uint64"
},
"extra": {
- "type": "array",
- "items": {
- "type": "byte"
- }
+ "$ref": "../defs.json#/definitions/any"
},
"address": {
"type": "string"
--
2.34.1

View File

@ -0,0 +1,26 @@
From 8b481b47c915a495397f4a6f1cb04bf2518280b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=AD=A6=E7=A7=AF=E8=B6=85?= <wujichao1@huawei.com>
Date: Thu, 7 Nov 2024 20:15:03 +0800
Subject: [PATCH 25/25] fix issues: Isula ps cannot display port mapping
---
src/json/schema/container/container.json | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/json/schema/container/container.json b/src/json/schema/container/container.json
index 7d59826..05b27e9 100644
--- a/src/json/schema/container/container.json
+++ b/src/json/schema/container/container.json
@@ -23,6 +23,9 @@
"command": {
"type": "string"
},
+ "ports": {
+ "type": "string"
+ },
"ram": {
"type": "double"
},
--
2.34.1

View File

@ -0,0 +1,42 @@
From caae9c01e8ee2d30c343ef1f79a6a0b7835e3d60 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Sat, 8 Feb 2025 16:40:26 +0800
Subject: [PATCH] sandboxer:add image type
Signed-off-by: liuxu <liuxu156@huawei.com>
---
src/json/schema/container/sandbox-info.json | 3 +++
src/json/schema/defs.json | 3 +++
2 files changed, 6 insertions(+)
diff --git a/src/json/schema/container/sandbox-info.json b/src/json/schema/container/sandbox-info.json
index 1d5954a..ccff6a4 100644
--- a/src/json/schema/container/sandbox-info.json
+++ b/src/json/schema/container/sandbox-info.json
@@ -5,6 +5,9 @@
"sandboxer": {
"type": "string"
},
+ "ImageType": {
+ "type": "string"
+ },
"id": {
"type": "string"
},
diff --git a/src/json/schema/defs.json b/src/json/schema/defs.json
index b313103..329d34a 100644
--- a/src/json/schema/defs.json
+++ b/src/json/schema/defs.json
@@ -315,6 +315,9 @@
},
"address": {
"type": "string"
+ },
+ "image-type": {
+ "type": "string"
}
}
}
--
2.34.1

View File

@ -0,0 +1,44 @@
From b97efe68935c239fe539aa933ee4389ed73c8ec3 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Sat, 22 Feb 2025 10:48:24 +1400
Subject: [PATCH] move sandbox network_ready from metadata to state for save
optimization
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/json/schema/sandbox/metadata.json | 3 ---
src/json/schema/sandbox/state.json | 3 +++
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/json/schema/sandbox/metadata.json b/src/json/schema/sandbox/metadata.json
index b3b6886..df9f6ab 100644
--- a/src/json/schema/sandbox/metadata.json
+++ b/src/json/schema/sandbox/metadata.json
@@ -31,9 +31,6 @@
"netNsPath": {
"type": "string"
},
- "networkReady": {
- "type": "boolean"
- },
"sandboxConfigJson": {
"type": "string"
}
diff --git a/src/json/schema/sandbox/state.json b/src/json/schema/sandbox/state.json
index ceb62b2..2eea0bc 100644
--- a/src/json/schema/sandbox/state.json
+++ b/src/json/schema/sandbox/state.json
@@ -19,6 +19,9 @@
},
"Status": {
"type": "integer"
+ },
+ "networkReady": {
+ "type": "boolean"
}
}
}
\ No newline at end of file
--
2.43.0

View File

@ -1,5 +1,5 @@
%global _version 2.1.4
%global _release 7
%global _release 14
%global _inner_name isula_libutils
%global enable_lxc 1
@ -23,6 +23,23 @@ Patch0007: 0007-restore-bufsize-to-prevent-log-loss.patch
Patch0008: 0008-support-clang-build.patch
Patch0009: 0009-support-cdi-spec.patch
Patch0010: 0010-remove-file-mode-check-in-ut.patch
Patch0011: 0011-remove-lcr-created-spec-only-if-create-failed.patch
Patch0012: 0012-Fix-info-inproper-data-type-for-timestamp.patch
Patch0013: 0013-fix-bug-for-potential-config-seccomp-ocihook-write-e.patch
Patch0014: 0014-add-codecheck-fix.patch
Patch0015: 0015-fix-invalid-args-len-set-in-execute_lxc_attach.patch
Patch0016: 0016-add-nri-definitions.patch
Patch0017: 0017-add-struct-for-nri.patch
Patch0018: 0018-add-nri-def-in-host-config.patch
Patch0019: 0019-fix-invalid-usage-of-arrtibute-visibility.patch
Patch0020: 0020-unify-nri-variable-format.patch
Patch0021: 0021-sandbox-sandbox-api-update.patch
Patch0022: 0022-json-schema-for-sandbox-api.patch
Patch0023: 0023-add-no-pivot-root-config.patch
Patch0024: 0024-Use-any-type-instead-of-bytearray.patch
Patch0025: 0025-fix-issues-Isula-ps-cannot-display-port-mapping.patch
Patch0026: 0026-sandboxer-add-image-type.patch
Patch0027: 0027-move-sandbox-network_ready-from-metadata-to-state-fo.patch
%define lxcver_lower 4.0.3-2022102400
%define lxcver_upper 5.0.3
@ -76,6 +93,7 @@ mkdir -p build
cd build
%if "%toolchain" == "clang"
%global cmake_opts -DCMAKE_C_FLAGS="${CFLAGS}"
CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument"
%endif
%if 0%{?enable_lxc}
@ -143,6 +161,48 @@ rm -rf %{buildroot}
%{_includedir}/lcr/utils_compile.h
%changelog
* Mon May 12 2025 dongyuzhen <dongyuzhen@h-partners.com> - 2.1.4-14
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:sync from upstream
* Mon Nov 25 2024 liuxu<liuxu156@huawei.com> - 2.1.4-13
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:sync from upstream
* Thu Oct 17 2024 wujichao<wujichao1@huawei.com> - 2.1.4-12
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:unify nri variable format
* Tue Sep 3 2024 yuanchao<1050706328@qq.com> - 2.1.4-11
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:fix invalid usage of arrtibute visibility
* Mon Aug 19 2024 zhongtao<zhongtao17@huawei.com> - 2.1.4-10
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:add nri def in host config
* Fri Aug 16 2024 zhongtao<zhongtao17@huawei.com> - 2.1.4-9
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:add nri struct definitions
* Tue Jun 11 2024 jikai<jikai11@huawei.com> - 2.1.4-8
- Type:enhancement
- CVE:NA
- SUG:NA
- DESC:sync from upstream
* Fri Apr 12 2024 luofeng<luofeng13@huawei.com> - 2.1.4-7
- Type:enhancement
- CVE:NA