Add missing criu symbols to criu_unsupported.go

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
This commit is contained in:
Doug Rabson 2022-05-08 12:51:50 +01:00
parent 3176b3fe01
commit 5902905970
3 changed files with 52 additions and 43 deletions

View File

@ -1,51 +1,8 @@
//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"
)
// 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
}
func GetCriuVestion() (int, error) {
c := criu.MakeCriu()
return c.GetCriuVersion()
}
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
}

44
pkg/criu/criu_linux.go Normal file
View File

@ -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()
}

View File

@ -3,6 +3,14 @@
package criu
func CheckForCriu(version int) bool {
return false
}
func MemTrack() bool {
return false
}
func GetCriuVestion() (int, error) {
return MinCriuVersion, nil
}