Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions images/virtualization-dra/internal/usb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,21 @@ func (s *AllocationStore) Unprepare(_ context.Context, claimUID types.UID) error
for _, device := range allocatedDevices {
if usbGatewayEnabled {
count, hasCount := s.usbipAllocatedDevicesCount[device]
s.log.Info("Device attached by USBGateway", slog.String("device", device), slog.Int("count", count))
s.log.Info("Device attached by USBGateway", slog.String("device", device), slog.Int("count", count), slog.Bool("tracked", hasCount))
switch {
case !hasCount || count <= 1:
case !hasCount:
s.log.Info("Device is not tracked by USBGateway, skipping detach", slog.String("device", device))
case count == 1:
s.log.Info("Device has no tracked consumers, attempting detach cleanup", slog.String("device", device), slog.Int("count", count))
if err := s.usbGateway.Detach(device); err != nil {
return fmt.Errorf("failed to detach device %s: %w", device, err)
}
delete(s.usbipAllocatedDevicesCount, device)
default:
case count > 1:
s.log.Info("Decrementing device consumer count", slog.String("device", device), slog.Int("newCount", count-1))
s.usbipAllocatedDevicesCount[device]--
default:
s.log.Warn("Device has invalid USBGateway consumer count, skipping detach", slog.String("device", device), slog.Int("count", count))
}
}

Expand Down
Loading