mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-01 19:12:59 +00:00
feat(vm): fix adding/removing hostpci devices forcing vm recreation (#504)
* feat(vm): fix adding/removing hostpci devices forcing vm recreation * fix: hostpci device removal * fix: hostpci jason unmarshalling but introduced in #500 --------- Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
26970541c4
commit
a038fd3142
@ -1622,7 +1622,7 @@ func (r *CustomPCIDevice) UnmarshalJSON(b []byte) error {
|
||||
} else if len(v) == 2 {
|
||||
switch v[0] {
|
||||
case "host":
|
||||
dIds := strings.Split(v[0], ";")
|
||||
dIds := strings.Split(v[1], ";")
|
||||
r.DeviceIDs = &dIds
|
||||
case "mapping":
|
||||
r.Mapping = &v[1]
|
||||
|
@ -137,6 +137,7 @@ const (
|
||||
maxResourceVirtualEnvironmentVMAudioDevices = 1
|
||||
maxResourceVirtualEnvironmentVMNetworkDevices = 8
|
||||
maxResourceVirtualEnvironmentVMSerialDevices = 4
|
||||
maxResourceVirtualEnvironmentVMHostPCIDevices = 8
|
||||
|
||||
mkResourceVirtualEnvironmentVMRebootAfterCreation = "reboot"
|
||||
mkResourceVirtualEnvironmentVMOnBoot = "on_boot"
|
||||
@ -998,7 +999,7 @@ func VM() *schema.Resource {
|
||||
Type: schema.TypeList,
|
||||
Description: "The Host PCI devices mapped to the VM",
|
||||
Optional: true,
|
||||
ForceNew: true,
|
||||
ForceNew: false,
|
||||
DefaultFunc: func() (interface{}, error) {
|
||||
return []interface{}{}, nil
|
||||
},
|
||||
@ -5300,6 +5301,11 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
|
||||
// Prepare the new hostpci devices configuration.
|
||||
if d.HasChange(mkResourceVirtualEnvironmentVMHostPCI) {
|
||||
updateBody.PCIDevices = vmGetHostPCIDeviceObjects(d)
|
||||
|
||||
for i := len(updateBody.PCIDevices); i < maxResourceVirtualEnvironmentVMHostPCIDevices; i++ {
|
||||
del = append(del, fmt.Sprintf("hostpci%d", i))
|
||||
}
|
||||
|
||||
rebootRequired = true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user