From 757d26edba7d7de8c564a87a262a0b1321ddf804 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 14 Jun 2023 14:58:25 +0200 Subject: all: support swap feature on Linux If the feature is supported on the device, allocate a 128MB swap file after VM boot and activate it. --- pkg/host/features_linux.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'pkg/host/features_linux.go') diff --git a/pkg/host/features_linux.go b/pkg/host/features_linux.go index 142e58e3b..408e219eb 100644 --- a/pkg/host/features_linux.go +++ b/pkg/host/features_linux.go @@ -5,6 +5,7 @@ package host import ( "fmt" + "os/exec" "regexp" "runtime" "runtime/debug" @@ -37,6 +38,7 @@ func init() { checkFeature[FeatureVhciInjection] = checkVhciInjection checkFeature[FeatureWifiEmulation] = checkWifiEmulation checkFeature[Feature802154Emulation] = check802154Emulation + checkFeature[FeatureSwap] = checkSwap } func checkCoverage() string { @@ -287,6 +289,16 @@ func check802154Emulation() string { return "" } +func checkSwap() string { + if err := osutil.IsAccessible("/proc/swaps"); err != nil { + return err.Error() + } + if _, err := exec.LookPath("mkswap"); err != nil { + return "mkswap is not available" + } + return "" +} + func requireKernel(x, y int) string { info := new(unix.Utsname) if err := unix.Uname(info); err != nil { -- cgit mrf-deployment