diff options
author | Adrian Reber <areber@redhat.com> | 2021-07-08 15:24:31 +0000 |
---|---|---|
committer | Adrian Reber <adrian@lisas.de> | 2021-07-27 16:10:44 +0200 |
commit | 92dce3e2febc752434c08574cbb394545c7fef47 (patch) | |
tree | 953df6e4037b3e242a4090e070b348054537788d | |
parent | b6c279be2296ce32fbb36ba39bd948f93be9bede (diff) | |
download | podman-92dce3e2febc752434c08574cbb394545c7fef47.tar.gz podman-92dce3e2febc752434c08574cbb394545c7fef47.tar.bz2 podman-92dce3e2febc752434c08574cbb394545c7fef47.zip |
Prepare CRIU version check to work with multiple versions
The upcoming commit to support checkpointing out of Pods requires CRIU
3.16. This changes the CRIU version check to support checking for
different versions.
Signed-off-by: Adrian Reber <areber@redhat.com>
-rw-r--r-- | libpod/container_internal_linux.go | 10 | ||||
-rw-r--r-- | pkg/criu/criu.go | 4 | ||||
-rw-r--r-- | test/e2e/checkpoint_test.go | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index b69ad4105..e002f9a22 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1021,9 +1021,9 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error { return nil } -func (c *Container) checkpointRestoreSupported() error { - if !criu.CheckForCriu() { - return errors.Errorf("checkpoint/restore requires at least CRIU %d", criu.MinCriuVersion) +func (c *Container) checkpointRestoreSupported(version int) error { + if !criu.CheckForCriu(version) { + return errors.Errorf("checkpoint/restore requires at least CRIU %d", version) } if !c.ociRuntime.SupportsCheckpoint() { return errors.Errorf("configured runtime does not support checkpoint/restore") @@ -1032,7 +1032,7 @@ func (c *Container) checkpointRestoreSupported() error { } func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointOptions) error { - if err := c.checkpointRestoreSupported(); err != nil { + if err := c.checkpointRestoreSupported(criu.MinCriuVersion); err != nil { return err } @@ -1136,7 +1136,7 @@ func (c *Container) importPreCheckpoint(input string) error { } func (c *Container) restore(ctx context.Context, options ContainerCheckpointOptions) (retErr error) { - if err := c.checkpointRestoreSupported(); err != nil { + if err := c.checkpointRestoreSupported(criu.MinCriuVersion); err != nil { return err } diff --git a/pkg/criu/criu.go b/pkg/criu/criu.go index f4cce238a..763b0d2f7 100644 --- a/pkg/criu/criu.go +++ b/pkg/criu/criu.go @@ -9,9 +9,9 @@ const MinCriuVersion = 31100 // CheckForCriu uses CRIU's go bindings to check if the CRIU // binary exists and if it at least the version Podman needs. -func CheckForCriu() bool { +func CheckForCriu(version int) bool { c := criu.MakeCriu() - result, err := c.IsCriuAtLeast(MinCriuVersion) + result, err := c.IsCriuAtLeast(version) if err != nil { return false } diff --git a/test/e2e/checkpoint_test.go b/test/e2e/checkpoint_test.go index b5bbfcd5c..cbebffe81 100644 --- a/test/e2e/checkpoint_test.go +++ b/test/e2e/checkpoint_test.go @@ -46,7 +46,7 @@ var _ = Describe("Podman checkpoint", func() { Skip("OCI runtime does not support checkpoint/restore") } - if !criu.CheckForCriu() { + if !criu.CheckForCriu(criu.MinCriuVersion) { Skip("CRIU is missing or too old.") } // Only Fedora 29 and newer has a new enough selinux-policy and |