Fix USB/IP import lease and attach races

This commit is contained in:
世界
2026-04-25 05:08:36 +08:00
parent ff9336435e
commit d690a17780
8 changed files with 405 additions and 35 deletions
+4 -1
View File
@@ -231,7 +231,7 @@ func writeUsbipSockfd(busid string, fd int) error {
return writeSysfs(filepath.Join(sysBusUSBDevices, busid, "usbip_sockfd"), strconv.Itoa(fd))
}
func vhciPickFreePort(speed uint32) (int, error) {
func vhciPickFreePort(speed uint32, skip map[int]struct{}) (int, error) {
records, err := readVHCIStatus()
if err != nil {
return -1, err
@@ -241,6 +241,9 @@ func vhciPickFreePort(speed uint32) (int, error) {
if record.hub != targetHub || record.state != 4 {
continue
}
if _, skipped := skip[record.port]; skipped {
continue
}
return record.port, nil
}
return -1, E.New("no free ", targetHub, " vhci port")