diff --git a/proxmox/nodes/vms/vms_types_test.go b/proxmox/nodes/vms/vms_types_test.go index 81747d9f..4a44fbc8 100644 --- a/proxmox/nodes/vms/vms_types_test.go +++ b/proxmox/nodes/vms/vms_types_test.go @@ -133,12 +133,7 @@ func TestCustomPCIDevice_UnmarshalJSON(t *testing.T) { name: "id only pci device", line: `"0000:81:00.2"`, want: &CustomPCIDevice{ - DeviceIDs: &[]string{"0000:81:00.2"}, - MDev: nil, - PCIExpress: types.BoolPtr(false), - ROMBAR: types.BoolPtr(true), - ROMFile: nil, - XVGA: types.BoolPtr(false), + DeviceIDs: &[]string{"0000:81:00.2"}, }, }, { @@ -176,6 +171,7 @@ func TestCustomPCIDevice_UnmarshalJSON(t *testing.T) { if err := r.UnmarshalJSON([]byte(tt.line)); (err != nil) != tt.wantErr { t.Errorf("UnmarshalJSON() error = %v, wantErr %v", err, tt.wantErr) } + require.Equal(t, tt.want, r) }) } } diff --git a/proxmoxtf/resource/vm.go b/proxmoxtf/resource/vm.go index e00cdd4e..db021dd9 100644 --- a/proxmoxtf/resource/vm.go +++ b/proxmoxtf/resource/vm.go @@ -4364,7 +4364,7 @@ func vmReadCustom( if pp.ROMBAR != nil { pci[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR] = *pp.ROMBAR } else { - pci[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR] = false + pci[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR] = true } if pp.ROMFile != nil { @@ -4388,7 +4388,7 @@ func vmReadCustom( pciMap[pi] = pci } - if len(currentPCIList) > 0 { + if len(clone) == 0 || len(currentPCIList) > 0 { orderedPCIList := orderedListFromMap(pciMap) err := d.Set(mkResourceVirtualEnvironmentVMHostPCI, orderedPCIList) diags = append(diags, diag.FromErr(err)...) @@ -4426,7 +4426,7 @@ func vmReadCustom( usbMap[pi] = usb } - if len(currentUSBList) > 0 { + if len(clone) == 0 || len(currentUSBList) > 0 { // todo: reordering of devices by PVE may cause an issue here orderedUSBList := orderedListFromMap(usbMap) err := d.Set(mkResourceVirtualEnvironmentVMHostUSB, orderedUSBList)