示例#1
0
func CreateVMConfig(cfg *Config, index int) (*vm.Config, error) {
	if index < 0 || index >= cfg.Count {
		return nil, fmt.Errorf("invalid VM index %v (count %v)", index, cfg.Count)
	}
	workdir, err := fileutil.ProcessTempDir(cfg.Workdir)
	if err != nil {
		return nil, fmt.Errorf("failed to create instance temp dir: %v", err)
	}
	vmCfg := &vm.Config{
		Name:        fmt.Sprintf("%v-%v-%v", cfg.Type, cfg.Name, index),
		Index:       index,
		Workdir:     workdir,
		Bin:         cfg.Bin,
		BinArgs:     cfg.Bin_Args,
		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]
	}
	return vmCfg, nil
}
示例#2
0
func CreateVMConfig(cfg *Config) (*vm.Config, error) {
	workdir, index, err := fileutil.ProcessTempDir(cfg.Workdir)
	if err != nil {
		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,
		Sshkey:     cfg.Sshkey,
		ConsoleDev: cfg.ConsoleDev,
		Cpu:        cfg.Cpu,
		Mem:        cfg.Mem,
		Debug:      cfg.Debug,
	}
	return vmCfg, nil
}