Github Issue #5701 - Missing newline in qvm-usb timeout output

Github Issue #5701 - Missing newline in qvm-usb timeout output

Reported by a user on Mar 3, 2020. Closed on Aug 5, 2023. Reopened on Feb 15

Run qvm-usb attach in some situation that will cause an attach timeout (in my case this is a separate bug that I’ll report shortly) Wait a few seconds. This is printed:

Device attach failed: /usr/lib/qubes/usb-import: 94: echo: echo: I/O error
Attach timeout, check kernel log for details. VM: "steevie-cloud" File: "/usr/lib/qubes/usb-import" Version Control:

This is a though issue I tried to pinpoint but failed miserably. It is a totally valid issue. Even if you do not have any USB device which would time-out on attaching, you could emulate it. This issue is valid for all USB attaching problems. Not just timeout. And it is not just a newline break which is missing. All newline breaks are missing from the output error.

In destination VM which receives the USB device (could be a disposable), Look at the /usr/lib/qubes/usb-import bash file. The error is generated there in the wait_for_attached function and printed via ERROR function. You could emulate the error by adding this line at line 164 of usb-import temporarily.

ERROR "Emulated timeout error"

That script is called via /etc/qubes-rpc/qubes.USBAttach RPC service. Now if we use qubes-usb to attach any USB devices to the modified destination VM, we get the emulated error message which lacks the newline breaks. Somewhere in the middle, the newline characters are eaten. And I lack deep knowledge of Qubes RPC internals at the moment. I appreciate if anyone could help on this issue.

Required Skills

RPC Internals. Unknown.