I try to use the usb-vhci in ubuntu 14.04 (both client side and server side are ubuntu 14.04). It can be installed successful, and I can redirection usb device well. But I find I can't disconnect the device safe.
The step to reproduce the issue:
1) Start the usb-vhci in server: sudo mono ./VhciServer.exe 4 1131
2) Redirection a udisk from clilent: sudo mono ./VhciClient.exe 2-1.2 10.117.162.159:1131
3) cp a large file from Udisk to server
4) Before cp complete, close the client by "Ctrl + C"
5) Retry to redirection the udisk from clilent again: sudo mono ./VhciClient.exe 2-1.2 10.117.162.159:1131
It looks like the vhci driver is in a error state, and it can't response any option operate.
The dmesg log as follow:
[74299.684261] usb_vhci_hcd usb_vhci_hcd.0: USB Virtual Host Controller Interface -- Version 1.15 (2016-11-02)
[74299.684270] usb_vhci_hcd usb_vhci_hcd.0: --> Backend: USB VHCI user-mode IOCTL-interface
[74299.684277] usb_vhci_hcd usb_vhci_hcd.0: VHCI Host Controller
[74299.684283] usb_vhci_hcd usb_vhci_hcd.0: new USB bus registered, assigned bus number 1
[74299.684361] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[74299.684365] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[74299.684369] usb usb1: Product: VHCI Host Controller
[74299.684372] usb usb1: Manufacturer: Linux 4.4.0-31-generic usb_vhci_hcd
[74299.684375] usb usb1: SerialNumber: usb_vhci_hcd.0
[74299.684628] hub 1-0:1.0: USB hub found
[74299.684643] hub 1-0:1.0: 4 ports detected
[74299.684859] usb_vhci_iocifc: Usb bus #1
[74304.195446] usb 1-1: new high-speed USB device number 2 using usb_vhci_hcd
[74304.341198] usb 1-1: New USB device found, idVendor=0951, idProduct=1666
[74304.341205] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[74304.341209] usb 1-1: Product: DataTraveler 3.0
[74304.341213] usb 1-1: Manufacturer: Kingston
[74304.341216] usb 1-1: SerialNumber: 60A44C413F39BE91BB4994E8
[74304.343747] usb-storage 1-1:1.0: USB Mass Storage device detected
[74304.344013] scsi host12: usb-storage 1-1:1.0
[74305.354909] scsi 12:0:0:0: Direct-Access Kingston DataTraveler 3.0 PMAP PQ: 0 ANSI: 6
[74305.357359] sd 12:0:0:0: Attached scsi generic sg2 type 0
[74305.361225] sd 12:0:0:0: [sdd] 30244864 512-byte logical blocks: (15.5 GB/14.4 GiB)
[74305.365385] sd 12:0:0:0: [sdd] Write Protect is off
[74305.365393] sd 12:0:0:0: [sdd] Mode Sense: 23 00 00 00
[74305.368881] sd 12:0:0:0: [sdd] No Caching mode page found
[74305.368889] sd 12:0:0:0: [sdd] Assuming drive cache: write through
[74305.390894] sdd: sdd4
[74305.405698] sd 12:0:0:0: [sdd] Attached SCSI removable disk
[74340.608282] FAT-fs (sdd4): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
[74363.531046] usb 1-1: USB disconnect, device number 2
The VhciServer log as follow:
VhciServer 1.5.1.4
Copyright © 2007-2009 Conemis AG Karlsruhe Germany
Copyright © 2007-2011 Michael Singer michael@a-singer.de
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Created usb_vhci_hcd.0 (usb bus #1)
BcdUSB: 0x0210
DeviceClass: 0x00
DeviceSubClass: 0x00
DeviceProtocol: 0x00
VendorID: 0x0951
ProductID: 0x1666
BcdDevice: 0x0100
ManufactStrIdx: 1
ProductStrIdx: 2
SerNumStrIdx: 3[Endpoint 0x00]
Type: CONTROL
Address: 0x00
MaxPacketSize: 64
MaxNakRate: 0
ConfigCount: 1
[Configuration 1]
Index: 1
IsActive: True
StrDescIndex: 0
SelfPowered: False
RemoteWakeup: False
MaxPower: 150 (300 mA)
InterfaceCount: 1
[Interface 0]
Index: 0
IsActive: True
OwningDriver: [no owner]
AltSettingCnt: 1
> [AlternateSetting 0]
Index: 0
IsActive: True
IfcClass: 0x08 (Mass Storage)
IfcSubClass: 0x06
IfcProtocol 0x50
StrDescIndex: 0
EndpointCount: 2
> [Endpoint 0x81]
Type: BULK
Address: 0x81
MaxPacketSize: 512
MaxNakRate: 0
> [Endpoint 0x02]
Type: BULK
Address: 0x02
MaxPacketSize: 512
MaxNakRate: 0
::::c.+:::c.+c.+c.+c.+c.+c.+c.+c.+c.+c.+c.+c.+b.+b.+b.+b+bbbbbbbbbbbbbbbbbbbbbb......................++++++++++++++++++++++b.+b.+bbbbbbbbbbbbbbbbbb..................++++++++++++++++++b.+b.+bbbb....++++b.+b.+bbbbbbbbbbbbbbbbbbb.b........b............b.bb..b.bbbbb+.+....++++++++++++++++++++++++++++b.+b.+bbbbbbbbbbbbbbbbbb..................+++++++++++++++> BcdUSB: 0x0210
DeviceClass: 0x00
DeviceSubClass: 0x00
DeviceProtocol: 0x00
VendorID: 0x0951
ProductID: 0x1666
BcdDevice: 0x0100
ManufactStrIdx: 1
ProductStrIdx: 2
SerNumStrIdx: 3
[Endpoint 0x00]
Type: CONTROL
Address: 0x00
MaxPacketSize: 64
MaxNakRate: 0
ConfigCount: 1
[Configuration 1]
Index: 1
IsActive: True
StrDescIndex: 0
SelfPowered: False
RemoteWakeup: False
MaxPower: 150 (300 mA)
InterfaceCount: 1
[Interface 0]
Index: 0
IsActive: True
OwningDriver: [no owner]
AltSettingCnt: 1
> [AlternateSetting 0]
Index: 0
IsActive: True
IfcClass: 0x08 (Mass Storage)
IfcSubClass: 0x06
IfcProtocol 0x50
StrDescIndex: 0
EndpointCount: 2
> [Endpoint 0x81]
Type: BULK
Address: 0x81
MaxPacketSize: 512
MaxNakRate: 0
> [Endpoint 0x02]
Type: BULK
Address: 0x02
MaxPacketSize: 512
MaxNakRate: 0
Can you remove the device if you unmount it before you disconnect the client?
I just repeated your steps and even though you shouldn't disconnect the device while it's mounted, it seems that some error status isn't passed along correctly. When I disconnect the client while a copy process is writing a file on the device, the process gets stuck in the D state (waiting for IO). Only after removing the HCD (shutting down the VhciServer), the process exits with an appropriate error message/code. For a real host controller, removing the controller isn't necessary to solve this condition. The process exits immediately after disconnecting the storage device.
So, something is not right here, thank you for pointing that out. But again, this was never supposed to be a safe way to remove your storage device. The file system gets screwed up anyway. Always unmount before disconnecting.
Last edit: Vadim G. 2017-02-22