From af643baa328ae3d4b7076054bba648c4b8bf8056 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 2 Jun 2017 20:09:00 +0200 Subject: vm: overhaul VM infrastructure currently has several problems: - Config struct is complete mess with a superset of params for all VM types - verification of Config is mess spread across several places - there is no place where VM code could do global initialization like creating GCE connection, uploading GCE image to GCS, matching adb devices with consoles, etc - it hard to add private VM implementations such impl would need to add code to config package which would lead to constant merge conflicts - interface for VM implementation is mixed with interface for VM users this does not allow to provide best interface for both of them - there is no way to add common code for all VM implementations This change solves these problems by: - splitting VM interface for users (vm package) and VM interface for VM implementations (vmimpl pacakge), this in turn allows to add common code - adding Pool concept that allows to do global initialization and config checking at the right time - decoupling manager config from VM-specific config each VM type now defines own config Note: manager configs need to be changed after this change: VM-specific parts are moved to own "vm" subobject. Note: this change also drops "local" VM type. Its story was long unclear and there is now syz-stress which solves the same problem. --- vm/vmimpl/util.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 vm/vmimpl/util.go (limited to 'vm/vmimpl/util.go') diff --git a/vm/vmimpl/util.go b/vm/vmimpl/util.go new file mode 100644 index 000000000..f80de8ab1 --- /dev/null +++ b/vm/vmimpl/util.go @@ -0,0 +1,19 @@ +// Copyright 2017 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package vmimpl + +import ( + "time" +) + +// Sleep for d. +// If shutdown is in progress, return false prematurely. +func SleepInterruptible(d time.Duration) bool { + select { + case <-time.After(d): + return true + case <-Shutdown: + return false + } +} -- cgit mrf-deployment