From 53c2e8ad91fd5f64989a4e6a923926990130b5cd Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 23 Jul 2024 14:13:28 +0200 Subject: vmimpl: refactor VM type registration Pass Type struct directly during registration. This allows to add additional optional parameters to VM types without changing all VM implementations. We we will need to add SupportsSnapshots flag and one flag to resolve #5028. With this change it will be possible to add "SupportsSnapshots: true" to just one VM type implemenetation. --- vm/vmimpl/vmimpl.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'vm/vmimpl/vmimpl.go') diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go index ce2a0dfb6..ac38a6634 100644 --- a/vm/vmimpl/vmimpl.go +++ b/vm/vmimpl/vmimpl.go @@ -124,15 +124,14 @@ func (err InfraError) InfraError() (string, []byte) { } // Register registers a new VM type within the package. -func Register(typ string, ctor ctorFunc, allowsOvercommit bool) { - Types[typ] = Type{ - Ctor: ctor, - Overcommit: allowsOvercommit, - } +func Register(typ string, desc Type) { + Types[typ] = desc } type Type struct { - Ctor ctorFunc + Ctor ctorFunc + // It's possible to create out-of-thin-air instances of this type. + // Out-of-thin-air instances are used by syz-ci for image testing, patch testing, bisection, etc. Overcommit bool } -- cgit mrf-deployment