Skip to content

Commit

Permalink
vm/gce: add support GCE VMs
Browse files Browse the repository at this point in the history
  • Loading branch information
dvyukov committed Oct 6, 2016
1 parent 2bdb521 commit 83374d7
Show file tree
Hide file tree
Showing 5 changed files with 480 additions and 27 deletions.
35 changes: 22 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Config struct {
// "namespace": create a new namespace for fuzzer using CLONE_NEWNS/CLONE_NEWNET/CLONE_NEWPID/etc,
// requires building kernel with CONFIG_NAMESPACES, CONFIG_UTS_NS, CONFIG_USER_NS, CONFIG_PID_NS and CONFIG_NET_NS.

Machine_Type string // GCE machine type (e.g. "n1-highcpu-2")

Cover bool // use kcov coverage (default: true)
Leak bool // do memory leak checking

Expand Down Expand Up @@ -116,6 +118,11 @@ func parse(data []byte) (*Config, map[int]bool, []*regexp.Regexp, error) {
return nil, nil, nil, fmt.Errorf("specify at least 1 adb device")
}
cfg.Count = len(cfg.Devices)
case "gce":
if cfg.Machine_Type == "" {
return nil, nil, nil, fmt.Errorf("machine_type parameter is empty (required for gce)")
}
fallthrough
default:
if cfg.Count <= 0 || cfg.Count > 1000 {
return nil, nil, nil, fmt.Errorf("invalid config param count: %v, want (1, 1000]", cfg.Count)
Expand Down Expand Up @@ -243,19 +250,20 @@ func CreateVMConfig(cfg *Config, index int) (*vm.Config, error) {
return nil, fmt.Errorf("failed to create instance temp dir: %v", err)
}
vmCfg := &vm.Config{
Name: fmt.Sprintf("%v-%v", cfg.Type, index),
Index: index,
Workdir: workdir,
Bin: cfg.Bin,
Kernel: cfg.Kernel,
Cmdline: cfg.Cmdline,
Image: cfg.Image,
Initrd: cfg.Initrd,
Sshkey: cfg.Sshkey,
Executor: filepath.Join(cfg.Syzkaller, "bin", "syz-executor"),
Cpu: cfg.Cpu,
Mem: cfg.Mem,
Debug: cfg.Debug,
Name: fmt.Sprintf("%v-%v", cfg.Type, index),
Index: index,
Workdir: workdir,
Bin: cfg.Bin,
Kernel: cfg.Kernel,
Cmdline: cfg.Cmdline,
Image: cfg.Image,
Initrd: cfg.Initrd,
Sshkey: cfg.Sshkey,
Executor: filepath.Join(cfg.Syzkaller, "bin", "syz-executor"),
Cpu: cfg.Cpu,
Mem: cfg.Mem,
Debug: cfg.Debug,
MachineType: cfg.Machine_Type,
}
if len(cfg.Devices) != 0 {
vmCfg.Device = cfg.Devices[index]
Expand Down Expand Up @@ -293,6 +301,7 @@ func checkUnknownFields(data []byte) (string, error) {
"Disable_Syscalls",
"Suppressions",
"Initrd",
"Machine_Type",
}
f := make(map[string]interface{})
if err := json.Unmarshal(data, &f); err != nil {
Expand Down
1 change: 1 addition & 0 deletions syz-manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/google/syzkaller/sys"
"github.com/google/syzkaller/vm"
_ "github.com/google/syzkaller/vm/adb"
_ "github.com/google/syzkaller/vm/gce"
_ "github.com/google/syzkaller/vm/kvm"
_ "github.com/google/syzkaller/vm/local"
_ "github.com/google/syzkaller/vm/qemu"
Expand Down
1 change: 1 addition & 0 deletions tools/syz-repro/repro.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/google/syzkaller/report"
"github.com/google/syzkaller/vm"
_ "github.com/google/syzkaller/vm/adb"
_ "github.com/google/syzkaller/vm/gce"
_ "github.com/google/syzkaller/vm/kvm"
_ "github.com/google/syzkaller/vm/qemu"
)
Expand Down
Loading

0 comments on commit 83374d7

Please sign in to comment.