Added support for specifying the number of cores as `cores` to vmware-common.
This commit is contained in:
parent
32f226eda0
commit
062c62eed8
|
@ -14,6 +14,7 @@ type HWConfig struct {
|
||||||
// cpu information
|
// cpu information
|
||||||
CpuCount int `mapstructure:"cpus"`
|
CpuCount int `mapstructure:"cpus"`
|
||||||
MemorySize int `mapstructure:"memory"`
|
MemorySize int `mapstructure:"memory"`
|
||||||
|
CoreCount int `mapstructure:"cores"`
|
||||||
|
|
||||||
// network type and adapter
|
// network type and adapter
|
||||||
Network string `mapstructure:"network"`
|
Network string `mapstructure:"network"`
|
||||||
|
@ -40,6 +41,11 @@ func (c *HWConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
errs = append(errs, fmt.Errorf("An invalid amount of memory was specified (memory < 0): %d", c.MemorySize))
|
errs = append(errs, fmt.Errorf("An invalid amount of memory was specified (memory < 0): %d", c.MemorySize))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hardware and cpu options
|
||||||
|
if c.CoreCount < 0 {
|
||||||
|
errs = append(errs, fmt.Errorf("An invalid number of cores was specified (cores < 0): %d", c.CoreCount))
|
||||||
|
}
|
||||||
|
|
||||||
// Peripherals
|
// Peripherals
|
||||||
if !c.Sound {
|
if !c.Sound {
|
||||||
c.Sound = false
|
c.Sound = false
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
func testHWConfig() *HWConfig {
|
func testHWConfig() *HWConfig {
|
||||||
return &HWConfig{
|
return &HWConfig{
|
||||||
CpuCount: 1,
|
CpuCount: 1,
|
||||||
|
CoreCount: 1,
|
||||||
MemorySize: 512,
|
MemorySize: 512,
|
||||||
|
|
||||||
Sound: true,
|
Sound: true,
|
||||||
|
@ -26,6 +27,10 @@ func TestHWConfigPrepare(t *testing.T) {
|
||||||
t.Errorf("bad cpu count: %d", c.CpuCount)
|
t.Errorf("bad cpu count: %d", c.CpuCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.CoreCount < 0 {
|
||||||
|
t.Errorf("bad core count: %d", c.CoreCount)
|
||||||
|
}
|
||||||
|
|
||||||
if c.MemorySize < 0 {
|
if c.MemorySize < 0 {
|
||||||
t.Errorf("bad memory size: %d", c.MemorySize)
|
t.Errorf("bad memory size: %d", c.MemorySize)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue