1 Star 0 Fork 46

wangfengtu/src-iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0003-isulad-rt_isula_start-should-read-the-isulad-shim-pi.patch 2.89 KB
一键复制 编辑 原始数据 按行查看 历史
gaohuatao 提交于 2020-11-12 19:32 . update from openeuler
From 3942bcc4c3a755d33e709046edd358f9af264d11 Mon Sep 17 00:00:00 2001
From: holyfei <[email protected]>
Date: Wed, 21 Oct 2020 10:00:15 +0800
Subject: [PATCH 03/28] isulad: rt_isula_start should read the isulad-shim
pidinfo
reason: the ppid of init pid should be isulad-shim, read isulad-shim pidinfo and set the start time for init pidinfo
Signed-off-by: yangfeiyu <[email protected]>
---
.../modules/runtime/isula/isula_rt_ops.c | 38 ++++++++++++++++++-
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 6e4512f..82d7aec 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -851,8 +851,13 @@ out:
int rt_isula_start(const char *id, const char *runtime, const rt_start_params_t *params, pid_ppid_info_t *pid_info)
{
char workdir[PATH_MAX] = { 0 };
+ char shim_pid_file_name[PATH_MAX] = { 0 };
pid_t pid = 0;
+ pid_t shim_pid = -1;
int ret = 0;
+ int splice_ret = 0;
+ proc_t *proc = NULL;
+ proc_t *p_proc = NULL;
if (id == NULL || runtime == NULL || params == NULL || pid_info == NULL) {
ERROR("nullptr arguments not allowed");
@@ -863,6 +868,12 @@ int rt_isula_start(const char *id, const char *runtime, const rt_start_params_t
return -1;
}
+ splice_ret = snprintf(shim_pid_file_name, sizeof(shim_pid_file_name), "%s/shim-pid", workdir);
+ if (splice_ret < 0 || splice_ret >= sizeof(shim_pid_file_name)) {
+ ERROR("%s: wrong shim workdir", id);
+ return -1;
+ }
+
pid = get_container_process_pid(workdir);
if (pid < 0) {
ret = -1;
@@ -870,12 +881,32 @@ int rt_isula_start(const char *id, const char *runtime, const rt_start_params_t
goto out;
}
- if (util_read_pid_ppid_info(pid, pid_info) != 0) {
+ file_read_int(shim_pid_file_name, &shim_pid);
+ if (shim_pid < 0) {
+ ret = -1;
+ ERROR("%s: failed to read isulad shim pid", id);
+ goto out;
+ }
+
+ proc = util_get_process_proc_info(pid);
+ if (proc == NULL) {
ret = -1;
- ERROR("%s: failed read pid info", id);
+ ERROR("%s: failed to read pidinfo", id);
goto out;
}
+ p_proc = util_get_process_proc_info(shim_pid);
+ if (p_proc == NULL) {
+ ret = -1;
+ ERROR("%s: failed to read isulad shim pidinfo", id);
+ goto out;
+ }
+
+ pid_info->pid = proc->pid;
+ pid_info->start_time = proc->start_time;
+ pid_info->ppid = shim_pid;
+ pid_info->pstart_time = p_proc->start_time;
+
if (runtime_call_simple(workdir, runtime, "start", NULL, 0, id) != 0) {
ERROR("call runtime start id failed");
ret = -1;
@@ -888,6 +919,9 @@ out:
shim_kill_force(workdir);
}
+ free(proc);
+ free(p_proc);
+
return ret;
}
--
2.20.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangfengtu/src-iSulad.git
[email protected]:wangfengtu/src-iSulad.git
wangfengtu
src-iSulad
src-iSulad
master

搜索帮助