VirtualBox

Opened 13 years ago

Last modified 8 years ago

#9007 reopened defect

Captured/filtered USB devices are released and reacquired when guest reboots

Reported by: Donuts Owned by:
Component: USB Version: VirtualBox 4.0.8
Keywords: Cc:
Guest type: Windows Host type: Linux

Description (last modified by aeichner)

Hi,

Host: Xubuntu 9.10 x86, VirtualBox 4.0.8 (with PUEL extension pack). Guest: Windows XP SP3

When the guest is rebooted, VirtualBox seems to free/release any filtered USB devices, then re-capture them. I think all filtered USB devices should remain filtered when the guest reboots.

This problem is most noticeable when using a USB floppy drive. Most(?) Linux distributions treat USB floppy drives as generic removable drives. So when you insert a disk, the kernel attempts to read the last sector and scans for partition tables. In combination with the default block device readahead of 256 blocks, that process can take 30 seconds or so. *Every time you insert a disk*. It's quite annoying. Floppy disks never have a partition table of course so the scan is pointless. Anyway...

To reproduce the problem:

  • Connect a USB floppy drive to your system.
  • Add the floppy drive to the USB Device Filters of a Windows guest VM.
  • Start the Windows VM. Insert a floppy disk. Notice the drive only spins for a short time. Because it is captured, the Linux host OS doesn't attempt to access it.
  • Reboot the guest OS.
  • Notice how when the guest reboots, the kernel creates a /dev/sdX block device and scans for partitions (taking about 30 seconds). Then the block device is removed when VirtualBox re-captures the device.

Other drives are probably affected similarly, so you get an unnecessary block device creation, partition scan and device removal whenever the guest is rebooted. (That takes less time than for USB floppy drives so will be less noticeable.)

Change History (3)

comment:1 by aeichner, 8 years ago

Description: modified (diff)
Resolution: obsolete
Status: newclosed

Please reopen if still relevant with a recent VirtualBox release.

comment:2 by Donuts, 8 years ago

Resolution: obsolete
Status: closedreopened

Reopening because the problem is still present with VirtualBox 5.1.4 (on Lubuntu 16.04 x86-64 now).

It should be very easy to reproduce this issue with pretty much any USB evice, e.g. a card reader or flash drive.

Attach your USB device then type dmesg in host to see info about it. Start a VM (with that USB device added to the filter so it appears to the guest) and boot the guest OS. Reboot the guest OS. Type dmesg in host again, you should see more lines about the USB device, after VirtualBox incorrectly releases and re-captures it.

Version 1, edited 8 years ago by Donuts (previous) (next) (diff)

comment:3 by aeichner, 8 years ago

I'm able to reproduce the issue but I'm afraid that fixing this will be a lot of work no one here has time for.
When the VM is reset all attached USB devices are reset too to bring them into the default state. For proxied device we use the USBDEVFS_RESET ioctl on Linux to issue the reset. However USBDEVFS_RESET causes the device to get logically disconnected and reconnected shortly after. When the device appears again VirtualBox needs some time to grab it again because on Linux we don't use a kernel driver which hooks into the USB stack but a userspace only approach which monitors the host for USB device changes. Until the new device is detected device probing in the kernel will kick in and grab the device for a short amount of time. The only solution is to implement a kernel driver for the USB support which prevents that other drivers can grab the device which is a lot of work.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use