Skip to content

Commit

Permalink
Only add ssd=1 if true
Browse files Browse the repository at this point in the history
  • Loading branch information
bouchardh authored and lbajolet-hashicorp committed Sep 12, 2023
1 parent b41e909 commit 0209937
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 2 additions & 5 deletions builder/proxmox/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,8 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st
}
}
}
if disk.SSD {
// SSD emulation is not supported on virtio device type
if disk.Type == "virtio" {
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("SSD emulation is not supported on a virtio disk"))
}
if disk.SSD && disk.Type == "virtio" {
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("SSD emulation is not supported on virtio disks"))
}
if disk.StoragePool == "" {
errs = packersdk.MultiErrorAppend(errs, fmt.Errorf("disks[%d].storage_pool must be specified", idx))
Expand Down
7 changes: 4 additions & 3 deletions builder/proxmox/common/step_start_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ func generateProxmoxDisks(disks []diskConfig) proxmox.QemuDevices {
}
return "ignore"
}())
// SSD emulation is not supported on virtio device type
if devs[idx]["type"] != "virtio" {
setDeviceParamIfDefined(devs[idx], "ssd", strconv.FormatBool(disks[idx].SSD))
// Add SSD flag only if true
if disks[idx].SSD {
devs[idx]["ssd"] = "1"
}
}
return devs
Expand Down Expand Up @@ -369,6 +369,7 @@ func generateProxmoxEfi(efi efiConfig) proxmox.QemuDevice {
}

func setDeviceParamIfDefined(dev proxmox.QemuDevice, key, value string) {
// Empty string is considered as not defined
if value != "" {
dev[key] = value
}
Expand Down

0 comments on commit 0209937

Please sign in to comment.