diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2026-01-27 12:31:49 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2026-02-17 14:55:28 +0000 |
| commit | 72e0f1b67bdd3f89cf51e89a3c17dd4a7cb575f1 (patch) | |
| tree | c7e29b0a56ad5f81ed82f2bf47531c0d0b52812d /pkg | |
| parent | 21b4b9b6789f7b255eb115d3757e82652bb33eaa (diff) | |
all: add a DumpMemory feature
On Linux, verify that makedumpfile and the second kernel are present,
then set up a kernel to be used on panic.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/flatrpc/flatrpc.fbs | 1 | ||||
| -rw-r--r-- | pkg/flatrpc/flatrpc.go | 3 | ||||
| -rw-r--r-- | pkg/flatrpc/flatrpc.h | 9 | ||||
| -rw-r--r-- | pkg/mgrconfig/config.go | 3 | ||||
| -rw-r--r-- | pkg/rpcserver/rpcserver.go | 4 | ||||
| -rw-r--r-- | pkg/rpcserver/rpcserver_test.go | 14 | ||||
| -rw-r--r-- | pkg/runtest/run_test.go | 3 | ||||
| -rw-r--r-- | pkg/vminfo/features.go | 4 | ||||
| -rw-r--r-- | pkg/vminfo/vminfo.go | 1 |
9 files changed, 38 insertions, 4 deletions
diff --git a/pkg/flatrpc/flatrpc.fbs b/pkg/flatrpc/flatrpc.fbs index 3876af965..b8542bf9e 100644 --- a/pkg/flatrpc/flatrpc.fbs +++ b/pkg/flatrpc/flatrpc.fbs @@ -34,6 +34,7 @@ enum Feature : uint64 (bit_flags) { LRWPANEmulation, // 802.15.4 standard BinFmtMisc, Swap, + MemoryDump, } table ConnectHelloRaw { diff --git a/pkg/flatrpc/flatrpc.go b/pkg/flatrpc/flatrpc.go index 439d06b67..9f86b077a 100644 --- a/pkg/flatrpc/flatrpc.go +++ b/pkg/flatrpc/flatrpc.go @@ -62,6 +62,7 @@ const ( FeatureLRWPANEmulation Feature = 524288 FeatureBinFmtMisc Feature = 1048576 FeatureSwap Feature = 2097152 + FeatureMemoryDump Feature = 4194304 ) var EnumNamesFeature = map[Feature]string{ @@ -87,6 +88,7 @@ var EnumNamesFeature = map[Feature]string{ FeatureLRWPANEmulation: "LRWPANEmulation", FeatureBinFmtMisc: "BinFmtMisc", FeatureSwap: "Swap", + FeatureMemoryDump: "MemoryDump", } var EnumValuesFeature = map[string]Feature{ @@ -112,6 +114,7 @@ var EnumValuesFeature = map[string]Feature{ "LRWPANEmulation": FeatureLRWPANEmulation, "BinFmtMisc": FeatureBinFmtMisc, "Swap": FeatureSwap, + "MemoryDump": FeatureMemoryDump, } func (v Feature) String() string { diff --git a/pkg/flatrpc/flatrpc.h b/pkg/flatrpc/flatrpc.h index aa386f7dc..6807434e6 100644 --- a/pkg/flatrpc/flatrpc.h +++ b/pkg/flatrpc/flatrpc.h @@ -159,12 +159,13 @@ enum class Feature : uint64_t { LRWPANEmulation = 524288ULL, BinFmtMisc = 1048576ULL, Swap = 2097152ULL, + MemoryDump = 4194304ULL, NONE = 0, - ANY = 4194303ULL + ANY = 8388607ULL }; FLATBUFFERS_DEFINE_BITMASK_OPERATORS(Feature, uint64_t) -inline const Feature (&EnumValuesFeature())[22] { +inline const Feature (&EnumValuesFeature())[23] { static const Feature values[] = { Feature::Coverage, Feature::Comparisons, @@ -187,7 +188,8 @@ inline const Feature (&EnumValuesFeature())[22] { Feature::WifiEmulation, Feature::LRWPANEmulation, Feature::BinFmtMisc, - Feature::Swap + Feature::Swap, + Feature::MemoryDump }; return values; } @@ -216,6 +218,7 @@ inline const char *EnumNameFeature(Feature e) { case Feature::LRWPANEmulation: return "LRWPANEmulation"; case Feature::BinFmtMisc: return "BinFmtMisc"; case Feature::Swap: return "Swap"; + case Feature::MemoryDump: return "MemoryDump"; default: return ""; } } diff --git a/pkg/mgrconfig/config.go b/pkg/mgrconfig/config.go index 45145243c..db6e10ba8 100644 --- a/pkg/mgrconfig/config.go +++ b/pkg/mgrconfig/config.go @@ -225,6 +225,9 @@ type Config struct { // More details can be found in pkg/asset/config.go. AssetStorage *asset.Config `json:"asset_storage"` + // MemoryDump enables feature to dump memory of the target VM on crash. + MemoryDump bool `json:"memory_dump"` + // Experimental options. Experimental Experimental diff --git a/pkg/rpcserver/rpcserver.go b/pkg/rpcserver/rpcserver.go index 04c5d877f..385c0350d 100644 --- a/pkg/rpcserver/rpcserver.go +++ b/pkg/rpcserver/rpcserver.go @@ -162,6 +162,9 @@ func New(cfg *RemoteConfig) (Server, error) { if !cfg.Experimental.RemoteCover { features &= ^flatrpc.FeatureExtraCoverage } + if !cfg.MemoryDump { + features &= ^flatrpc.FeatureMemoryDump + } return newImpl(&Config{ Config: vminfo.Config{ Target: cfg.Target, @@ -170,6 +173,7 @@ func New(cfg *RemoteConfig) (Server, error) { Syscalls: cfg.Syscalls, Debug: cfg.Debug, Cover: cfg.Cover, + MemoryDump: cfg.MemoryDump, Sandbox: sandbox, SandboxArg: cfg.SandboxArg, }, diff --git a/pkg/rpcserver/rpcserver_test.go b/pkg/rpcserver/rpcserver_test.go index 429b275ac..86dddcf76 100644 --- a/pkg/rpcserver/rpcserver_test.go +++ b/pkg/rpcserver/rpcserver_test.go @@ -72,6 +72,20 @@ func TestNew(t *testing.T) { }, expectedServCheck: func(srv Server) { s := srv.(*server) + assert.Equal(t, s.cfg.Config.Features, + flatrpc.AllFeatures&(^flatrpc.FeatureExtraCoverage)&(^flatrpc.FeatureMemoryDump)) + assert.Nil(t, s.serv) + }, + }, + { + name: "memory dump enabled", + modifyCfg: func() *mgrconfig.Config { + cfg := defaultCfg + cfg.MemoryDump = true + return &cfg + }, + expectedServCheck: func(srv Server) { + s := srv.(*server) assert.Equal(t, s.cfg.Config.Features, flatrpc.AllFeatures&(^flatrpc.FeatureExtraCoverage)) assert.Nil(t, s.serv) }, diff --git a/pkg/runtest/run_test.go b/pkg/runtest/run_test.go index 97c31d6f9..14c643bba 100644 --- a/pkg/runtest/run_test.go +++ b/pkg/runtest/run_test.go @@ -106,7 +106,8 @@ func test(t *testing.T, sysTarget *targets.Target) { flatrpc.FeatureWifiEmulation | flatrpc.FeatureLRWPANEmulation | flatrpc.FeatureBinFmtMisc | - flatrpc.FeatureSwap + flatrpc.FeatureSwap | + flatrpc.FeatureMemoryDump for feat, name := range flatrpc.EnumNamesFeature { if features&feat != want&feat { t.Errorf("expect feature %v to be %v, but it is %v", diff --git a/pkg/vminfo/features.go b/pkg/vminfo/features.go index 6c4d6ae6d..34cf995ae 100644 --- a/pkg/vminfo/features.go +++ b/pkg/vminfo/features.go @@ -115,6 +115,9 @@ func (ctx *checkContext) finishFeatures(featureInfos []*flatrpc.FeatureInfo) (Fe if feat := features[flatrpc.FeatureCoverage]; ctx.cfg.Cover && !feat.Enabled { return features, fmt.Errorf("coverage is not supported: %v", feat.Reason) } + if feat := features[flatrpc.FeatureMemoryDump]; ctx.cfg.MemoryDump && !feat.Enabled { + return features, fmt.Errorf("memory dump is not supported: %v", feat.Reason) + } return features, nil } @@ -171,6 +174,7 @@ func (ctx *checkContext) featureToFlags(feat flatrpc.Feature) (flatrpc.ExecEnv, case flatrpc.FeatureLRWPANEmulation: case flatrpc.FeatureBinFmtMisc: case flatrpc.FeatureSwap: + case flatrpc.FeatureMemoryDump: default: panic(fmt.Sprintf("unknown feature %v", flatrpc.EnumNamesFeature[feat])) } diff --git a/pkg/vminfo/vminfo.go b/pkg/vminfo/vminfo.go index 41fadf59a..f807ec9a0 100644 --- a/pkg/vminfo/vminfo.go +++ b/pkg/vminfo/vminfo.go @@ -51,6 +51,7 @@ type Config struct { Syscalls []int Debug bool Cover bool + MemoryDump bool Sandbox flatrpc.ExecEnv SandboxArg int64 } |
