Skip to content

Commit

Permalink
fix: usb & pci devices not removed (#1169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyblargon authored Nov 23, 2024
1 parent 1478348 commit cbc3a2d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions proxmox/Internal/resource/guest/qemu/pci/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ func SDK(d *schema.ResourceData) (pveAPI.QemuPciDevices, diag.Diagnostics) {
if subSchema, ok := schemaItem[0].(map[string]interface{}); ok {
for k, v := range subSchema {
tmpID, _ := strconv.ParseUint(k[len(prefixSchemaID):], 10, 64)
pciDevices[pveAPI.QemuPciID(tmpID)] = sdkPCIs_Unsafe(v.([]interface{}))
pciDevices[pveAPI.QemuPciID(tmpID)] = sdkPCIs(v.([]interface{}))
}
}
} else {
for i := pveAPI.QemuPciID(0); i < pveAPI.QemuPciID(amountPCIs); i++ {
pciDevices[i] = pveAPI.QemuPci{Delete: true}
}
}
}
return pciDevices, diags
Expand Down Expand Up @@ -91,7 +95,7 @@ func sdkPCI(schema map[string]interface{}) (pveAPI.QemuPciID, pveAPI.QemuPci, er
return id, pveAPI.QemuPci{Delete: true}, nil
}

func sdkPCIs_Unsafe(schema []interface{}) pveAPI.QemuPci {
func sdkPCIs(schema []interface{}) pveAPI.QemuPci {
if len(schema) == 0 {
return pveAPI.QemuPci{Delete: true}
}
Expand Down
4 changes: 4 additions & 0 deletions proxmox/Internal/resource/guest/qemu/usb/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func SDK(d *schema.ResourceData) (pveAPI.QemuUSBs, diag.Diagnostics) {
usbDevices[pveAPI.QemuUsbID(tmpID)] = usbsSDK(v.([]interface{}))
}
}
} else {
for i := 0; i < amountUSBs; i++ {
usbDevices[pveAPI.QemuUsbID(i)] = pveAPI.QemuUSB{Delete: true}
}
}
}
return usbDevices, diags
Expand Down

0 comments on commit cbc3a2d

Please sign in to comment.