From 511d0732d71c04eb6feda0e21f36f21f37702e60 Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Mon, 4 Nov 2024 19:57:30 +0000 Subject: [PATCH] seize: enable support for frozen containers Container runtimes like CRI-O and containerd utilize the freezer cgroup to create a consistent snapshot of container rootfs changes. In this case, the container is frozen before invoking CRIU. Once CRIU successfully completes, a copy of the container rootfs diff is saved, and then the container is unfrozen. To enable GPU checkpointing support with these runtimes, we need to unfreeze the cgroup and restore it to its original state at the end. Fixes: #2508 Signed-off-by: Radostin Stoyanov --- criu/seize.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/criu/seize.c b/criu/seize.c index edeb57cc8a..b8e070c00e 100644 --- a/criu/seize.c +++ b/criu/seize.c @@ -509,6 +509,7 @@ static int check_freezer_cgroup(void) { enum freezer_state state = THAWED; int fd; + int exit_code = -1; BUG_ON(!freeze_cgroup_disabled); @@ -517,17 +518,22 @@ static int check_freezer_cgroup(void) return -1; state = get_freezer_state(fd); - close(fd); if (state == FREEZER_ERROR) { - return -1; + goto err; } + origin_freezer_state = state == FREEZING ? FROZEN : state; + if (state != THAWED) { - pr_err("One or more plugins are incompatible with the freezer cgroup in the FROZEN state.\n"); - return -1; + pr_warn("unfreezing cgroup for plugin compatibility\n"); + if (freezer_write_state(fd, THAWED)) + goto err; } - return 0; + exit_code = 0; +err: + close(fd); + return exit_code; } static int freeze_processes(void)