1 Star 0 Fork 44

严莹/iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0049-distinguish-between-runtime-and-runtime_cmd-in-isula.patch 5.61 KB
一键复制 编辑 原始数据 按行查看 历史
liuxu 提交于 2024-04-20 10:00 . upgrade from upstream
From 491baece02522128720b3bd992a76dc5148aa7b2 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Mon, 8 Apr 2024 11:37:13 +0800
Subject: [PATCH 49/69] distinguish between runtime and runtime_cmd in
isulad-shim
Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
src/cmd/isulad-shim/process.c | 20 +++++++++----------
src/cmd/isulad-shim/process.h | 4 ++--
.../modules/runtime/isula/isula_rt_ops.c | 2 ++
3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/cmd/isulad-shim/process.c b/src/cmd/isulad-shim/process.c
index 8a4ca175..6b5f8f7f 100644
--- a/src/cmd/isulad-shim/process.c
+++ b/src/cmd/isulad-shim/process.c
@@ -1131,7 +1131,7 @@ static int init_root_path(process_t *p)
return SHIM_ERR;
}
- if (buffer->nappend(buffer, PATH_MAX, "%s/%s", state_path, p->runtime) < 0) {
+ if (buffer->nappend(buffer, PATH_MAX, "%s/%s", state_path, p->state->runtime) < 0) {
ERROR("Failed to append state_path\n");
isula_buffer_free(buffer);
return SHIM_ERR;
@@ -1146,7 +1146,7 @@ static int init_root_path(process_t *p)
return SHIM_OK;
}
-process_t *new_process(char *id, char *bundle, char *runtime)
+process_t *new_process(char *id, char *bundle, char *runtime_cmd)
{
shim_client_process_state *p_state;
process_t *p = NULL;
@@ -1174,7 +1174,7 @@ process_t *new_process(char *id, char *bundle, char *runtime)
p->id = id;
p->bundle = bundle;
- p->runtime = runtime;
+ p->runtime_cmd = runtime_cmd;
p->state = p_state;
p->console_sock_path = NULL;
p->exit_fd = -1;
@@ -1247,7 +1247,7 @@ static void set_common_params(process_t *p, const char *params[], int *index, co
{
int j;
- params[(*index)++] = p->runtime;
+ params[(*index)++] = p->runtime_cmd;
for (j = 0; j < p->state->runtime_args_len; j++) {
params[(*index)++] = p->state->runtime_args[j];
}
@@ -1261,7 +1261,7 @@ static void set_common_params(process_t *p, const char *params[], int *index, co
// In addition to kata, other commonly used oci runtimes (runc, crun, youki, gvisor)
// need to set the --root option
- if (strcasecmp(p->runtime, "kata-runtime") != 0) {
+ if (strcasecmp(p->state->runtime, "kata-runtime") != 0) {
params[(*index)++] = "--root";
params[(*index)++] = p->root_path;
}
@@ -1347,7 +1347,7 @@ static void process_kill_all(process_t *p)
params[i++] = p->id;
params[i++] = "SIGKILL";
- (void)cmd_combined_output(p->runtime, params, output, &output_len);
+ (void)cmd_combined_output(p->runtime_cmd, params, output, &output_len);
return;
}
@@ -1375,7 +1375,7 @@ static void process_delete(process_t *p)
params[i++] = "--force";
params[i++] = p->id;
- (void)cmd_combined_output(p->runtime, params, output, &output_len);
+ (void)cmd_combined_output(p->runtime_cmd, params, output, &output_len);
return;
}
@@ -1444,8 +1444,8 @@ static void exec_runtime_process(process_t *p, int exec_fd)
const char *params[MAX_RUNTIME_ARGS] = { 0 };
get_runtime_cmd(p, log_path, pid_path, process_desc, params);
- execvp(p->runtime, (char * const *)params);
- (void)dprintf(exec_fd, "run process: %s error: %s", p->runtime, strerror(errno));
+ execvp(p->runtime_cmd, (char * const *)params);
+ (void)dprintf(exec_fd, "run process: %s error: %s", p->runtime_cmd, strerror(errno));
_exit(EXIT_FAILURE);
}
@@ -1586,7 +1586,7 @@ static int waitpid_with_timeout(int ctr_pid, int *status, const uint64_t timeou
static int wait_container_process_with_timeout(process_t *p, const uint64_t timeout, int *status)
{
// currently, kata runtime does not support setting timeout during exec
- if (strcasecmp(p->runtime, "kata-runtime") != 0 && timeout > 0) {
+ if (strcasecmp(p->state->runtime, "kata-runtime") != 0 && timeout > 0) {
return waitpid_with_timeout(p->ctr_pid, status, timeout);
}
diff --git a/src/cmd/isulad-shim/process.h b/src/cmd/isulad-shim/process.h
index 32ba7366..05fd87b0 100644
--- a/src/cmd/isulad-shim/process.h
+++ b/src/cmd/isulad-shim/process.h
@@ -44,7 +44,7 @@ typedef struct {
typedef struct process {
char *id;
char *bundle;
- char *runtime;
+ char *runtime_cmd;
char *console_sock_path; // pty socket path
char *workdir;
char *root_path;
@@ -70,7 +70,7 @@ typedef struct {
int status;
} process_exit_t;
-process_t* new_process(char *id, char *bundle, char *runtime);
+process_t* new_process(char *id, char *bundle, char *runtime_cmd);
int prepare_attach_socket(process_t *p);
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index b9aba3e3..bc3c36c8 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -1154,6 +1154,7 @@ int rt_isula_create(const char *id, const char *runtime, const rt_create_params_
p.isulad_stdin = (char *)params->stdin;
p.isulad_stdout = (char *)params->stdout;
p.isulad_stderr = (char *)params->stderr;
+ p.runtime = (char *)runtime;
p.runtime_args = (char **)runtime_args;
p.runtime_args_len = runtime_args_len;
p.attach_socket = attach_socket;
@@ -1409,6 +1410,7 @@ static int preparation_exec(const char *id, const char *runtime, const char *wor
p.isulad_stdout = (char *)params->console_fifos[1];
p.isulad_stderr = (char *)params->console_fifos[2];
p.resize_fifo = resize_fifo_dir;
+ p.runtime = (char *)runtime;
p.runtime_args = (char **)runtime_args;
p.runtime_args_len = runtime_args_len;
copy_process(&p, process);
--
2.34.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yanyir/iSulad.git
git@gitee.com:yanyir/iSulad.git
yanyir
iSulad
iSulad
master

搜索帮助