From 02832ca35ded902878eb2a3aa43a1235de5f8ac4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 25 Nov 2024 12:03:30 +0100 Subject: pkg/vminfo: refactor few things Use default nop implementation for most openbsd/netbsd methods. Move linux-specific vm type checks to linux code. Remove indirection for CheckFiles as we have for RequiredFiles. --- pkg/vminfo/linux.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'pkg/vminfo/linux.go') diff --git a/pkg/vminfo/linux.go b/pkg/vminfo/linux.go index 0f598515c..52f6982b2 100644 --- a/pkg/vminfo/linux.go +++ b/pkg/vminfo/linux.go @@ -13,9 +13,13 @@ import ( "sort" "strconv" "strings" + + "github.com/google/syzkaller/sys/targets" ) -type linux int +type linux struct { + vmType string +} func (linux) RequiredFiles() []string { return []string{ @@ -27,7 +31,7 @@ func (linux) RequiredFiles() []string { } } -func (linux) checkFiles() []string { +func (linux) CheckFiles() []string { return []string{ "/proc/version", "/proc/filesystems", @@ -42,7 +46,10 @@ func (linux) machineInfos() []machineInfoFunc { } } -func (linux) parseModules(files filesystem) ([]*KernelModule, error) { +func (linux linux) parseModules(files filesystem) ([]*KernelModule, error) { + if linux.vmType == targets.GVisor || linux.vmType == targets.Starnix { + return nil, nil + } var modules []*KernelModule re := regexp.MustCompile(`(\w+) ([0-9]+) .*(0[x|X][a-fA-F0-9]+)[^\n]*`) modulesText, _ := files.ReadFile("/proc/modules") -- cgit mrf-deployment