split hyper_exec_cmd()

Signed-off-by: Lai Jiangshan <jiangshanlai@gmail.com>
This commit is contained in:
Lai Jiangshan
2016-07-06 11:39:27 +08:00
parent e255de660d
commit 00308d00b5
2 changed files with 18 additions and 9 deletions
+17 -9
View File
@@ -631,28 +631,38 @@ static void hyper_free_exec(struct hyper_exec *exec)
int hyper_exec_cmd(char *json, int length)
{
struct hyper_exec *exec;
struct hyper_pod *pod = &global_pod;
int pipe[2] = {-1, -1};
int pid, ret = -1;
uint32_t type;
fprintf(stdout, "call hyper_exec_cmd, json %s, len %d\n", json, length);
exec = hyper_parse_execcmd(json, length);
if (exec == NULL) {
fprintf(stderr, "parse exec cmd failed\n");
goto out;
return -1;
}
int ret = hyper_run_process(exec);
if (ret < 0) {
hyper_free_exec(exec);
}
return ret;
}
int hyper_run_process(struct hyper_exec *exec)
{
struct hyper_pod *pod = &global_pod;
int pipe[2] = {-1, -1};
int pid, ret = -1;
uint32_t type;
if (exec->argv == NULL) {
fprintf(stderr, "cmd is %p, seq %" PRIu64 ", container %s\n",
exec->argv, exec->seq, exec->id);
goto free_exec;
goto out;
}
if (hyper_setup_exec_tty(exec) < 0) {
fprintf(stderr, "setup exec tty failed\n");
goto free_exec;
goto out;
}
if (hyper_watch_exec_pty(exec, pod) < 0) {
@@ -699,8 +709,6 @@ close_tty:
close(exec->stdinfd);
close(exec->stdoutfd);
close(exec->stderrfd);
free_exec:
hyper_free_exec(exec);
goto out;
}
+1
View File
@@ -49,6 +49,7 @@ int hyper_release_exec(struct hyper_exec *, struct hyper_pod *);
int hyper_container_execcmd(struct hyper_pod *pod);
int hyper_setup_exec_tty(struct hyper_exec *e);
int hyper_dup_exec_tty(struct hyper_exec *e);
int hyper_run_process(struct hyper_exec *e);
void hyper_exec_process(struct hyper_exec *e);
struct hyper_exec *hyper_find_exec_by_pid(struct list_head *head, int pid);
struct hyper_exec *hyper_find_exec_by_seq(struct hyper_pod *pod, uint64_t seq);