diff --git a/src/cmd/isulad/main.c b/src/cmd/isulad/main.c index 7d63951547ce8b145fb35e6dd9ee42b807334559..9cbe3f305256c5a3c948c4a231a71edb7f44e344 100644 --- a/src/cmd/isulad/main.c +++ b/src/cmd/isulad/main.c @@ -42,7 +42,6 @@ #include "collector.h" #include "isulad_commands.h" #include "isula_libutils/log.h" -#include "engine.h" #include "utils.h" #include "isulad_config.h" #include "image.h" @@ -59,6 +58,7 @@ #include "plugin.h" #include "selinux_label.h" #include "http.h" +#include "engine.h" #ifdef GRPC_CONNECTOR #include "clibcni/api.h" diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index d24b23f9ba19d2ce2921070682f3fa224bad35cf..65c1b1ae3cd3c6b637a57ed4a13d8e118d6ea61a 100644 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -1,7 +1,6 @@ # get current directory sources files aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} daemon_top_srcs) -add_subdirectory(engines) add_subdirectory(runtime) add_subdirectory(image) add_subdirectory(plugin) @@ -11,10 +10,10 @@ add_subdirectory(container) add_subdirectory(connect) add_subdirectory(log) add_subdirectory(events) +add_subdirectory(engines) set(local_daemon_srcs ${daemon_top_srcs} - ${ENGINES_SRCS} ${RUNTIME_SRCS} ${IMAGE_SRCS} ${PLUGIN_SRCS} @@ -24,11 +23,11 @@ set(local_daemon_srcs ${SERVER_CONNECT_SRCS} ${LOG_GATHER_SRCS} ${EVENTS_SRCS} + ${ENGINES_SRCS} ) set(local_daemon_incs ${CMAKE_CURRENT_SOURCE_DIR} - ${ENGINES_INCS} ${RUNTIME_INCS} ${IMAGE_INCS} ${PLUGIN_INCS} @@ -38,6 +37,7 @@ set(local_daemon_incs ${SERVER_CONNECT_INCS} ${LOG_GATHER_INCS} ${EVENTS_INCS} + ${ENGINES_INCS} ) if (GRPC_CONNECTOR) diff --git a/src/daemon/callback/container_cb/execution.c b/src/daemon/callback/container_cb/execution.c index 90ac8aa42538b6f7a6ca87a14acdff6b06f04ab0..5b68b32d06a5a67e0f1a3efc5c8038b92bc74fe0 100644 --- a/src/daemon/callback/container_cb/execution.c +++ b/src/daemon/callback/container_cb/execution.c @@ -30,7 +30,6 @@ #include "constants.h" #include "isula_libutils/log.h" -#include "engine.h" #include "console.h" #include "isulad_config.h" #include "config.h" @@ -55,7 +54,6 @@ #include "collector.h" #include "specs.h" - static int filter_by_label(const container_t *cont, const container_get_id_request *request) { int ret = 0; @@ -68,7 +66,7 @@ static int filter_by_label(const container_t *cont, const container_get_id_reque goto out; } - if (cont->common_config->config == NULL || cont->common_config->config->labels == NULL || \ + if (cont->common_config->config == NULL || cont->common_config->config->labels == NULL || cont->common_config->config->labels->len == 0) { ERROR("No such container: %s", request->id_or_name); isulad_set_error_message("No such container: %s", request->id_or_name); @@ -86,7 +84,7 @@ static int filter_by_label(const container_t *cont, const container_get_id_reque len_val = (strlen(request->label) - len_key) - 1; labels = cont->common_config->config->labels; for (i = 0; i < labels->len; i++) { - if (strlen(labels->keys[i]) == len_key && strncmp(labels->keys[i], request->label, len_key) == 0 && \ + if (strlen(labels->keys[i]) == len_key && strncmp(labels->keys[i], request->label, len_key) == 0 && strlen(labels->values[i]) == len_val && strncmp(labels->values[i], p_equal + 1, len_val) == 0) { ret = 0; goto out; @@ -479,15 +477,13 @@ static int mount_host_channel(const host_config_host_channel *host_channel, cons if (util_detect_mounted(host_channel->path_on_host)) { return 0; } - int nret = snprintf(properties, sizeof(properties), "mode=1777,size=%llu", - (long long unsigned int)host_channel->size); + int nret = + snprintf(properties, sizeof(properties), "mode=1777,size=%llu", (long long unsigned int)host_channel->size); if (nret < 0 || (size_t)nret >= sizeof(properties)) { ERROR("Failed to generate mount properties"); return -1; } - if (mount("tmpfs", host_channel->path_on_host, "tmpfs", - MS_NOEXEC | MS_NOSUID | MS_NODEV, - (void *)properties)) { + if (mount("tmpfs", host_channel->path_on_host, "tmpfs", MS_NOEXEC | MS_NOSUID | MS_NODEV, (void *)properties)) { ERROR("Failed to mount host path '%s'", host_channel->path_on_host); return -1; } @@ -712,15 +708,13 @@ static int write_env_to_target_file(const container_t *cont, const oci_runtime_s ERROR("Failed to get env target file path: %s", cont->hostconfig->env_target_file); return -1; } - ret = write_env_content(env_path, - (const char **)oci_spec->process->env, - oci_spec->process->env_len); + ret = write_env_content(env_path, (const char **)oci_spec->process->env, oci_spec->process->env_len); free(env_path); return ret; } -static int do_post_start_on_success(const char *id, const char *runtime, - const char *pidfile, int exit_fifo_fd, const container_pid_t *pid_info) +static int do_post_start_on_success(const char *id, const char *runtime, const char *pidfile, int exit_fifo_fd, + const container_pid_t *pid_info) { int ret = 0; @@ -846,8 +840,7 @@ out: return ret; } -static int do_start_container(container_t *cont, const char *console_fifos[], bool reset_rm, - container_pid_t *pid_info) +static int do_start_container(container_t *cont, const char *console_fifos[], bool reset_rm, container_pid_t *pid_info) { int ret = 0; int nret = 0; @@ -1071,7 +1064,8 @@ int start_container(container_t *cont, const char *console_fifos[], bool reset_r } if (gc_is_gc_progress(cont->common_config->id)) { - isulad_set_error_message("You cannot start container %s in garbage collector progress.", cont->common_config->id); + isulad_set_error_message("You cannot start container %s in garbage collector progress.", + cont->common_config->id); ERROR("You cannot start container %s in garbage collector progress.", cont->common_config->id); ret = -1; goto out; @@ -1109,8 +1103,8 @@ out: return ret; } -static int prepare_start_io(container_t *cont, const container_start_request *request, - char **fifopath, char *fifos[], int stdinfd, struct io_write_wrapper *stdout_handler, +static int prepare_start_io(container_t *cont, const container_start_request *request, char **fifopath, char *fifos[], + int stdinfd, struct io_write_wrapper *stdout_handler, struct io_write_wrapper *stderr_handler) { int ret = 0; @@ -1126,8 +1120,8 @@ static int prepare_start_io(container_t *cont, const container_start_request *re goto out; } - if (ready_copy_io_data(-1, true, request->stdin, request->stdout, request->stderr, - stdinfd, stdout_handler, stderr_handler, (const char **)fifos, &tid)) { + if (ready_copy_io_data(-1, true, request->stdin, request->stdout, request->stderr, stdinfd, stdout_handler, + stderr_handler, (const char **)fifos, &tid)) { ret = -1; goto out; } @@ -1153,9 +1147,8 @@ static void pack_start_response(container_start_response *response, uint32_t cc, } } -static int container_start_prepare(container_t *cont, const container_start_request *request, - int stdinfd, struct io_write_wrapper *stdout_handler, - struct io_write_wrapper *stderr_handler, +static int container_start_prepare(container_t *cont, const container_start_request *request, int stdinfd, + struct io_write_wrapper *stdout_handler, struct io_write_wrapper *stderr_handler, char **fifopath, char *fifos[]) { const char *id = cont->common_config->id; @@ -1173,9 +1166,8 @@ static int container_start_prepare(container_t *cont, const container_start_requ return 0; } -static int container_start_cb(const container_start_request *request, container_start_response **response, - int stdinfd, struct io_write_wrapper *stdout_handler, - struct io_write_wrapper *stderr_handler) +static int container_start_cb(const container_start_request *request, container_start_response **response, int stdinfd, + struct io_write_wrapper *stdout_handler, struct io_write_wrapper *stderr_handler) { uint32_t cc = ISULAD_SUCCESS; char *id = NULL; @@ -1258,7 +1250,7 @@ static int kill_with_signal(container_t *cont, uint32_t signal) const char *id = cont->common_config->id; bool need_unpause = is_paused(cont->state); rt_resume_params_t params = { 0 }; - char annotations[EXTRA_ANNOTATION_MAX] = {0}; + char annotations[EXTRA_ANNOTATION_MAX] = { 0 }; if (container_exit_on_next(cont)) { ERROR("Failed to cancel restart manager"); @@ -1367,8 +1359,7 @@ int stop_container(container_t *cont, int timeout, bool force, bool restart) } ret = container_wait_stop(cont, timeout); if (ret != 0) { - ERROR("Failed to wait Container(%s) 'STOPPED' for %d seconds, force killing", - id, timeout); + ERROR("Failed to wait Container(%s) 'STOPPED' for %d seconds, force killing", id, timeout); ret = force_kill(cont); if (ret != 0) { ERROR("Failed to force kill container %s", id); @@ -1498,8 +1489,7 @@ static uint32_t do_restart_container(container_t *cont, int timeout) return ISULAD_SUCCESS; } -static int container_restart_cb(const container_restart_request *request, - container_restart_response **response) +static int container_restart_cb(const container_restart_request *request, container_restart_response **response) { int timeout = 0; uint32_t cc = ISULAD_SUCCESS; @@ -1582,8 +1572,7 @@ static void pack_stop_response(container_stop_response *response, uint32_t cc, c } } -static int container_stop_cb(const container_stop_request *request, - container_stop_response **response) +static int container_stop_cb(const container_stop_request *request, container_stop_response **response) { int timeout = 0; bool force = false; @@ -1705,8 +1694,7 @@ static void pack_kill_response(container_kill_response *response, uint32_t cc, c } } -static int container_kill_cb(const container_kill_request *request, - container_kill_response **response) +static int container_kill_cb(const container_kill_request *request, container_kill_response **response) { int ret = 0; char *name = NULL; @@ -1765,7 +1753,6 @@ static int container_kill_cb(const container_kill_request *request, EVENT("Event: {Object: %s, Type: Killing, Signal:%u}", id, signal); - if (gc_is_gc_progress(id)) { isulad_set_error_message("You cannot kill container %s in garbage collector progress.", id); ERROR("You cannot kill container %s in garbage collector progress.", id); @@ -1822,7 +1809,7 @@ int umount_residual_shm(const char *mount_info, const char *target) int cleanup_mounts_by_id(const char *id, const char *engine_root_path) { - char target[PATH_MAX] = {0}; + char target[PATH_MAX] = { 0 }; int nret = 0; nret = snprintf(target, PATH_MAX, "%s/%s", engine_root_path, id); @@ -1967,14 +1954,18 @@ int cleanup_container(container_t *cont, bool force) if (is_paused(cont->state)) { isulad_set_error_message("You cannot remove a paused container %s. " "Unpause and then stop the container before " - "attempting removal or force remove", id); + "attempting removal or force remove", + id); ERROR("You cannot remove a paused container %s. Unpause and then stop the container before " - "attempting removal or force remove", id); + "attempting removal or force remove", + id); } else { isulad_set_error_message("You cannot remove a running container %s. " - "Stop the container before attempting removal or use -f", id); + "Stop the container before attempting removal or use -f", + id); ERROR("You cannot remove a running container %s." - " Stop the container before attempting removal or use -f", id); + " Stop the container before attempting removal or use -f", + id); } ret = -1; goto reset_removal_progress; @@ -2018,8 +2009,7 @@ static void pack_delete_response(container_delete_response *response, uint32_t c } } -static int container_delete_cb(const container_delete_request *request, - container_delete_response **response) +static int container_delete_cb(const container_delete_request *request, container_delete_response **response) { bool force = false; uint32_t cc = ISULAD_SUCCESS; @@ -2101,4 +2091,3 @@ void container_callback_init(service_container_callback_t *cb) container_stream_callback_init(cb); container_extend_callback_init(cb); } - diff --git a/src/daemon/callback/container_cb/execution_create.c b/src/daemon/callback/container_cb/execution_create.c index 94a278c790a25c38d0a58a85f9713a8a0dbed07e..1da23d65483ac67a31df76420f433df7deef90cf 100644 --- a/src/daemon/callback/container_cb/execution_create.c +++ b/src/daemon/callback/container_cb/execution_create.c @@ -29,7 +29,6 @@ #include #include "isula_libutils/log.h" -#include "engine.h" #include "console.h" #include "isulad_config.h" #include "config.h" diff --git a/src/daemon/callback/container_cb/execution_extend.c b/src/daemon/callback/container_cb/execution_extend.c index c8e86727b1480c81dbfda7da0ffa5fd28ebc2ef0..186dbc060dabc4a8e1042d47bd1a460828dcd5c9 100644 --- a/src/daemon/callback/container_cb/execution_extend.c +++ b/src/daemon/callback/container_cb/execution_extend.c @@ -27,7 +27,6 @@ #include #include "isula_libutils/log.h" -#include "engine.h" #include "collector.h" #include "console.h" #include "isulad_config.h" diff --git a/src/daemon/callback/container_cb/execution_information.c b/src/daemon/callback/container_cb/execution_information.c index 91b414a348d3654d419222b6bc4a598eaed5a46c..737d15f078f92763b657f3f66bd9b5600bf61931 100644 --- a/src/daemon/callback/container_cb/execution_information.c +++ b/src/daemon/callback/container_cb/execution_information.c @@ -27,7 +27,6 @@ #include #include "isula_libutils/log.h" -#include "engine.h" #include "console.h" #include "isulad_config.h" #include "config.h" diff --git a/src/daemon/callback/container_cb/execution_stream.c b/src/daemon/callback/container_cb/execution_stream.c index 48ebb822f37a873022019fa79d287f42820482b4..193705fd530b396ac70acb37058b3ee0179b0f29 100644 --- a/src/daemon/callback/container_cb/execution_stream.c +++ b/src/daemon/callback/container_cb/execution_stream.c @@ -30,7 +30,6 @@ #include #include "isula_libutils/log.h" -#include "engine.h" #include "console.h" #include "isulad_config.h" #include "config.h" @@ -496,8 +495,7 @@ err_out: return NULL; } -static int exec_container(container_t *cont, const char *runtime, char * const console_fifos[], - defs_process_user *puser, +static int exec_container(container_t *cont, const char *runtime, char * const console_fifos[], defs_process_user *puser, const container_exec_request *request, int *exit_code) { int ret = 0; diff --git a/src/daemon/callback/image_cb/image_cb.c b/src/daemon/callback/image_cb/image_cb.c index 63419ef60eac6659928a95b5bb9d4c1bd09748e1..62768b7421e935743ebab31989a5121f174f53fe 100644 --- a/src/daemon/callback/image_cb/image_cb.c +++ b/src/daemon/callback/image_cb/image_cb.c @@ -30,7 +30,6 @@ #include "libisulad.h" #include "isula_libutils/log.h" #include "image.h" -#include "engine.h" #include "isulad_config.h" #include "mediatype.h" #include "filters.h" diff --git a/src/daemon/container/container_state.h b/src/daemon/container/container_state.h index a767fe2f65992538a47389e9c7729b64f1dcd85d..b55168f6cbf11b1f3d223b30075b5f2af9a1917d 100644 --- a/src/daemon/container/container_state.h +++ b/src/daemon/container/container_state.h @@ -19,7 +19,7 @@ #include "libisulad.h" #include "isula_libutils/container_config_v2.h" -#include "engine.h" +#include "runtime.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -30,7 +30,6 @@ typedef struct _container_state_t_ { container_config_v2_state *state; } container_state_t; - container_state_t *container_state_new(void); void container_state_free(container_state_t *state); @@ -97,4 +96,3 @@ int dup_health_check_status(defs_health **dst, const defs_health *src); #endif #endif /* __ISULAD_CONTAINER_STATE_H__ */ - diff --git a/src/daemon/container/container_unix.c b/src/daemon/container/container_unix.c index a3578e73f27a33d0f10c17fccb448d89df82d111..ef61a12ce54d75335689ad805ce01fa27c851e9a 100644 --- a/src/daemon/container/container_unix.c +++ b/src/daemon/container/container_unix.c @@ -1056,40 +1056,6 @@ char *container_get_env_nolock(const container_t *cont, const char *key) return val; } -int container_read_proc(uint32_t pid, container_pid_t *pid_info) -{ - int ret = 0; - proc_t *proc = NULL; - proc_t *p_proc = NULL; - - if (pid == 0) { - ret = -1; - goto out; - } - - proc = util_get_process_proc_info((pid_t)pid); - if (proc == NULL) { - ret = -1; - goto out; - } - - p_proc = util_get_process_proc_info((pid_t)proc->ppid); - if (p_proc == NULL) { - ret = -1; - goto out; - } - - pid_info->pid = proc->pid; - pid_info->start_time = proc->start_time; - pid_info->ppid = proc->ppid; - pid_info->pstart_time = p_proc->start_time; - -out: - free(proc); - free(p_proc); - return ret; -} - /* * @cont: check container * @mpath: target mount path diff --git a/src/daemon/container/container_unix.h b/src/daemon/container/container_unix.h index a3b30a0432b4016761e9f4803a5a115d5ef1d7ea..7ba1f88251cacb3fcae9ab8158badc1fada00dd7 100644 --- a/src/daemon/container/container_unix.h +++ b/src/daemon/container/container_unix.h @@ -107,8 +107,6 @@ int container_wait_rm_locking(container_t *cont, int timeout); int save_host_config(const char *id, const char *rootpath, const char *hostconfigstr); int save_config_v2_json(const char *id, const char *rootpath, const char *v2configstr); -int container_read_proc(uint32_t pid, container_pid_t *pid_info); - bool has_mount_for(container_t *cont, const char *mpath); #if defined(__cplusplus) || defined(c_plusplus) @@ -116,4 +114,3 @@ bool has_mount_for(container_t *cont, const char *mpath); #endif #endif /* __ISULAD_CONTAINER_UNIX_H__ */ - diff --git a/src/daemon/container/monitord.h b/src/daemon/container/monitord.h index dbcd1d60b7752d6d29845561730d49dc6b4e7092..5b744b35a9c178c25b0e5e750e858a7778e08fc6 100644 --- a/src/daemon/container/monitord.h +++ b/src/daemon/container/monitord.h @@ -17,7 +17,6 @@ #include #include #include -#include "engine.h" #include "libisulad.h" #include "utils.h" diff --git a/src/daemon/container/restartmanager.h b/src/daemon/container/restartmanager.h index 2f134bd3bd8fc7391a774aa72551449e8073df21..03fec7f32861202244f6be882d190cc55d02efbb 100644 --- a/src/daemon/container/restartmanager.h +++ b/src/daemon/container/restartmanager.h @@ -17,7 +17,6 @@ #include #include -#include "engine.h" #include "isula_libutils/host_config.h" struct restart_policy { @@ -59,6 +58,4 @@ int restart_manager_wait_cancel(restart_manager_t *rm, uint64_t timeout); int container_restart_in_thread(const char *id, uint64_t timeout, int exit_code); - #endif /* __RESTARTMANAGER_H */ - diff --git a/src/daemon/container/restore.h b/src/daemon/container/restore.h index aa4fa5a1291984deb7f3d81d50d2e9eccfe424a3..fc84731db75c619963727c8c2c9268437bfa71d4 100644 --- a/src/daemon/container/restore.h +++ b/src/daemon/container/restore.h @@ -18,8 +18,6 @@ #include #include -#include "engine.h" - #ifdef __cplusplus extern "C" { #endif @@ -31,4 +29,3 @@ extern void containers_restore(void); #endif #endif - diff --git a/src/daemon/engines/CMakeLists.txt b/src/daemon/engines/CMakeLists.txt index dc1297da220d3a79ec794f79c80c0175032b270c..9fbd3425f7003d54498095044ac05db4295ee94a 100644 --- a/src/daemon/engines/CMakeLists.txt +++ b/src/daemon/engines/CMakeLists.txt @@ -1,14 +1,11 @@ # get current directory sources files aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} engines_top_srcs) -add_subdirectory(lcr) set(ENGINES_SRCS ${engines_top_srcs} - ${ENGINES_LCR_SRCS} PARENT_SCOPE ) set(ENGINES_INCS ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/lcr PARENT_SCOPE ) diff --git a/src/daemon/engines/engine.c b/src/daemon/engines/engine.c index 9a950cfd2fe7f3f28899434416e80d3aa68ed225..d45ebc0048a5fd59bef3d8133987f99aad47d2dd 100644 --- a/src/daemon/engines/engine.c +++ b/src/daemon/engines/engine.c @@ -90,8 +90,8 @@ static int engine_routine_log_init(const struct engine_operation *eop) goto unlock_out; } // log throught fifo, so we need disable stderr by quiet (set to 1) - ret = eop->engine_log_init_op(args->progname, engine_log_path, args->json_confs->log_level, eop->engine_type, - 1, NULL); + ret = eop->engine_log_init_op(args->progname, engine_log_path, args->json_confs->log_level, eop->engine_type, 1, + NULL); if (ret != 0) { ret = -1; goto unlock_out; @@ -327,4 +327,3 @@ struct engine_operation *engines_get_handler(const char *name) out: return engine_op; } - diff --git a/src/daemon/engines/engine.h b/src/daemon/engines/engine.h index f361ae6ddaa276ab0e2caff1497ee7c1954d31ca..572cbdb7b88950daf553ef63d027e2f103da8a78 100644 --- a/src/daemon/engines/engine.h +++ b/src/daemon/engines/engine.h @@ -23,19 +23,6 @@ extern "C" { #endif -struct engine_cgroup_resources { - uint64_t blkio_weight; - uint64_t cpu_shares; - uint64_t cpu_period; - uint64_t cpu_quota; - char *cpuset_cpus; - char *cpuset_mems; - uint64_t memory_limit; - uint64_t memory_swap; - uint64_t memory_reservation; - uint64_t kernel_memory_limit; -}; - typedef enum { ENGINE_CONTAINER_STATUS_UNKNOWN = 0, ENGINE_CONTAINER_STATUS_CREATED = 1, @@ -47,19 +34,6 @@ typedef enum { ENGINE_CONTAINER_STATUS_MAX_STATE = 7 } Engine_Container_Status; -struct engine_container_summary_info { - char *id; - uint32_t has_pid; - uint32_t pid; - Engine_Container_Status status; - char *image; - char *command; - uint32_t exit_code; - uint32_t restart_count; - char *startat; - char *finishat; -}; - struct engine_container_status_info { bool has_pid; uint32_t pid; @@ -82,12 +56,31 @@ struct engine_container_resources_stats_info { uint64_t kmem_limit; }; -typedef struct _container_pid_t { - int pid; /* process id */ - int ppid; /* pid of parent process */ - unsigned long long start_time, /* start time of process -- seconds since 1-1-70 */ - pstart_time; /* start time of parent process -- seconds since 1-1-70 */ -} container_pid_t; +struct engine_cgroup_resources { + uint64_t blkio_weight; + uint64_t cpu_shares; + uint64_t cpu_period; + uint64_t cpu_quota; + char *cpuset_cpus; + char *cpuset_mems; + uint64_t memory_limit; + uint64_t memory_swap; + uint64_t memory_reservation; + uint64_t kernel_memory_limit; +}; + +struct engine_container_summary_info { + char *id; + uint32_t has_pid; + uint32_t pid; + Engine_Container_Status status; + char *image; + char *command; + uint32_t exit_code; + uint32_t restart_count; + char *startat; + char *finishat; +}; typedef struct _engine_start_request_t { const char *name; @@ -129,7 +122,6 @@ typedef struct _engine_exec_request_t { bool open_stdin; } engine_exec_request_t; - typedef bool (*engine_create_t)(const char *, const char *, void *); typedef bool (*engine_start_t)(const engine_start_request_t *request); @@ -208,4 +200,3 @@ extern struct engine_operation *engines_get_handler(const char *name); #endif #endif - diff --git a/src/daemon/engines/lcr/CMakeLists.txt b/src/daemon/engines/lcr/CMakeLists.txt deleted file mode 100644 index 5b848c2387cd94dab77261389a292f489bb5443b..0000000000000000000000000000000000000000 --- a/src/daemon/engines/lcr/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_lcr_srcs) - -set(ENGINES_LCR_SRCS - ${local_lcr_srcs} - PARENT_SCOPE - ) diff --git a/src/daemon/libisulad.c b/src/daemon/libisulad.c index 7a4bc5e3ba426bacec5ad635ff0f4301b075d232..b2ea49f040409b758570d6bfae7419143280c068 100644 --- a/src/daemon/libisulad.c +++ b/src/daemon/libisulad.c @@ -193,7 +193,6 @@ void isulad_container_resize_response_free(struct isulad_container_resize_respon free(response); } - void isulad_logs_request_free(struct isulad_logs_request *request) { if (request == NULL) { @@ -258,3 +257,36 @@ void isulad_events_format_free(struct isulad_events_format *value) free(value); } +int container_read_proc(uint32_t pid, container_pid_t *pid_info) +{ + int ret = 0; + proc_t *proc = NULL; + proc_t *p_proc = NULL; + + if (pid == 0) { + ret = -1; + goto out; + } + + proc = util_get_process_proc_info((pid_t)pid); + if (proc == NULL) { + ret = -1; + goto out; + } + + p_proc = util_get_process_proc_info((pid_t)proc->ppid); + if (p_proc == NULL) { + ret = -1; + goto out; + } + + pid_info->pid = proc->pid; + pid_info->start_time = proc->start_time; + pid_info->ppid = proc->ppid; + pid_info->pstart_time = p_proc->start_time; + +out: + free(proc); + free(p_proc); + return ret; +} diff --git a/src/daemon/libisulad.h b/src/daemon/libisulad.h index b12185d3d9d23d5032526224f7bbd1e5fbdecb7b..63616762475a4025be08d60bae053e6c8705acfd 100644 --- a/src/daemon/libisulad.h +++ b/src/daemon/libisulad.h @@ -36,6 +36,13 @@ extern __thread char *g_isulad_errmsg; } \ } while (0) +typedef struct _container_pid_t { + int pid; /* process id */ + int ppid; /* pid of parent process */ + unsigned long long start_time, /* start time of process -- seconds since 1-1-70 */ + pstart_time; /* start time of parent process -- seconds since 1-1-70 */ +} container_pid_t; + typedef enum { EVENTS_TYPE_EXIT = 0, EVENTS_TYPE_STOPPED1 = 1, @@ -244,6 +251,7 @@ void isulad_logs_response_free(struct isulad_logs_response *response); void isulad_events_format_free(struct isulad_events_format *value); +int container_read_proc(uint32_t pid, container_pid_t *pid_info); #ifdef __cplusplus } #endif diff --git a/src/daemon/runtime/CMakeLists.txt b/src/daemon/runtime/CMakeLists.txt index cdff93892b133f546903fa4cd8d7cec61d6f207a..383250c619ed0be14f7616cd9460811b397a43b5 100644 --- a/src/daemon/runtime/CMakeLists.txt +++ b/src/daemon/runtime/CMakeLists.txt @@ -12,7 +12,7 @@ set(local_runtime_srcs set(local_runtime_incs ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/lcr + ${LCR_INCS} ${CMAKE_CURRENT_SOURCE_DIR}/isula ) diff --git a/src/daemon/runtime/isula/isula_rt_ops.c b/src/daemon/runtime/isula/isula_rt_ops.c index 63145f66098667893c56ac27010f6b7e78ee926c..1c79b927eab8a1566ddd515462d2d734f6c87d30 100644 --- a/src/daemon/runtime/isula/isula_rt_ops.c +++ b/src/daemon/runtime/isula/isula_rt_ops.c @@ -23,7 +23,6 @@ #include "isula_libutils/log.h" #include "error.h" #include "runtime.h" -#include "engine.h" #include "constants.h" #include "isula_libutils/shim_client_process_state.h" #include "isula_libutils/shim_client_runtime_stats.h" @@ -33,10 +32,9 @@ #include "libisulad.h" #define SHIM_BINARY "isulad-shim" -#define SHIM_LOG_SIZE ((BUFSIZ-100)/2) +#define SHIM_LOG_SIZE ((BUFSIZ - 100) / 2) #define PID_WAIT_TIME 120 - static void copy_process(shim_client_process_state *p, defs_process *dp) { p->args = dp->args; @@ -83,7 +81,7 @@ static void copy_annotations(shim_client_process_state *p, json_map_string_strin static int file_write_int(const char *fname, int val) { - char sint[UINT_LEN] = {0}; + char sint[UINT_LEN] = { 0 }; if (snprintf(sint, sizeof(sint), "%d", val) < 0) { return -1; @@ -121,10 +119,10 @@ static void file_read_int(const char *fname, int *val) static void get_err_message(char *buf, int buf_size, const char *workdir, const char *file) { - char fname[PATH_MAX] = {0}; + char fname[PATH_MAX] = { 0 }; FILE *fp = NULL; char *pline = NULL; - char *lines[3] = {0}; + char *lines[3] = { 0 }; size_t length = 0; if (snprintf(fname, sizeof(fname), "%s/%s", workdir, file) < 0) { @@ -177,9 +175,9 @@ static void get_err_message(char *buf, int buf_size, const char *workdir, const static void show_shim_runtime_errlog(const char *workdir) { - char buf[BUFSIZ] = {0}; - char buf1[SHIM_LOG_SIZE] = {0}; - char buf2[SHIM_LOG_SIZE] = {0}; + char buf[BUFSIZ] = { 0 }; + char buf1[SHIM_LOG_SIZE] = { 0 }; + char buf2[SHIM_LOG_SIZE] = { 0 }; get_err_message(buf1, sizeof(buf1), workdir, "shim-log.json"); get_err_message(buf2, sizeof(buf2), workdir, "log.json"); @@ -200,10 +198,10 @@ bool rt_isula_detect(const char *runtime) static int create_process_json_file(const char *workdir, const shim_client_process_state *p) { - struct parser_context ctx = {OPT_GEN_SIMPLIFY, 0}; + struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; parser_error perr = NULL; char *data = NULL; - char fname[PATH_MAX] = {0}; + char fname[PATH_MAX] = { 0 }; int retcode = 0; if (snprintf(fname, sizeof(fname), "%s/process.json", workdir) < 0) { @@ -328,7 +326,7 @@ out: static bool shim_alive(const char *workdir) { int pid = 0; - char fpid[PATH_MAX] = {0}; + char fpid[PATH_MAX] = { 0 }; int ret = 0; if (snprintf(fpid, sizeof(fpid), "%s/shim-pid", workdir) < 0) { @@ -403,10 +401,8 @@ static void runtime_exec_param_init(runtime_exec_info *rei) } } -static void runtime_exec_info_init(runtime_exec_info *rei, - const char *workdir, const char *runtime, - const char *subcmd, const char **opts, size_t opts_len, const char *id, - char **params, size_t params_num) +static void runtime_exec_info_init(runtime_exec_info *rei, const char *workdir, const char *runtime, const char *subcmd, + const char **opts, size_t opts_len, const char *id, char **params, size_t params_num) { rei->workdir = workdir; rei->runtime = runtime; @@ -423,10 +419,9 @@ static void runtime_exec_info_init(runtime_exec_info *rei, runtime_exec_param_dump((const char **)rei->params); } - static void runtime_exec_func(void *arg) { - runtime_exec_info *rei = (runtime_exec_info *) arg; + runtime_exec_info *rei = (runtime_exec_info *)arg; if (rei == NULL) { dprintf(STDERR_FILENO, "missing runtime exec info"); @@ -457,17 +452,17 @@ static int status_string_to_int(const char *status) return ENGINE_CONTAINER_STATUS_UNKNOWN; } -static int runtime_call_status(const char *workdir, const char *runtime, - const char *id, struct engine_container_status_info *ecsi) +static int runtime_call_status(const char *workdir, const char *runtime, const char *id, + struct engine_container_status_info *ecsi) { char *stdout = NULL; char *stderr = NULL; oci_runtime_state *state = NULL; - struct parser_context ctx = {OPT_GEN_SIMPLIFY, 0}; + struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; parser_error perr = NULL; runtime_exec_info rei = { 0 }; int ret = 0; - char *params[PARAM_NUM] = {0}; + char *params[PARAM_NUM] = { 0 }; runtime_exec_info_init(&rei, workdir, runtime, "state", NULL, 0, id, params, PARAM_NUM); @@ -506,18 +501,18 @@ out: return ret; } -static int runtime_call_stats(const char *workdir, const char *runtime, - const char *id, struct engine_container_resources_stats_info *info) +static int runtime_call_stats(const char *workdir, const char *runtime, const char *id, + struct engine_container_resources_stats_info *info) { char *stdout = NULL; char *stderr = NULL; shim_client_runtime_stats *stats = NULL; - struct parser_context ctx = {OPT_GEN_SIMPLIFY, 0}; + struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 }; parser_error perr = NULL; runtime_exec_info rei = { 0 }; int ret = 0; - char *params[PARAM_NUM] = {0}; - const char *opts[1] = {"--stats"}; + char *params[PARAM_NUM] = { 0 }; + const char *opts[1] = { "--stats" }; runtime_exec_info_init(&rei, workdir, runtime, "events", opts, 1, id, params, PARAM_NUM); @@ -560,14 +555,14 @@ out: return ret; } -static int runtime_call_simple(const char *workdir, const char *runtime, - const char *subcmd, const char **opts, size_t opts_len, const char *id) +static int runtime_call_simple(const char *workdir, const char *runtime, const char *subcmd, const char **opts, + size_t opts_len, const char *id) { - runtime_exec_info rei = {0}; + runtime_exec_info rei = { 0 }; char *stdout = NULL; char *stderr = NULL; int ret = 0; - char *params[PARAM_NUM] = {0}; + char *params[PARAM_NUM] = { 0 }; runtime_exec_info_init(&rei, workdir, runtime, subcmd, opts, opts_len, id, params, PARAM_NUM); if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout, &stderr)) { @@ -588,7 +583,7 @@ static int runtime_call_kill_force(const char *workdir, const char *runtime, con static int runtime_call_delete_force(const char *workdir, const char *runtime, const char *id) { - const char *opts[1] = {"--force"}; + const char *opts[1] = { "--force" }; return runtime_call_simple(workdir, runtime, "delete", opts, 1, id); } @@ -611,8 +606,7 @@ static int status_to_exit_code(int status) return exit_code; } -static int shim_create(bool fg, const char *id, const char *workdir, - const char *bundle, const char *runtime_cmd, +static int shim_create(bool fg, const char *id, const char *workdir, const char *bundle, const char *runtime_cmd, int *exit_code) { pid_t pid = 0; @@ -620,8 +614,8 @@ static int shim_create(bool fg, const char *id, const char *workdir, int num = 0; int ret = 0; char exec_buff[BUFSIZ + 1] = { 0 }; - char fpid[PATH_MAX] = {0}; - const char *params[PARAM_NUM] = {0}; + char fpid[PATH_MAX] = { 0 }; + const char *params[PARAM_NUM] = { 0 }; int i = 0; int status = 0; @@ -718,19 +712,18 @@ realexec: out: if (ret != 0) { show_shim_runtime_errlog(workdir); - kill(pid, SIGKILL); /* can kill other process? */ + kill(pid, SIGKILL); /* can kill other process? */ } return ret; } - static int get_container_process_pid(const char *workdir) { - char fname[PATH_MAX] = {0}; + char fname[PATH_MAX] = { 0 }; int pid = 0; - struct timespec beg = {0}; - struct timespec end = {0}; + struct timespec beg = { 0 }; + struct timespec end = { 0 }; if (snprintf(fname, sizeof(fname), "%s/pid", workdir) < 0) { ERROR("failed make pid full path"); @@ -760,7 +753,7 @@ static int get_container_process_pid(const char *workdir) ERROR("failed read pid from dead shim %s", workdir); return -1; } - return pid; /* success */ + return pid; /* success */ } return -1; } @@ -768,7 +761,7 @@ static int get_container_process_pid(const char *workdir) static void shim_kill_force(const char *workdir) { int pid = 0; - char fpid[PATH_MAX] = {0}; + char fpid[PATH_MAX] = { 0 }; if (snprintf(fpid, sizeof(fpid), "%s/shim-pid", workdir) < 0) { INFO("shim-pid not exist"); @@ -787,16 +780,15 @@ out: INFO("kill shim force %s", workdir); } -int rt_isula_create(const char *id, const char *runtime, - const rt_create_params_t *params) +int rt_isula_create(const char *id, const char *runtime, const rt_create_params_t *params) { oci_runtime_spec *config = NULL; const char *cmd = NULL; const char **runtime_args = NULL; size_t runtime_args_len = 0; int ret = 0; - char workdir[PATH_MAX] = {0}; - shim_client_process_state p = {0}; + char workdir[PATH_MAX] = { 0 }; + shim_client_process_state p = { 0 }; if (id == NULL || runtime == NULL || params == NULL) { ERROR("nullptr arguments not allowed"); @@ -840,11 +832,9 @@ out: return ret; } -int rt_isula_start(const char *id, const char *runtime, - const rt_start_params_t *params, - container_pid_t *pid_info) +int rt_isula_start(const char *id, const char *runtime, const rt_start_params_t *params, container_pid_t *pid_info) { - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; pid_t pid = 0; int ret = 0; @@ -885,17 +875,15 @@ out: return ret; } -int rt_isula_restart(const char *name, const char *runtime, - const rt_restart_params_t *params) +int rt_isula_restart(const char *name, const char *runtime, const rt_restart_params_t *params) { ERROR(">>> restart not implemented"); return RUNTIME_NOT_IMPLEMENT_RESET; } -int rt_isula_clean_resource(const char *id, const char *runtime, - const rt_clean_params_t *params) +int rt_isula_clean_resource(const char *id, const char *runtime, const rt_clean_params_t *params) { - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; if (id == NULL || runtime == NULL || params == NULL) { ERROR("nullptr arguments not allowed"); @@ -930,7 +918,7 @@ int rt_isula_clean_resource(const char *id, const char *runtime, int rt_isula_rm(const char *id, const char *runtime, const rt_rm_params_t *params) { - char libdir[PATH_MAX] = {0}; + char libdir[PATH_MAX] = { 0 }; if (id == NULL || runtime == NULL || params == NULL) { ERROR("nullptr arguments not allowed"); @@ -978,26 +966,24 @@ err_out: static bool fg_exec(const rt_exec_params_t *params) { - if (params->console_fifos[0] != NULL || params->console_fifos[1] != NULL || - params->console_fifos[2] != NULL) { + if (params->console_fifos[0] != NULL || params->console_fifos[1] != NULL || params->console_fifos[2] != NULL) { return true; } return false; } -int rt_isula_exec(const char *id, const char *runtime, - const rt_exec_params_t *params, int *exit_code) +int rt_isula_exec(const char *id, const char *runtime, const rt_exec_params_t *params, int *exit_code) { char *exec_id = NULL; defs_process *process = NULL; const char **runtime_args = NULL; size_t runtime_args_len = 0; - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; const char *cmd = NULL; int ret = 0; - char bundle[PATH_MAX] = {0}; + char bundle[PATH_MAX] = { 0 }; int pid = 0; - shim_client_process_state p = {0}; + shim_client_process_state p = { 0 }; if (id == NULL || runtime == NULL || params == NULL || exit_code == NULL) { ERROR("nullptr arguments not allowed"); @@ -1070,11 +1056,10 @@ out: return ret; } -int rt_isula_status(const char *id, const char *runtime, - const rt_status_params_t *params, +int rt_isula_status(const char *id, const char *runtime, const rt_status_params_t *params, struct engine_container_status_info *status) { - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; int ret = 0; if (id == NULL || runtime == NULL || params == NULL || status == NULL) { @@ -1100,8 +1085,7 @@ out: return ret; } -int rt_isula_attach(const char *id, const char *runtime, - const rt_attach_params_t *params) +int rt_isula_attach(const char *id, const char *runtime, const rt_attach_params_t *params) { ERROR("isula attach not support on isulad-shim"); isulad_set_error_message("isula attach not support on isulad-shim"); @@ -1117,7 +1101,7 @@ int rt_isula_update(const char *id, const char *runtime, const rt_update_params_ int rt_isula_pause(const char *id, const char *runtime, const rt_pause_params_t *params) { - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; if (id == NULL || runtime == NULL || params == NULL) { ERROR("nullptr arguments not allowed"); @@ -1134,7 +1118,7 @@ int rt_isula_pause(const char *id, const char *runtime, const rt_pause_params_t int rt_isula_resume(const char *id, const char *runtime, const rt_resume_params_t *params) { - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; if (id == NULL || runtime == NULL || params == NULL) { ERROR("nullptr arguments not allowed"); @@ -1156,11 +1140,10 @@ int rt_isula_listpids(const char *name, const char *runtime, const rt_listpids_p return -1; } -int rt_isula_resources_stats(const char *id, const char *runtime, - const rt_stats_params_t *params, +int rt_isula_resources_stats(const char *id, const char *runtime, const rt_stats_params_t *params, struct engine_container_resources_stats_info *rs_stats) { - char workdir[PATH_MAX] = {0}; + char workdir[PATH_MAX] = { 0 }; int ret = 0; if (id == NULL || runtime == NULL || params == NULL || rs_stats == NULL) { diff --git a/src/daemon/runtime/lcr/CMakeLists.txt b/src/daemon/runtime/lcr/CMakeLists.txt index f3b1c4d4455b36faf1e512ad0964f6bfaf003a89..e00109684aabb7d4eec81e61cca38e32e52137f6 100644 --- a/src/daemon/runtime/lcr/CMakeLists.txt +++ b/src/daemon/runtime/lcr/CMakeLists.txt @@ -1,7 +1,20 @@ # get current directory sources files -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_lcr_srcs) + +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} runtime_lcr_top_srcs) + +set(local_runtime_lcr_srcs + ${runtime_lcr_top_srcs} + ) + +set(local_runtime_lcr_incs + ${CMAKE_CURRENT_SOURCE_DIR} + ) set(LCR_SRCS - ${local_lcr_srcs} + ${local_runtime_lcr_srcs} + PARENT_SCOPE + ) +set(LCR_INCS + ${local_runtime_lcr_incs} PARENT_SCOPE ) diff --git a/src/daemon/engines/lcr/lcr_engine.c b/src/daemon/runtime/lcr/lcr_engine.c similarity index 100% rename from src/daemon/engines/lcr/lcr_engine.c rename to src/daemon/runtime/lcr/lcr_engine.c diff --git a/src/daemon/engines/lcr/lcr_engine.h b/src/daemon/runtime/lcr/lcr_engine.h similarity index 99% rename from src/daemon/engines/lcr/lcr_engine.h rename to src/daemon/runtime/lcr/lcr_engine.h index a0ae7863853f2daed0a101d8646132c5b1deb0e0..3887dbc47a0d80b6446875dc7146e85e695d3636 100644 --- a/src/daemon/engines/lcr/lcr_engine.h +++ b/src/daemon/runtime/lcr/lcr_engine.h @@ -28,4 +28,3 @@ struct engine_operation *lcr_engine_init(); #endif #endif - diff --git a/src/daemon/runtime/lcr/lcr_rt_ops.c b/src/daemon/runtime/lcr/lcr_rt_ops.c index bb2a4056ede5d3db5cefa223a3d382d7673f3564..f66003c54fd30ec49b5392d3a354d18ee73b6e16 100644 --- a/src/daemon/runtime/lcr/lcr_rt_ops.c +++ b/src/daemon/runtime/lcr/lcr_rt_ops.c @@ -22,6 +22,7 @@ #include "engine.h" #include "error.h" #include "isulad_config.h" +#include "libisulad.h" #include "runtime.h" bool rt_lcr_detect(const char *runtime) @@ -61,8 +62,7 @@ int rt_lcr_create(const char *name, const char *runtime, const rt_create_params_ tmpmsg = engine_ops->engine_get_errmsg_op(); } isulad_set_error_message("Create container error: %s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -95,7 +95,7 @@ static int lcr_rt_read_pidfile(const char *pidfile, container_pid_t *pid_info) return -1; } - char sbuf[1024] = { 0 }; /* bufs for stat */ + char sbuf[1024] = { 0 }; /* bufs for stat */ if ((util_file2str(pidfile, sbuf, sizeof(sbuf))) == -1) { return -1; @@ -135,10 +135,8 @@ int rt_lcr_start(const char *name, const char *runtime, const rt_start_params_t tmpmsg = engine_ops->engine_get_errmsg_op(); } isulad_set_error_message("Start container error: %s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); - ERROR("Start container error: %s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); + ERROR("Start container error: %s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -178,8 +176,7 @@ int rt_lcr_clean_resource(const char *name, const char *runtime, const rt_clean_ tmpmsg = engine_ops->engine_get_errmsg_op(); } isulad_try_set_error_message("Clean resource container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -392,8 +389,8 @@ int rt_lcr_exec(const char *id, const char *runtime, const rt_exec_params_t *par if (engine_ops->engine_get_errmsg_op != NULL) { tmpmsg = engine_ops->engine_get_errmsg_op(); } - isulad_set_error_message("Exec container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Exec container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); util_contain_errmsg(g_isulad_errmsg, exit_code); ret = -1; goto out; @@ -425,8 +422,8 @@ int rt_lcr_pause(const char *name, const char *runtime, const rt_pause_params_t if (engine_ops->engine_get_errmsg_op != NULL) { tmpmsg = engine_ops->engine_get_errmsg_op(); } - isulad_set_error_message("Pause container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Pause container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -456,8 +453,7 @@ int rt_lcr_resume(const char *name, const char *runtime, const rt_resume_params_ tmpmsg = engine_ops->engine_get_errmsg_op(); } isulad_set_error_message("Resume container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -487,8 +483,8 @@ int rt_lcr_attach(const char *name, const char *runtime, const rt_attach_params_ if (engine_ops->engine_get_errmsg_op != NULL) { tmpmsg = engine_ops->engine_get_errmsg_op(); } - isulad_set_error_message("Attach container error;%s", (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Attach container error;%s", + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -538,8 +534,8 @@ int rt_lcr_update(const char *id, const char *runtime, const rt_update_params_t if (engine_ops->engine_get_errmsg_op != NULL) { tmpmsg = engine_ops->engine_get_errmsg_op(); } - isulad_set_error_message("Cannot update container %s: %s", id, (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? - tmpmsg : DEF_ERR_RUNTIME_STR); + isulad_set_error_message("Cannot update container %s: %s", id, + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } @@ -605,8 +601,7 @@ int rt_lcr_resize(const char *id, const char *runtime, const rt_resize_params_t tmpmsg = engine_ops->engine_get_errmsg_op(); } isulad_set_error_message("Resize container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; @@ -637,8 +632,7 @@ int rt_lcr_exec_resize(const char *id, const char *runtime, const rt_exec_resize tmpmsg = engine_ops->engine_get_errmsg_op(); } isulad_set_error_message("Resize container error;%s", - (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg - : DEF_ERR_RUNTIME_STR); + (tmpmsg && strcmp(tmpmsg, DEF_SUCCESS_STR)) ? tmpmsg : DEF_ERR_RUNTIME_STR); ret = -1; goto out; } diff --git a/src/daemon/runtime/runtime.h b/src/daemon/runtime/runtime.h index e49d2bdede4760aacc816bd60a64340d9066486e..8de425dab39b882ab53d93240be2ca1e3512bcd6 100644 --- a/src/daemon/runtime/runtime.h +++ b/src/daemon/runtime/runtime.h @@ -17,8 +17,9 @@ #include #include - -#include "container_unix.h" +#include "libisulad.h" +#include "isula_libutils/host_config.h" +#include "isula_libutils/oci_runtime_spec.h" #include "engine.h" #ifdef __cplusplus @@ -41,7 +42,6 @@ typedef struct _rt_create_params_t { bool open_stdin; } rt_create_params_t; - typedef struct _rt_start_params_t { const char *rootpath; const char *state; @@ -162,8 +162,7 @@ struct rt_ops { int (*rt_resources_stats)(const char *name, const char *runtime, const rt_stats_params_t *params, struct engine_container_resources_stats_info *rs_stats); - int (*rt_exec)(const char *name, const char *runtime, const rt_exec_params_t *params, - int *exit_code); + int (*rt_exec)(const char *name, const char *runtime, const rt_exec_params_t *params, int *exit_code); int (*rt_pause)(const char *name, const char *runtime, const rt_pause_params_t *params); int (*rt_resume)(const char *name, const char *runtime, const rt_resume_params_t *params); @@ -187,8 +186,7 @@ int runtime_status(const char *name, const char *runtime, const rt_status_params struct engine_container_status_info *status); int runtime_resources_stats(const char *name, const char *runtime, const rt_stats_params_t *params, struct engine_container_resources_stats_info *rs_stats); -int runtime_exec(const char *name, const char *runtime, const rt_exec_params_t *params, - int *exit_code); +int runtime_exec(const char *name, const char *runtime, const rt_exec_params_t *params, int *exit_code); int runtime_pause(const char *name, const char *runtime, const rt_pause_params_t *params); int runtime_resume(const char *name, const char *runtime, const rt_resume_params_t *params); int runtime_attach(const char *name, const char *runtime, const rt_attach_params_t *params); @@ -204,4 +202,3 @@ int runtime_exec_resize(const char *name, const char *runtime, const rt_exec_res #endif #endif -