Skip to content

Commit

Permalink
Add support for discard and ssd storage options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeinwag committed Jun 23, 2023
1 parent 2edca36 commit 4e48973
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions builder/proxmox/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
9 changes: 8 additions & 1 deletion builder/proxmox/common/step_start_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions docs/builders/clone.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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):

Expand Down
6 changes: 6 additions & 0 deletions docs/builders/iso.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 4e48973

Please sign in to comment.