Skip to content

[BUG] AutoAttachLocalClient causes device creation to fail if usbip exits with error #31

Description

@DRKV333

Bug Description

According the the docs about autoattach:

Automatically attach newly added devices to a local USBIP client on the same host (localhost only). This is a convenience feature; attachment failures (tool not found, error exit) are logged but do not abort device creation.

This doesn't appear to be the case though.

To Reproduce

I was running VIIPER as a normal, non-root user, which caused usbip attach to fail with the message usbip: error: import device.

The log indicates that this caused the call from the client (SISR) to return an error:

$ ./viiper server --log.level="trace" --api.auto-attach-local-client=true
2026-06-26T02:01:58.608257+02:00  INFO Starting VIIPER USB-IP server addr=:3240
2026-06-26T02:01:58.608469+02:00  INFO USBIP server listening addr=[::]:3240
2026-06-26T02:01:58.608488+02:00  INFO Auto-attach is enabled, checking prerequisites...
2026-06-26T02:01:58.608501+02:00 DEBUG usbip tool found in PATH
2026-06-26T02:01:58.608623+02:00 DEBUG vhci-hcd kernel module is loaded
2026-06-26T02:01:58.608627+02:00  INFO Auto-attach prerequisites satisfied
2026-06-26T02:01:58.608645+02:00  INFO API listening addr=[::]:3242
2026-06-26T02:02:09.251659+02:00 DEBUG Detected auth attempt
2026-06-26T02:02:09.264707+02:00 DEBUG authenticated connection established
2026-06-26T02:02:09.264830+02:00  INFO api cmd path=ping
2026-06-26T02:02:09.264852+02:00 DEBUG api handler success path=ping
2026-06-26T02:02:09.397758+02:00 DEBUG Detected auth attempt
2026-06-26T02:02:09.410255+02:00 DEBUG authenticated connection established
2026-06-26T02:02:09.410333+02:00  INFO api cmd path=bus/create
2026-06-26T02:02:09.410353+02:00 DEBUG api handler success path=bus/create
2026-06-26T02:02:09.424141+02:00 DEBUG Detected auth attempt
2026-06-26T02:02:09.437637+02:00 DEBUG authenticated connection established
2026-06-26T02:02:09.437684+02:00  INFO api cmd path=bus/1/add
2026-06-26T02:02:09.437748+02:00  INFO Auto-attaching localhost client busID=1 deviceID=1
2026-06-26T02:02:09.439070+02:00  INFO Client connected remote=[::1]:60330
2026/06/26 02:02:09 C->S chunk: 8 bytes, hex: 01 11 80 03 00 00 00 00
2026-06-26T02:02:09.439130+02:00  INFO OP_REQ_IMPORT
2026/06/26 02:02:09 C->S chunk: 32 bytes, hex: 31 2d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
2026-06-26T02:02:09.439143+02:00  INFO Import request busid=1-1
2026/06/26 02:02:09 S->C chunk: 320 bytes, hex: 01 11 00 03 00 00 00 00 2f 73 79 73 2f 64 65 76 69 63 65 73 2f 70 63 69 30 30 30 30 3a 30 30 2f 30 30 30 30 3a 30 30 3a 30 38 2e 31 2f 30 30 30 30 3a 30 30 3a 30 34 3a 30 30 2e 33 2f 75 73 62 31 2f 31 2d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 2d 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 02 04 5e 02 8e 01 14 ff ff ff 01 01 04
2026-06-26T02:02:09.439829+02:00  INFO Client disconnected error=read URB header: EOF
2026-06-26T02:02:09.439832+02:00 ERROR Failed to attach device error=exit status 1 port=3240 output=usbip: info: using port 3240 ("3240")
usbip: error: import device

2026-06-26T02:02:09.439852+02:00 ERROR failed to auto-attach localhost client error=exit status 1
2026-06-26T02:02:09.439858+02:00 ERROR api handler error path=bus/1/add error=409 Conflict: Failed to auto-attach device: exit status 1
2026-06-26T02:02:09.453518+02:00 DEBUG Detected auth attempt
2026-06-26T02:02:09.466861+02:00 DEBUG authenticated connection established
2026-06-26T02:02:09.466900+02:00  INFO api cmd path=ping
2026-06-26T02:02:09.466911+02:00 DEBUG api handler success path=ping
2026-06-26T02:02:14.442067+02:00  INFO timeout: removed device (no connection) busID=1 deviceID=1
2026-06-26T02:02:14.442099+02:00 DEBUG Started bus cleanup goroutine (RemoveDeviceByID)
2026-06-26T02:02:19.446148+02:00  INFO timeout: removed empty bus busID=1

Expected Behavior

According to the docs, failing to autoattach the device should not abort the device creation, so I would expect the call to still report success.

Actual Behavior

An error is reported, which is also visible in the SISR logs:

[2026-06-26 02:02:09] 2026-06-26T02:02:09.383640+02:00 DEBUG Opened Gamepad id=4 name=Steam Controller steamHandle=275536453573331 serial= path=/dev/input/event27 type=steam realType=standard
[2026-06-26 02:02:09] 2026-06-26T02:02:09.383682+02:00  WARN First opened gamepad has non-zero Steam handle; likely xbox controller
[2026-06-26 02:02:09] 2026-06-26T02:02:09.383694+02:00  INFO Found Steam Virtual Gamepad id=4 name=Steam Controller steamhandle=275536453573331 paired with=4 paired with name=Steam Controller
[2026-06-26 02:02:09] 2026-06-26T02:02:09.383741+02:00 DEBUG No previous VIIPER bus used, creating new bus
[2026-06-26 02:02:09] 2026-06-26T02:02:09.410437+02:00  INFO Created VIIPER bus busID=1
[2026-06-26 02:02:09] 2026-06-26T02:02:09.439994+02:00 ERROR Failed to create VIIPER device error=409 Conflict: Failed to auto-attach device: exit status 1

Further, as soon as I press any input on the gamepad, SISR starts spamming the log with this:

[2026-06-26 02:10:02] 2026-06-26T02:10:02.233790+02:00 DEBUG No VIIPER device for gamepad found, scheduling create id=4

And spams VIIPER with device creation requests, which all fail. (Though this is probably more of an issue with SISR, not VIIPER.)

Screenshots/Logs

(See above)

Environment

  • OS: arch linux
  • VIIPER Version: 0.7.0-7-g88f66f1
  • USB-IP Version: 7.0.12-1

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions