mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-22 19:38:35 +00:00
fix(vm): fix vm machine type validation in order to support viommu (#1798)
* fix(vm): fix vm machine type validation in order to support viommu Signed-off-by: Mikael Nakajima <nakamorichi@protonmail.com> * docs(vm): update machine type documentation with VIOMMU details Enhance VM machine type documentation to clarify VIOMMU configuration option for q35 machine type Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> --------- Signed-off-by: Mikael Nakajima <nakamorichi@protonmail.com> Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
b3c862b986
commit
57c3970d54
@ -414,7 +414,7 @@ output "ubuntu_vm_public_key" {
|
||||
- `kvm_arguments` - (Optional) Arbitrary arguments passed to kvm.
|
||||
- `machine` - (Optional) The VM machine type (defaults to `pc`).
|
||||
- `pc` - Standard PC (i440FX + PIIX, 1996).
|
||||
- `q35` - Standard PC (Q35 + ICH9, 2009).
|
||||
- `q35` - Standard PC (Q35 + ICH9, 2009). Optionally, you can enable VIOMMU by adding `viommu=virtio|intel` to the value, for example `q35,viommu=virtio`.
|
||||
- `memory` - (Optional) The memory configuration.
|
||||
- `dedicated` - (Optional) The dedicated memory in megabytes (defaults to `512`).
|
||||
- `floating` - (Optional) The floating memory in megabytes. The default is `0`, which disables "ballooning device" for the VM.
|
||||
|
@ -192,7 +192,7 @@ func KeyboardLayoutValidator() schema.SchemaValidateDiagFunc {
|
||||
// MachineTypeValidator is a schema validation function for machine types.
|
||||
func MachineTypeValidator() schema.SchemaValidateDiagFunc {
|
||||
//nolint:lll
|
||||
r := regexp.MustCompile(`^$|^(pc|pc(-i440fx)?-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|q35|pc-q35-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|virt(?:-\d+(\.\d+)+)?(\+pve\d+)?)$`)
|
||||
r := regexp.MustCompile(`^$|^(pc|pc(-i440fx)?-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|q35(,viommu=(intel|virtio))?|pc-q35-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|virt(?:-\d+(\.\d+)+)?(\+pve\d+)?)$`)
|
||||
|
||||
return validation.ToDiagFunc(validation.StringMatch(r, "must be a valid machine type"))
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ func TestMachineType(t *testing.T) {
|
||||
{"empty is valid", "", true},
|
||||
{"invalid", "invalid", false},
|
||||
{"valid q35", "q35", true},
|
||||
{"valid q35 with viommu", "q35,viommu=virtio", true},
|
||||
{"invalid q35 with viommu", "q35,viommu=invalid", false},
|
||||
{"valid pc-q35", "pc-q35-2.3", true},
|
||||
{"valid i440fx", "pc-i440fx-3.1+pve0", true},
|
||||
{"valid virt", "virt", true},
|
||||
|
Loading…
Reference in New Issue
Block a user