Merge pull request #8201 from brickstool/f-proxmox-cpu-type-support

[Proxmox] Add ability to select CPU type
This commit is contained in:
Adrien Delorme 2019-10-08 15:52:26 +02:00 committed by GitHub
commit 3aafba95dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

View File

@ -39,6 +39,7 @@ type Config struct {
Memory int `mapstructure:"memory"`
Cores int `mapstructure:"cores"`
CPUType string `mapstructure:"cpu_type"`
Sockets int `mapstructure:"sockets"`
OS string `mapstructure:"os"`
NICs []nicConfig `mapstructure:"network_adapters"`
@ -130,6 +131,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
log.Printf("Number of sockets %d is too small, using default: 1", c.Sockets)
c.Sockets = 1
}
if c.CPUType == "" {
log.Printf("CPU type not set, using default 'kvm64'")
c.CPUType = "kvm64"
}
if c.OS == "" {
log.Printf("OS not set, using default 'other'")
c.OS = "other"

View File

@ -90,6 +90,7 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) {
// Memory 0 is too small, using default: 512
// Number of cores 0 is too small, using default: 1
// Number of sockets 0 is too small, using default: 1
// CPU type not set, using default 'kvm64'
// OS not set, using default 'other'
// NIC 0 model not set, using default 'e1000'
// Disk 0 cache mode not set, using default 'none'
@ -105,6 +106,9 @@ func TestBasicExampleFromDocsIsValid(t *testing.T) {
if b.config.Sockets != 1 {
t.Errorf("Expected Sockets to be 1, got %d", b.config.Sockets)
}
if b.config.CPUType != "kvm64" {
t.Errorf("Expected CPU type to be 'kvm64', got %s", b.config.CPUType)
}
if b.config.OS != "other" {
t.Errorf("Expected OS to be 'other', got %s", b.config.OS)
}

View File

@ -31,7 +31,7 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist
Name: c.VMName,
Agent: agent,
Boot: "cdn", // Boot priority, c:CDROM -> d:Disk -> n:Network
QemuCpu: "host",
QemuCpu: c.CPUType,
Description: "Packer ephemeral build VM",
Memory: c.Memory,
QemuCores: c.Cores,

View File

@ -73,6 +73,10 @@ builder.
- `sockets` (int) - How many CPU sockets to give the virtual machine.
Defaults to `1`
- `cpu_type` (string) - The CPU type to emulate. See the Proxmox API
documentation for the complete list of accepted values. For best
performance, set this to `host`. Defaults to `kvm64`.
- `os` (string) - The operating system. Can be `wxp`, `w2k`, `w2k3`, `w2k8`,
`wvista`, `win7`, `win8`, `win10`, `l24` (Linux 2.4), `l26` (Linux 2.6+),
`solaris` or `other`. Defaults to `other`.