Files
podman/pkg/criu/criu_linux.go
Paul Holzinger ab502fc5c4 criu: return error when checking for min version
There is weird issue #18856 which causes the version check to fail.
Return the underlying error in these cases so we can see it and debug
it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-12 15:29:21 +02:00

51 lines
1021 B
Go

//go:build linux
// +build linux
package criu
import (
"fmt"
"github.com/checkpoint-restore/go-criu/v6"
"github.com/checkpoint-restore/go-criu/v6/rpc"
"google.golang.org/protobuf/proto"
)
// 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) error {
c := criu.MakeCriu()
criuVersion, err := c.GetCriuVersion()
if err != nil {
return fmt.Errorf("failed to check for criu version: %w", err)
}
if criuVersion >= version {
return nil
}
return fmt.Errorf("checkpoint/restore requires at least CRIU %d, current version is %d", version, criuVersion)
}
func MemTrack() bool {
features, err := criu.MakeCriu().FeatureCheck(
&rpc.CriuFeatures{
MemTrack: proto.Bool(true),
},
)
if err != nil {
return false
}
if features == nil || features.MemTrack == nil {
return false
}
return *features.MemTrack
}
func GetCriuVersion() (int, error) {
c := criu.MakeCriu()
return c.GetCriuVersion()
}