summaryrefslogtreecommitdiff
path: root/pkg/checkpoint/crutils
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2021-07-12 11:43:45 +0000
committerAdrian Reber <adrian@lisas.de>2021-07-27 16:10:44 +0200
commiteb94467780eab06a452586c9751fc4f571d9e089 (patch)
tree7fd60bf5369ae2da6c4661ba2c20e80267abf0c5 /pkg/checkpoint/crutils
parent3375cbb198c74e895624eada148edff514b64d35 (diff)
downloadpodman-eb94467780eab06a452586c9751fc4f571d9e089.tar.gz
podman-eb94467780eab06a452586c9751fc4f571d9e089.tar.bz2
podman-eb94467780eab06a452586c9751fc4f571d9e089.zip
Support checkpoint/restore with pods
This adds support to checkpoint containers out of pods and restore container into pods. It is only possible to restore a container into a pod if it has been checkpointed out of pod. It is also not possible to restore a non pod container into a pod. The main reason this does not work is the PID namespace. If a non pod container is being restored in a pod with a shared PID namespace, at least one process in the restored container uses PID 1 which is already in use by the infrastructure container. If someone tries to restore container from a pod with a shared PID namespace without a shared PID namespace it will also fail because the resulting PID namespace will not have a PID 1. Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'pkg/checkpoint/crutils')
-rw-r--r--pkg/checkpoint/crutils/checkpoint_restore_utils.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/checkpoint/crutils/checkpoint_restore_utils.go b/pkg/checkpoint/crutils/checkpoint_restore_utils.go
index 53ff55865..3b77368bb 100644
--- a/pkg/checkpoint/crutils/checkpoint_restore_utils.go
+++ b/pkg/checkpoint/crutils/checkpoint_restore_utils.go
@@ -1,6 +1,7 @@
package crutils
import (
+ "bytes"
"io"
"os"
"os/exec"
@@ -189,3 +190,13 @@ func CRRuntimeSupportsCheckpointRestore(runtimePath string) bool {
}
return false
}
+
+// CRRuntimeSupportsCheckpointRestore tests if the runtime at 'runtimePath'
+// supports restoring into existing Pods. The runtime needs to support
+// the CRIU option --lsm-mount-context and the existence of this is checked
+// by this function. In addition it is necessary to at least have CRIU 3.16.
+func CRRuntimeSupportsPodCheckpointRestore(runtimePath string) bool {
+ cmd := exec.Command(runtimePath, "restore", "--lsm-mount-context")
+ out, _ := cmd.CombinedOutput()
+ return bytes.Contains(out, []byte("flag needs an argument"))
+}