diff --git a/builder/proxmox/common/config.go b/builder/proxmox/common/config.go index f5d25572..3ffedd1d 100644 --- a/builder/proxmox/common/config.go +++ b/builder/proxmox/common/config.go @@ -109,6 +109,8 @@ type diskConfig struct { CacheMode string `mapstructure:"cache_mode"` DiskFormat string `mapstructure:"format"` IOThread bool `mapstructure:"io_thread"` + Discard bool `mapstructure:"discard"` + SSD bool `mapstructure:"ssd"` } type efiConfig struct { EFIStoragePool string `mapstructure:"efi_storage_pool"` diff --git a/builder/proxmox/common/step_start_vm.go b/builder/proxmox/common/step_start_vm.go index 849227dc..c6644419 100644 --- a/builder/proxmox/common/step_start_vm.go +++ b/builder/proxmox/common/step_start_vm.go @@ -284,10 +284,17 @@ func generateProxmoxDisks(disks []diskConfig) proxmox.QemuDevices { setDeviceParamIfDefined(devs[idx], "storage", disks[idx].StoragePool) setDeviceParamIfDefined(devs[idx], "cache", disks[idx].CacheMode) setDeviceParamIfDefined(devs[idx], "format", disks[idx].DiskFormat) - if devs[idx]["type"] == "scsi" || devs[idx]["type"] == "virtio" { setDeviceParamIfDefined(devs[idx], "iothread", strconv.FormatBool(disks[idx].IOThread)) } + // Proxmox API expectes the value of discard to bei either "off" or "on" + setDeviceParamIfDefined(devs[idx], "discard", func() string { + if disks[idx].Discard { + return "on" + } + return "off" + }()) + setDeviceParamIfDefined(devs[idx], "ssd", strconv.FormatBool(disks[idx].IOThread)) } return devs } diff --git a/docs/builders/clone.mdx b/docs/builders/clone.mdx index 8162eaf6..7c898bb0 100644 --- a/docs/builders/clone.mdx +++ b/docs/builders/clone.mdx @@ -49,7 +49,7 @@ in the image's Cloud-Init settings for provisioning. - `username` (string) - Username when authenticating to Proxmox, including the realm. For example `user@pve` to use the local Proxmox realm. When using token authentication, the username must include the token id after an exclamation - mark. For example, `user@pve!tokenid`. + mark. For example, `user@pve!tokenid`. Can also be set via the `PROXMOX_USERNAME` environment variable. - `password` (string) - Password for the user. @@ -228,6 +228,12 @@ or responding to pattern `/dev/.+`. Example: multiple disks are used. Requires `virtio-scsi-single` controller and a `scsi` or `virtio` disk. Defaults to `false`. + - `discard` (bool) - Relay TRIM commands to the underlying storage. Defaults + to false. + + - `ssd` (bool) - Drive will be represented to the guest as solid-state drive + rather than a rotational disk. + - `template_name` (string) - Name of the template. Defaults to the generated name used during creation. @@ -261,7 +267,7 @@ or responding to pattern `/dev/.+`. Example: - `ipconfig` (array of objects) - Set IP address and gateway via Cloud-Init. If you have configured more than one network interface, make sure to match the order of - `network_adapters` and `ipconfig`. + `network_adapters` and `ipconfig`. Usage example (JSON): diff --git a/docs/builders/iso.mdx b/docs/builders/iso.mdx index 68235a22..c0523b01 100644 --- a/docs/builders/iso.mdx +++ b/docs/builders/iso.mdx @@ -239,6 +239,12 @@ or responding to pattern `/dev/.+`. Example: multiple disks are used. Requires `virtio-scsi-single` controller and a `scsi` or `virtio` disk. Defaults to `false`. + - `discard` (bool) - Relay TRIM commands to the underlying storage. Defaults + to false. + + - `ssd` (bool) - Drive will be represented to the guest as solid-state drive + rather than a rotational disk. + - `template_name` (string) - Name of the template. Defaults to the generated name used during creation.