summaryrefslogtreecommitdiff
path: root/0049-distinguish-between-runtime-and-runtime_cmd-in-isula.patch
blob: 4366d7acd7ae924d04b654ee48f0e361cd8282ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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