mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

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>
24 lines
582 B
Go
24 lines
582 B
Go
package criu
|
|
|
|
import (
|
|
"github.com/checkpoint-restore/go-criu/v5"
|
|
)
|
|
|
|
// MinCriuVersion for Podman at least CRIU 3.11 is required
|
|
const MinCriuVersion = 31100
|
|
|
|
// PodCriuVersion is the version of CRIU needed for
|
|
// checkpointing and restoring containers out of and into Pods.
|
|
const PodCriuVersion = 31600
|
|
|
|
// CheckForCriu uses CRIU's go bindings to check if the CRIU
|
|
// binary exists and if it at least the version Podman needs.
|
|
func CheckForCriu(version int) bool {
|
|
c := criu.MakeCriu()
|
|
result, err := c.IsCriuAtLeast(version)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return result
|
|
}
|