From 209ada69e7792c8942816a6571b2502d2c4871b2 Mon Sep 17 00:00:00 2001 From: zhangsong34 Date: Sat, 7 Mar 2020 21:40:53 +0800 Subject: [PATCH] iSulad: support syscontainer without external rootfs Signed-off-by: zhangsong34 --- src/services/execution/execute/execution.c | 4 ++-- src/services/execution/execute/execution_create.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/services/execution/execute/execution.c b/src/services/execution/execute/execution.c index cd92e03..90a3f56 100644 --- a/src/services/execution/execute/execution.c +++ b/src/services/execution/execute/execution.c @@ -248,7 +248,7 @@ static int send_signal_to_process(pid_t pid, unsigned long long start_time, uint static int umount_dev_tmpfs_for_system_container(const container_t *cont) { - if (cont->hostconfig != NULL && cont->hostconfig->system_container) { + if (cont->hostconfig != NULL && cont->hostconfig->system_container && cont->hostconfig->external_rootfs != NULL) { char rootfs_dev_path[PATH_MAX] = { 0 }; int nret = snprintf(rootfs_dev_path, sizeof(rootfs_dev_path), "%s/dev", cont->common_config->base_fs); if ((size_t)nret >= sizeof(rootfs_dev_path) || nret < 0) { @@ -514,7 +514,7 @@ static int mount_dev_tmpfs_for_system_container(const container_t *cont) if (cont == NULL || cont->hostconfig == NULL || cont->common_config == NULL) { return 0; } - if (!cont->hostconfig->system_container) { + if (!cont->hostconfig->system_container || cont->hostconfig->external_rootfs == NULL) { return 0; } int nret = snprintf(rootfs_dev_path, sizeof(rootfs_dev_path), "%s/dev", cont->common_config->base_fs); diff --git a/src/services/execution/execute/execution_create.c b/src/services/execution/execute/execution_create.c index 15180da..02fb799 100644 --- a/src/services/execution/execute/execution_create.c +++ b/src/services/execution/execute/execution_create.c @@ -285,12 +285,23 @@ static int merge_config_for_syscontainer(const container_create_request *request const container_config *container_spec, const oci_runtime_spec *oci_spec) { int ret = 0; + char *value = NULL; - if (!host_spec->system_container || request->rootfs == NULL) { + if (!host_spec->system_container) { return 0; } + if (request->rootfs == NULL) { + value = oci_spec->root->path; + } else { + value = request->rootfs; + } - if (append_json_map_string_string(oci_spec->annotations, "rootfs.mount", request->rootfs)) { + if (append_json_map_string_string(oci_spec->annotations, "rootfs.mount", value)) { + ERROR("Realloc annotations failed"); + ret = -1; + goto out; + } + if (request->rootfs != NULL && append_json_map_string_string(oci_spec->annotations, "external.rootfs", "true")) { ERROR("Realloc annotations failed"); ret = -1; goto out; -- GitLab