[SOLVED] USB loss of connectivity (frequent/intermittent)

Discussions related to using VirtualBox on Linux hosts.
Post Reply
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

[SOLVED] USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

I was trying to run 2 UPS units with nut (and previously, apcupsd) within a vbox VM. There are reasons I'd like to be able to do this, but that matter is actually aside from the problem. Using virtualbox's handy USB passthrough, I would typically get 45 mins or an hour or so of runtime until there was a loss of connectivity with one of the units, but the longevity varied widely; sometimes I had to restart the VM from cold boot. Other times, the 2nd unit would also lose connectivity but not as frequently. I found that by restarting nut-server, I could get connectivity immediately again. This is, of course, a bit unreliable.

I checked system logs on both the host and guest frequently and observed nothing unusual, other than disconnect messages indicating I had unchecked the USB devices in the VM device menu. I even tried running the problem down using wireshark, but either that software does not have full support for USB, or my own wireshark skills are lacking. Either way, I did notice that USB is extremely noisy... even if I had known exactly how to do this, there were reams of packets, far more than what I usually observe even when looking at a busy vnet. And, of course, I finally resorted -- a couple of times, I am ashamed to admit -- to rebooting the whole box, something not ordinarily required or even desired with unixy systems.

I am now running the exact same 2 units on the linux host, using the exact same nut configuration. It has been at least 6 hours since I started nut on the vbox host and I have not experienced a loss in communications. I am suspicious that this may have something to do with the particular devices being passed-through to the guest.

The host and guest are both devuan chimaera, running virtualbox 6.1.30. I have also updated all packages on both to the latest from the devuan repos. Since these are older units, I am guessing they do not require USB 3, so I've only enabled USB 2 for the guest. I am not experiencing any instability with the host, guest, or virtualbox in general.

Note that the one unit, an APC xs1300 is probably about 15 years old now. I recently replaced the batteries in it. The other unit, an APC es650, is only a few years old. A recent power outage proved that both units function correctly. That unit is physically connected to the linux host via an unusual cable, one end being USB A connector and the other resembling a standard ethernet connector. I did find, at one point (while nut-server was running in the guest) that by applying a little pressure to the clip end of the cable at the back of the UPS, connectivity might resume. However, this may have been coincidence. I just thought it might be useful to include here. OTOH, since I'm not seeing further disconnects with the same physical arrangement running the nut-server on the host, I think any loose connectors is probably beside the point.

Another factoid that may be relevant is that both are APC units with the same USB VID:PID pair. NUT allows me to configure each APC by specifying additional information beyond the VID:PID, such as serial number, so it can distinguish the units. However, I am not sure what impact this might have on virtualbox's USB subsystem.

I am not sure my issue warrants a bug report. There have been numerous reports of various problems with these UPS's and the apcupsd and nut software packages, though most of those seem to go back 5 or 10 years. I only noticed one very recent, one being a NAS UPS configuration. I am happy to run nut-server on the host (hopefully this situation will remain stable), but I thought I should report this in case devs might see some issue that could be of interest. Or perhaps other users here have experienced similar sporadic disconnects with USB equipment passed through to their guest VMs. I may try some additional tests in a libvirt/kvm VM just for comparison.

I'll update this in case there are further disruptions to connectivity in the host nut-server scenario currently running, so far successfully.
Last edited by HarryMan on 30. Apr 2022, 06:27, edited 3 times in total.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: USB loss of connectivity (frequent/intermittent)

Post by scottgus1 »

Start the VM from full normal shutdown, not save-state.

Take note of the wall clock time the VM is started.

Run until you see the UPS's lose connection. Take note of the wall clock time.

If you can wait until the connection is restored, that would be good too. Take note of the wall clock time.

Shut down the VM from within the VM's OS.

Right-click the VM in the main Virtualbox window's VM list, choose Show Log. Save the far left tab's log, zip it, and post the zip file, using the forum's Upload Attachment tab.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

Thanks, scottgus. (I should have figured you guys would want the log.)

Usually, the UPS does not restore connectivity. However, if I restart the nut-server, usually it will restore connectivity. So I have a method for forcing it to reconnect. Do you want me to do this manually? (It will be quicker, for one thing.)

Please note that I am noticing other strange USB behavior besides the UPS. I have a couple of VMs using usb-ethernet adapters. They mostly work without issues, but every so often -- at times I am still trying to determine the pattern of -- they will have a momentary glitch, or even a full-fledged outage. (I am not changing any physical hardware while this happens.)
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: USB loss of connectivity (frequent/intermittent)

Post by scottgus1 »

HarryMan wrote:Usually, the UPS does not restore connectivity. However, if I restart the nut-server, usually it will restore connectivity. So I have a method for forcing it to reconnect. Do you want me to do this manually? (It will be quicker, for one thing.)
Yes, that will be fine. Please note the wall clock times when you do so.

The log shows messages when the USB devices are connecting and disconnecting through the Virtualbox USB filters. If such messages occur when the UPS disconnect occurs, it would mean Virtualbox is losing hold of the UPS somehow. If the log does not show the expected messages, then it may be the VM OS or some such that is losing the connection.

FWIW the devs say that the Virtualbox USB 3 implementation is better than USB 2, even on USB 2 devices. So setting up the VM for USB 3 could also help.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

Here is the log. (It took me many attempts to get this because sometimes the UPS was already down upon startup! I wanted to create just the scenario you asked for.)

Started VM (cold boot) Jan 3 2:05:53
UPS Disconnected ~ 2:30:17
Restarted UPS (manually) ~ 2:35:25
shut down VM 2:37:10

All times are US/Pacific.

I have not yet tried USB 3. Oddly, I was warned not to use it due to some unspecified issues. But I will try it next.
Attachments
myvm-2022-01-03-02-37-09.log.gz
(41.26 KiB) Downloaded 7 times
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

USB 3 setting might be the charm. I've had the VM running for 9 hours now and, so far, no problems with either UPS.

I'll try USB 3 for the other VM with the usb-ethernet adapter issue.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

This seems to have solved it. Usually, one unit would always fail after just a short uptime. I'm OK with marking this as solved, or I can provide more logs etc if you want to continue to resolve the problem with USB 2.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

Re: [SOLVED] USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

Maybe not solved yet. See viewtopic.php?f=7&t=104891.

Unmarking this as solved until the other issue is resolved.
HarryMan
Posts: 113
Joined: 15. Jan 2014, 13:54
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: devuan, MX-Linux, others

[SOLVED] Re: USB loss of connectivity (frequent/intermittent)

Post by HarryMan »

I've switched from NUT to UPOWER and now it is all working satisfactorily. I have not had any problems after a month.

I'll mark this as solved again. Thanks for the help.
Post Reply