diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-06-14 14:58:25 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-06-15 11:49:04 +0200 |
| commit | 757d26edba7d7de8c564a87a262a0b1321ddf804 (patch) | |
| tree | f78b5e053c0a61ef2771e130af410ee7ee1d40da /pkg/host/features_linux.go | |
| parent | 90d4044eae0123561d6cf2f667a4bc3357d93e7a (diff) | |
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.
Diffstat (limited to 'pkg/host/features_linux.go')
| -rw-r--r-- | pkg/host/features_linux.go | 12 |
1 files changed, 12 insertions, 0 deletions
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 { |
