From 1d79b7ec8df11e04572e650cf8b0e2a374b6354a Mon Sep 17 00:00:00 2001 From: Virgil Date: Tue, 6 Aug 2019 09:48:51 +0200 Subject: [PATCH 1/3] Add Numa and other CPU type support --- proxmox/resource_vm_qemu.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index 366340d..10e918a 100644 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -97,6 +97,16 @@ func resourceVmQemu() *schema.Resource { Optional: true, Default: 1, }, + "cpu": { + Type: schema.TypeString, + Optional: true, + Default: "host", + }, + "numa": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "scsihw": { Type: schema.TypeString, Optional: true, @@ -386,6 +396,8 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error { Memory: d.Get("memory").(int), QemuCores: d.Get("cores").(int), QemuSockets: d.Get("sockets").(int), + QemuCpu: d.Get("cpu").(string), + QemuNuma: d.Get("numa").(bool), Scsihw: d.Get("scsihw").(string), QemuOs: d.Get("qemu_os").(string), QemuNetworks: qemuNetworks, @@ -545,6 +557,8 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error { Memory: d.Get("memory").(int), QemuCores: d.Get("cores").(int), QemuSockets: d.Get("sockets").(int), + QemuCpu: d.Get("cpu").(string), + QemuNuma: d.Get("numa").(bool), Scsihw: d.Get("scsihw").(string), QemuOs: d.Get("qemu_os").(string), QemuNetworks: qemuNetworks, @@ -636,6 +650,8 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error { d.Set("memory", config.Memory) d.Set("cores", config.QemuCores) d.Set("sockets", config.QemuSockets) + d.Set("cpu", config.QemuCpu) + d.Set("numa", config.QemuNuma) d.Set("scsihw", config.Scsihw) d.Set("qemu_os", config.QemuOs) // Cloud-init. From f0a71f4dcec419e54a801bd41fa44a40855bbd1e Mon Sep 17 00:00:00 2001 From: Virgil Date: Tue, 6 Aug 2019 12:38:48 +0200 Subject: [PATCH 2/3] Add hotplug support --- proxmox/resource_vm_qemu.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index 10e918a..9d7dea5 100644 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -107,6 +107,11 @@ func resourceVmQemu() *schema.Resource { Optional: true, Default: false, }, + "hotplug": { + Type: schema.TypeString, + Optional: true, + Default: "network,disk,usb", + }, "scsihw": { Type: schema.TypeString, Optional: true, @@ -398,6 +403,7 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error { QemuSockets: d.Get("sockets").(int), QemuCpu: d.Get("cpu").(string), QemuNuma: d.Get("numa").(bool), + Hotplug: d.Get("hotplug").(string), Scsihw: d.Get("scsihw").(string), QemuOs: d.Get("qemu_os").(string), QemuNetworks: qemuNetworks, @@ -559,6 +565,7 @@ func resourceVmQemuUpdate(d *schema.ResourceData, meta interface{}) error { QemuSockets: d.Get("sockets").(int), QemuCpu: d.Get("cpu").(string), QemuNuma: d.Get("numa").(bool), + Hotplug: d.Get("hotplug").(string), Scsihw: d.Get("scsihw").(string), QemuOs: d.Get("qemu_os").(string), QemuNetworks: qemuNetworks, @@ -652,6 +659,7 @@ func resourceVmQemuRead(d *schema.ResourceData, meta interface{}) error { d.Set("sockets", config.QemuSockets) d.Set("cpu", config.QemuCpu) d.Set("numa", config.QemuNuma) + d.Set("hotplug", config.Hotplug) d.Set("scsihw", config.Scsihw) d.Set("qemu_os", config.QemuOs) // Cloud-init. From d1fa174f755aabb53e3c204ed47bc3149e260005 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 14 Aug 2019 18:23:36 +0200 Subject: [PATCH 3/3] Add examples about cpu and host vars --- README.md | 7 +++++++ examples/cloudinit_example.tf | 1 + 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 193d4c5..51b1693 100644 --- a/README.md +++ b/README.md @@ -121,10 +121,17 @@ resource "proxmox_vm_qemu" "prepprovision-test" { cores = 3 sockets = 1 + # Same CPU as the Physical host, possible to add cpu flags + # Ex: "host,flags=+md-clear;+pcid;+spec-ctrl;+ssbd;+pdpe1gb" + cpu = "host" + numa = false memory = 2560 scsihw = "lsi" # Boot from hard disk (c), CD-ROM (d), network (n) boot = "cdn" + # It's possible to add this type of material and use it directly + # Possible values are: network,disk,cpu,memory,usb + hotplug = "network,disk,usb" # Default boot disk bootdisk = "virtio0" network { diff --git a/examples/cloudinit_example.tf b/examples/cloudinit_example.tf index b36c68a..0974429 100644 --- a/examples/cloudinit_example.tf +++ b/examples/cloudinit_example.tf @@ -26,6 +26,7 @@ resource "proxmox_vm_qemu" "cloudinit-test" { os_type = "cloud-init" cores = "2" sockets = "1" + cpu = "host" memory = "2048" scsihw = "lsi"