diff --git a/proxmox/nodes/vms/custom_usb_device.go b/proxmox/nodes/vms/custom_usb_device.go index e141c43d..51f70826 100644 --- a/proxmox/nodes/vms/custom_usb_device.go +++ b/proxmox/nodes/vms/custom_usb_device.go @@ -77,7 +77,7 @@ func (r *CustomUSBDevice) UnmarshalJSON(b []byte) error { for _, p := range pairs { v := strings.Split(strings.TrimSpace(p), "=") if len(v) == 1 { - r.HostDevice = &v[1] + r.HostDevice = &v[0] } else if len(v) == 2 { switch v[0] { case "host": diff --git a/proxmox/nodes/vms/custom_usb_device_test.go b/proxmox/nodes/vms/custom_usb_device_test.go index d1629ba9..4725b6eb 100644 --- a/proxmox/nodes/vms/custom_usb_device_test.go +++ b/proxmox/nodes/vms/custom_usb_device_test.go @@ -46,6 +46,13 @@ func TestCustomUSBDevice_UnmarshalJSON(t *testing.T) { USB3: types.CustomBool(false).Pointer(), }, }, + { + name: "spice usb device", + line: `"spice"`, + want: &CustomUSBDevice{ + HostDevice: ptr.Ptr("spice"), + }, + }, } for _, tt := range tests {