diff --git a/proxmox/config_qemu_usb.go b/proxmox/config_qemu_usb.go index 447aaa5a..8b9423ab 100644 --- a/proxmox/config_qemu_usb.go +++ b/proxmox/config_qemu_usb.go @@ -325,7 +325,7 @@ func (id UsbDeviceID) String() string { type UsbPortID string // regex: \d+-\d+ const ( - UsbPortID_Error_Invalid string = "invalid usb port id" + UsbPortID_Error_Invalid string = "invalid usb port id. Expected expression of the form '-(.)*' where bus and port are integers" ) func (id UsbPortID) String() string { @@ -340,8 +340,11 @@ func (id UsbPortID) Validate() error { if _, err := strconv.Atoi(idArray[0]); err != nil { return errors.New(UsbPortID_Error_Invalid) } - if _, err := strconv.Atoi(idArray[1]); err != nil { - return errors.New(UsbPortID_Error_Invalid) + parts := strings.Split(idArray[1], ".") + for _, part := range parts { + if _, err := strconv.Atoi(part); err != nil { + return errors.New(UsbPortID_Error_Invalid) + } } return nil } diff --git a/proxmox/config_qemu_usb_test.go b/proxmox/config_qemu_usb_test.go index f51cd129..4cc30ddb 100644 --- a/proxmox/config_qemu_usb_test.go +++ b/proxmox/config_qemu_usb_test.go @@ -172,6 +172,10 @@ func Test_UsbPortID_Validate(t *testing.T) { }{ {name: "Valid", input: "2-4"}, + {name: "Valid", + input: "2-4.1"}, + {name: "Valid", + input: "3-1.2.3.4.5.6.7.8.9"}, // Invalid {name: "UsbPortID_Error_Invalid", input: "2-4-5",