From 409f5bf06e782fe5cbcf01e463b114c973b33dcb Mon Sep 17 00:00:00 2001 From: gaohuatao Date: Thu, 21 Oct 2021 12:11:00 +0800 Subject: [PATCH 2/2] disable lxc_keep with oci image Signed-off-by: gaohuatao --- src/lcrcontainer.h | 1 + src/lcrcontainer_execute.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h index ecf3655..062d681 100644 --- a/src/lcrcontainer.h +++ b/src/lcrcontainer.h @@ -201,6 +201,7 @@ struct lcr_start_request { uint32_t start_timeout; const char *container_pidfile; const char *exit_fifo; + bool image_type_oci; }; bool lcr_start(const struct lcr_start_request *request); diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c index 4c8e0e6..d04a467 100644 --- a/src/lcrcontainer_execute.c +++ b/src/lcrcontainer_execute.c @@ -966,7 +966,9 @@ void execute_lxc_start(const char *name, const char *path, const struct lcr_star { // should check the size of params when add new params. char *params[PARAM_NUM] = {NULL}; + char buf[PARAM_NUM] = { 0 }; size_t i = 0; + int nret = 0; if (lcr_util_check_inherited(true, -1) != 0) { COMMAND_ERROR("Close inherited fds failed"); @@ -983,6 +985,17 @@ void execute_lxc_start(const char *name, const char *path, const struct lcr_star add_array_kv(params, PARAM_NUM, &i, "--in-fifo", request->console_fifos[0]); add_array_kv(params, PARAM_NUM, &i, "--out-fifo", request->console_fifos[1]); add_array_kv(params, PARAM_NUM, &i, "--err-fifo", request->console_fifos[2]); + + nret = snprintf(buf, sizeof(buf), "%s=true", LXC_IMAGE_OCI_KEY); + if (nret < 0 || (size_t)nret >= sizeof(buf)) { + COMMAND_ERROR("Format KEY=VAL of image type error"); + exit(EXIT_FAILURE); + } + + if (request->image_type_oci) { + add_array_kv(params, PARAM_NUM, &i, "-s", buf); + } + if (!request->tty) { add_array_elem(params, PARAM_NUM, &i, "--disable-pty"); } -- 2.20.1