diff options
author | Doug Rabson <dfr@rabson.org> | 2022-05-08 12:51:50 +0100 |
---|---|---|
committer | Doug Rabson <dfr@rabson.org> | 2022-06-27 12:57:44 +0100 |
commit | 5902905970b56ad843311cba32f803404819f592 (patch) | |
tree | 3f3548077218c336dd65e376144394df43a9f78a /pkg/criu/criu_linux.go | |
parent | 3176b3fe011aa3323ba192e90efe516d0701e46e (diff) | |
download | podman-5902905970b56ad843311cba32f803404819f592.tar.gz podman-5902905970b56ad843311cba32f803404819f592.tar.bz2 podman-5902905970b56ad843311cba32f803404819f592.zip |
Add missing criu symbols to criu_unsupported.go
[NO NEW TESTS NEEDED]
Signed-off-by: Doug Rabson <dfr@rabson.org>
Diffstat (limited to 'pkg/criu/criu_linux.go')
-rw-r--r-- | pkg/criu/criu_linux.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/pkg/criu/criu_linux.go b/pkg/criu/criu_linux.go new file mode 100644 index 000000000..1d4c0a782 --- /dev/null +++ b/pkg/criu/criu_linux.go @@ -0,0 +1,44 @@ +//go:build linux +// +build linux + +package criu + +import ( + "github.com/checkpoint-restore/go-criu/v5" + "github.com/checkpoint-restore/go-criu/v5/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) bool { + c := criu.MakeCriu() + result, err := c.IsCriuAtLeast(version) + if err != nil { + return false + } + return result +} + +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 GetCriuVestion() (int, error) { + c := criu.MakeCriu() + return c.GetCriuVersion() +} |