[Devel] [libvzctl PATCH] cgrop: get process CT ID from its status
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Mon Aug 21 11:20:40 MSK 2017
Taking CT ID from /proc/<pid>/cgroup is not reliable.
For instance when "shutdown" in called inside CT, CTs init has the following
cgroup content:
root at skinsbursky-vz7:~/stub_proxy_fs# cat /proc/397761/cgroup
16:perf_event:/
15:cpuset:/
14:hugetlb:/
13:pids:/
10:ve:/
8:devices:/
7:freezer:/
6:net_prio,net_cls:/
5:cpuacct,cpu:/
4:name=systemd:/
3:beancounter:/
2:memory:/
1:blkio:/
This is because process exits cgroups before killing all it's descendants.
This leads to failing "cg_env_check_init_pid" (processes "CT ID" doesn't match
cached CT ID), leading in turn to skipping SUNRPC suppress, thus breaking CT
killing with unreachable NFS.
This patch changes the logic to take envID from /proc/pid/status, which
contains real VE ID, but not cgroup.
https://jira.sw.ru/browse/PSBM-70402
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
lib/cgroup.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/cgroup.c b/lib/cgroup.c
index 843e197..cb521b6 100644
--- a/lib/cgroup.c
+++ b/lib/cgroup.c
@@ -798,11 +798,11 @@ int cg_env_set_net_classid(const char *ctid, unsigned int classid)
static int cg_env_check_init_pid(const char *ctid, pid_t pid)
{
- int ret, n;
+ int ret;
FILE *fp;
char buf[4096];
- snprintf(buf, sizeof(buf), "/proc/%d/cgroup", pid);
+ snprintf(buf, sizeof(buf), "/proc/%d/status", pid);
fp = fopen(buf, "r");
if (fp == NULL) {
if (errno == ENOENT)
@@ -813,7 +813,7 @@ static int cg_env_check_init_pid(const char *ctid, pid_t pid)
ret = 1;
while (fgets(buf, sizeof(buf), fp)) {
- if (sscanf(buf, "%d:ve:/%s", &n, buf) != 2)
+ if (sscanf(buf, "envID: %s", buf) != 1)
continue;
if (!strcmp(ctid, buf))
More information about the Devel
mailing list