mirror of https://github.com/containers/podman.git
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>
This commit is contained in:
parent
b6c279be22
commit
92dce3e2fe
|
@ -1021,9 +1021,9 @@ func (c *Container) exportCheckpoint(options ContainerCheckpointOptions) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) checkpointRestoreSupported() error {
|
func (c *Container) checkpointRestoreSupported(version int) error {
|
||||||
if !criu.CheckForCriu() {
|
if !criu.CheckForCriu(version) {
|
||||||
return errors.Errorf("checkpoint/restore requires at least CRIU %d", criu.MinCriuVersion)
|
return errors.Errorf("checkpoint/restore requires at least CRIU %d", version)
|
||||||
}
|
}
|
||||||
if !c.ociRuntime.SupportsCheckpoint() {
|
if !c.ociRuntime.SupportsCheckpoint() {
|
||||||
return errors.Errorf("configured runtime does not support checkpoint/restore")
|
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 {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1136,7 +1136,7 @@ func (c *Container) importPreCheckpoint(input string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) restore(ctx context.Context, options ContainerCheckpointOptions) (retErr 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ const MinCriuVersion = 31100
|
||||||
|
|
||||||
// CheckForCriu uses CRIU's go bindings to check if the CRIU
|
// CheckForCriu uses CRIU's go bindings to check if the CRIU
|
||||||
// binary exists and if it at least the version Podman needs.
|
// binary exists and if it at least the version Podman needs.
|
||||||
func CheckForCriu() bool {
|
func CheckForCriu(version int) bool {
|
||||||
c := criu.MakeCriu()
|
c := criu.MakeCriu()
|
||||||
result, err := c.IsCriuAtLeast(MinCriuVersion)
|
result, err := c.IsCriuAtLeast(version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ var _ = Describe("Podman checkpoint", func() {
|
||||||
Skip("OCI runtime does not support checkpoint/restore")
|
Skip("OCI runtime does not support checkpoint/restore")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !criu.CheckForCriu() {
|
if !criu.CheckForCriu(criu.MinCriuVersion) {
|
||||||
Skip("CRIU is missing or too old.")
|
Skip("CRIU is missing or too old.")
|
||||||
}
|
}
|
||||||
// Only Fedora 29 and newer has a new enough selinux-policy and
|
// Only Fedora 29 and newer has a new enough selinux-policy and
|
||||||
|
|
Loading…
Reference in New Issue