From 8d760da7f5f58c8caa0e8546f33f02dfcd473185 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Tue, 23 Jan 2024 14:25:17 +0800
Subject: [PATCH 190/198] update rootfs.mnt in container spec for system
 container

Signed-off-by: jikai <jikai11@huawei.com>
---
 src/daemon/executor/container_cb/execution_create.c | 7 +++++--
 src/daemon/modules/service/service_container.c      | 1 +
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c
index d5e54aaf..a0b3fd9e 100644
--- a/src/daemon/executor/container_cb/execution_create.c
+++ b/src/daemon/executor/container_cb/execution_create.c
@@ -564,12 +564,15 @@ static int merge_config_for_syscontainer(const container_create_request *request
         value = request->rootfs;
     }
 
-    if (append_json_map_string_string(oci_spec->annotations, "rootfs.mount", value)) {
+    // should also update to container spec
+    if (append_json_map_string_string(container_spec->annotations, "rootfs.mount", value)
+        || 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")) {
+    if (request->rootfs != NULL && (append_json_map_string_string(container_spec->annotations, "external.rootfs", "true")
+        || append_json_map_string_string(oci_spec->annotations, "external.rootfs", "true"))) {
         ERROR("Realloc annotations failed");
         ret = -1;
         goto out;
diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c
index d2802db0..534a0a1d 100644
--- a/src/daemon/modules/service/service_container.c
+++ b/src/daemon/modules/service/service_container.c
@@ -690,6 +690,7 @@ static int do_oci_spec_update(const char *id, oci_runtime_spec *oci_spec, contai
 
     // Renew annotations for oci spec, cgroup path only,
     // since lxc uses the "cgroup.dir" in oci annotations to create cgroup
+    // should ensure that container spec has the same annotations as oci spec
     ret = update_spec_annotations(oci_spec, container_spec, hostconfig);
     if (ret < 0) {
         return -1;
-- 
2.25.1

