diff --git a/0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch b/0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch new file mode 100644 index 0000000000000000000000000000000000000000..102b524c37ccdc62c0748c4591a6c0b551c37991 --- /dev/null +++ b/0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch @@ -0,0 +1,128 @@ +From c080da6dda7a47de8ccb5cc3eabec6e5b2e4c649 Mon Sep 17 00:00:00 2001 +From: WangFengTu +Date: Mon, 23 May 2022 19:00:28 +0800 +Subject: [PATCH] do not operate playload and attach cgroup if no controller + +Signed-off-by: WangFengTu +--- + src/lxc/cgroups/cgroup.h | 1 + + src/lxc/cgroups/isulad_cgfsng.c | 48 ++++++++++++++++++++++++++++++++- + 2 files changed, 48 insertions(+), 1 deletion(-) + +diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h +index a9048c4..8b18c1e 100644 +--- a/src/lxc/cgroups/cgroup.h ++++ b/src/lxc/cgroups/cgroup.h +@@ -104,6 +104,7 @@ struct cgroup_ops { + + #ifdef HAVE_ISULAD + int errfd; ++ bool no_controller; + #endif + + /* @hierarchies +diff --git a/src/lxc/cgroups/isulad_cgfsng.c b/src/lxc/cgroups/isulad_cgfsng.c +index 576b424..8a9656a 100644 +--- a/src/lxc/cgroups/isulad_cgfsng.c ++++ b/src/lxc/cgroups/isulad_cgfsng.c +@@ -677,6 +677,13 @@ __cgfsng_ops static bool isulad_cgfsng_payload_destroy(struct cgroup_ops *ops, + return false; + } + ++#ifdef HAVE_ISULAD ++ if (ops->no_controller) { ++ DEBUG("no controller found, isgnore isulad_cgfsng_payload_destroy"); ++ return true; ++ } ++#endif ++ + if (!ops->hierarchies) { + return false; + } +@@ -934,6 +941,13 @@ __cgfsng_ops static inline bool isulad_cgfsng_payload_create(struct cgroup_ops * + int i; + char *container_cgroup = ops->container_cgroup; + ++#ifdef HAVE_ISULAD ++ if (ops->no_controller) { ++ DEBUG("no controller found, isgnore isulad_cgfsng_payload_create"); ++ return true; ++ } ++#endif ++ + if (!container_cgroup) { + ERROR("cgfsng_create container_cgroup is invalid"); + return false; +@@ -964,6 +978,13 @@ __cgfsng_ops static bool isulad_cgfsng_payload_enter(struct cgroup_ops *ops, + if (!ops) + return ret_set_errno(false, ENOENT); + ++#ifdef HAVE_ISULAD ++ if (ops->no_controller) { ++ DEBUG("no controller found, isgnore isulad_cgfsng_payload_enter"); ++ return true; ++ } ++#endif ++ + if (!ops->hierarchies) + return true; + +@@ -1121,6 +1142,13 @@ __cgfsng_ops void isulad_cgfsng_payload_finalize(struct cgroup_ops *ops) + if (!ops) + return; + ++#ifdef HAVE_ISULAD ++ if (ops->no_controller) { ++ DEBUG("no controller found, isgnore isulad_cgfsng_payload_finalize"); ++ return; ++ } ++#endif ++ + if (!ops->hierarchies) + return; + +@@ -2010,6 +2038,13 @@ __cgfsng_ops static bool isulad_cgfsng_attach(struct cgroup_ops *ops, + if (!ops) + return ret_set_errno(false, ENOENT); + ++#ifdef HAVE_ISULAD ++ if (ops->no_controller) { ++ DEBUG("no controller found, isgnore isulad_cgfsng_attach"); ++ return true; ++ } ++#endif ++ + if (!ops->hierarchies) + return true; + +@@ -2781,6 +2816,13 @@ __cgfsng_ops bool isulad_cgfsng_payload_delegate_controllers(struct cgroup_ops * + if (!ops) + return ret_set_errno(false, ENOENT); + ++#ifdef HAVE_ISULAD ++ if (ops->no_controller) { ++ DEBUG("no controller found, isgnore isulad_cgfsng_payload_delegate_controllers"); ++ return true; ++ } ++#endif ++ + return __cgfsng_delegate_controllers(ops, ops->container_cgroup); + } + +@@ -3041,8 +3083,12 @@ static int cg_unified_init(struct cgroup_ops *ops, bool relative, + delegatable = cg_unified_get_controllers(subtree_path); + if (!delegatable) + delegatable = cg_unified_make_empty_controller(); +- if (!delegatable[0]) ++ if (!delegatable[0]) { + TRACE("No controllers are enabled for delegation"); ++#ifdef HAVE_ISULAD ++ ops->no_controller = true; ++#endif ++ } + + /* TODO: If the user requested specific controllers via lxc.cgroup.use + * we should verify here. The reason I'm not doing it right is that I'm +-- +2.25.1 + diff --git a/lxc.spec b/lxc.spec index 0d71de97e157ba608e06ba4933d7d3d4d81351a5..9d8315f6b8852a40f9f9c279851056e6e53bce85 100644 --- a/lxc.spec +++ b/lxc.spec @@ -1,4 +1,4 @@ -%global _release 2022052101 +%global _release 2022052301 Name: lxc Version: 4.0.3 @@ -50,6 +50,7 @@ Patch0039: 0039-fix-bug-of-memory-free.patch Patch0040: 0040-refactor-the-way-to-convert-selinux-label-to-shared.path Patch0041: 0041-do-not-free-the-pointer-returned-by-dirname.patch Patch0042: 0042-add-x-permission-when-create-directory.patch +Patch0043: 0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch BuildRequires: systemd-units git libtool graphviz docbook2X doxygen chrpath BuildRequires: pkgconfig(libseccomp) @@ -221,6 +222,12 @@ make check %{_mandir}/*/man7/%{name}* %changelog +* Mon May 23 2022 wangfengtu - 4.0.3-2022052301 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: do not operate playload and attach cgroup if no controller found + * Sat May 21 2022 wangfengtu - 4.0.3-2022052101 - Type:bugfix - ID:NA diff --git a/series.conf b/series.conf index 7c6011f61f8a46766e2b7f43ef2e48280c24f194..00d07d0bad247d70bd08e89647c8ffaf712f8f15 100644 --- a/series.conf +++ b/series.conf @@ -39,3 +39,5 @@ 0039-fix-bug-of-memory-free.patch 0040-refactor-the-way-to-convert-selinux-label-to-shared.path 0041-do-not-free-the-pointer-returned-by-dirname.patch +0042-add-x-permission-when-create-directory.patch +0043-do-not-operate-playload-and-attach-cgroup-if-no-cont.patch