[CRIU] [PATCH] freezer: don't catch kernel threads

Andrey Vagin avagin at openvz.org
Wed Oct 14 08:40:38 PDT 2015


From: Andrew Vagin <avagin at virtuozzo.org>

OpenVZ creates per-container kernel threads and they live in
container's cgroups. CRIU should skip these threads, it's impossiable to
get any state of them.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.org>
Signed-off-by: Andrew Vagin <avagin at openvz.org>
---
 seize.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/seize.c b/seize.c
index fd11f5c..20c0349 100644
--- a/seize.c
+++ b/seize.c
@@ -1,6 +1,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -146,6 +147,14 @@ static int freeze_processes(void)
 				continue;
 
 			if (seize_catch_task(pid) && state == frozen) {
+				char buf[] = "/proc/XXXXXXXXXX/exe";
+				struct stat st;
+
+				/* skip kernel threads */
+				snprintf(buf, sizeof(buf), "/proc/%d/exe", pid);
+				if (stat(buf, &st) == -1 && errno == ENOENT)
+					continue;
+
 				/* fails when meets a zombie */
 				fclose(f);
 				goto err;
-- 
2.4.3



More information about the CRIU mailing list