Problem with multiple USB devices

Discussions related to using VirtualBox on Windows hosts.
Post Reply
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Problem with multiple USB devices

Post by NicoV »

Hi,

I'm encountering some problems working with USB devices, when I have several instances of the same kind of USB devices.
I have VirtualBox 4.3.12 on a Windows 8.1 host, using a Windows 7 guest.
The USB devices I'm using are HASP HL Key from SafeNet

Whe I have only one HASP HL Key plugged into the host, sharing seems to work.
When I have two HASP HL Key plugged into the host, things start to fail working:
* sometimes error messages when trying to share one Key (captured but not shared)
* sometimes it seems to work
* sometimes one of the key disappears from the list of USB devices in virtualbox menu

Is there something I can do to make it work ?
I want to run 2 VMs, sharing one key with each VM.


Second question: how can easily affect one key to one VM, and the other key to the second VM ?
Working with a filter on port is not practical (laptop will be handled by an other person, having to plug the keys in specified ports is not great)
I didn't find a way to get the serial number of the keys to use that as a filter.

Thanks
Nico
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Problem with multiple USB devices

Post by mpack »

You seem to have answered your own question: if you can't distinguish the keys... then they can't be distinguished.

Also, I doubt your statement that sharing a single key seems to work: the USB protocol is not designed to allow two PCs (in this case, the host and a VM) to share one USB port. One PC will own the device, i.e. will have exclusive use of it. As far as the other PC is concerned, the device is not present - so how can it be working?
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

You misunderstood me completely it seems (by sharing, I meant affecting a key to a VM) : I have 2 keys, I want to affect the first one to one VM, the second one to the other VM.
When I have 1 key plugged in the host, I can affect it to the first VM
When I have the 2 keys plugged in the host, I have problems affecting the first key to the first VM (error messages, key being marked as captured but not really affected, key becoming displayed as unknown in virtualbox menu, ...)
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

Something I tried:
* Plug one key in the host
* Start the first VM
* Affect the key to the VM using the menu : it works
* Stop the VM

* Plug the second key in the host
* Start the first VM
* Try to affect the first key to the VM using the menu :
** When I first open the menu, both keys are visible
** Click on the first: no error message, but the key is not really affected (not visible in the device manager of the guest)
** Open again the menu: the first key has disappeared, only the second key is listed in the menu
** Click on the only key listed: no error message, the key is not really affected, its status in the menu goes from Occupied to Captured
* Stop the VM

* Unplug the second key
* Start the first VM
* Try to affect the first key to the VM using the menu :
** When I first open the menu, both keys are visible (even if only one is still plugged in the host) : first as Occupied, second as Captured
** Click on the first: seems to work
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Problem with multiple USB devices

Post by mpack »

NicoV wrote: You misunderstood me completely it seems...
NicoV wrote: Whe I have only one HASP HL Key plugged into the host, sharing seems to work.
In fact, I think I understand the English language quite well. If exactly one VM was using exactly one key then no sharing was involved and your sentence gave bad information. As written, it states that multiple VMs can share a single key, or that the host and one or more VMs can share the key.

If your question is entirely about distinguishing multiple keys attached to the host then the first sentence of my previous post applies: if all of the device ID fields in two devices are identical, then they can't be distinguished. I don't use USB a lot, so I'm not sure what happens if you plug one of these in while two VMs are running with matching filters. At a guess, I'd say whichever VM has the focus will get it. Obviously you wouldn't plug the key in before the VM boots.
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

mpack wrote:
NicoV wrote: You misunderstood me completely it seems...
NicoV wrote: Whe I have only one HASP HL Key plugged into the host, sharing seems to work.
In fact, I think I understand the English language quite well. If exactly one VM was using exactly one key then no sharing was involved and your sentence gave bad information. As written, it states that multiple VMs can share a single key, or that the host and one or more VMs can share the key.

If your question is entirely about distinguishing multiple keys attached to the host then the first sentence of my previous post applies: if all of the device ID fields in two devices are identical, then they can't be distinguished. I don't use USB a lot, so I'm not sure what happens if you plug one of these in while two VMs are running with matching filters. At a guess, I'd say whichever VM has the focus will get it. Obviously you wouldn't plug the key in before the VM boots.
Hi again,

Well, yes, you understand the English language well. For me, English not being my language, I can make mistake in my sentences.
That's what I tried to say in my second post (rephrasing "by sharing, I meant affecting a key to a VM").
Please stop bickering: for me "You misunderstood me" simply meant that what you understand wasn't what I wanted to say, probably because I didn't say it well.

My question is not entirely about distinguishing multiple keys, that's only the second part of my question and not the most important part.

I do believe that the keys can be distinguished (probably by serial number, I just don't know how to find that information).

The problem is that when the two keys are plugged in the host, then strange behaviours occur when trying to affect one of the key to the VM : either the key simply vanishes from the menu, or it stays in the menu but displayed as Unknown, or its status change from Occupied (Occupé in French) to Captured (Capturé in French) but without the key becoming visible to the VM.
Once a problem occurs with a key, stopping the VM and stopping VirtualBox doesn't solve the problem, but entirely restarting the host does.

I want to find a solution for having 2 keys on the host, 1 affected to a first VM, the other affected to a second VM, that's the goal of my post
Last edited by NicoV on 26. Aug 2014, 16:14, edited 1 time in total.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Problem with multiple USB devices

Post by mpack »

NicoV wrote: I do believe that the keys can be distinguished (probably by serial number, I just don't know how to find that information).
If you go to the USB filter part of the VM settings, create a new filter from an existing device (second icon down,
usbadd.png
usbadd.png (780 Bytes) Viewed 5220 times
), and select a device from the list of those known to the host (so it can't already have been grabbed by a VM), then the filter will be filled with all of the ID information published by the device, including a serial number if it defines one. If a field is blank then the device doesn't provide that ID.
NicoV wrote: The problem is that when the two keys are plugged in the host, then strange behaviours occur when trying to affect one of the key to the VM : either the key simply vanishes from the menu, or it stays in the menu but displayed as Unknown, or its status change from Occupied (Occupé in French) to Captured (Capturé in French) but without the key becoming visible to the VM.
Let's clarify: you are doing this in the VM settings, right? You are not trying to grab a USB device while the VM is running?
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

mpack wrote:
NicoV wrote: I do believe that the keys can be distinguished (probably by serial number, I just don't know how to find that information).
If you go to the USB filter part of the VM settings, create a new filter from an existing device (second icon down,
usbadd.png
), and select a device from the list of those known to the host (so it can't already have been grabbed by a VM), then the filter will be filled with all of the ID information published by the device, including a serial number if it defines one. If a field is blank then the device doesn't provide that ID.
If I do this:
* When I click on the add button, I see 2 lines named AKS HASP HL 3.25 [0325]
* If I click on the first line, the device is added in the list
* If I then check the details of the filter, I have (approximative translations, my version is in French) : Name=AKS HASP HL 3.25 [0325]; Vendor ID=0529; Product ID=0001; Revision=0325; Builder=AKS; Product=HASP HL 3.5; Serial Number= ; Port= ; Remotely=No
(serial number and port are empty)

Since the port was empty, I assumed the serial number was also empty by default to allow any device of the same kind. But maybe, it's a wrong assumption.
mpack wrote:
NicoV wrote: The problem is that when the two keys are plugged in the host, then strange behaviours occur when trying to affect one of the key to the VM : either the key simply vanishes from the menu, or it stays in the menu but displayed as Unknown, or its status change from Occupied (Occupé in French) to Captured (Capturé in French) but without the key becoming visible to the VM.
Let's clarify: you are doing this in the VM settings, right? You are not trying to grab a USB device while the VM is running?
No, when I do this in the VM settings, it seems that Virtual Box tries to affect both keys to the VM when I start the VM.
That's why I'm trying to do this while the VM is running, using the menu above the VM screen. That's what I was trying to explain in my 3rd post:
* Plug one key in the host
* Start the first VM
* Affect the key to the VM using the menu : it works
* Stop the VM
...
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

NicoV wrote:
mpack wrote:
NicoV wrote: I do believe that the keys can be distinguished (probably by serial number, I just don't know how to find that information).
If you go to the USB filter part of the VM settings, create a new filter from an existing device (second icon down,
usbadd.png
), and select a device from the list of those known to the host (so it can't already have been grabbed by a VM), then the filter will be filled with all of the ID information published by the device, including a serial number if it defines one. If a field is blank then the device doesn't provide that ID.
If I do this:
* When I click on the add button, I see 2 lines named AKS HASP HL 3.25 [0325]
* If I click on the first line, the device is added in the list
* If I then check the details of the filter, I have (approximative translations, my version is in French) : Name=AKS HASP HL 3.25 [0325]; Vendor ID=0529; Product ID=0001; Revision=0325; Builder=AKS; Product=HASP HL 3.5; Serial Number= ; Port= ; Remotely=No
(serial number and port are empty)

Since the port was empty, I assumed the serial number was also empty by default to allow any device of the same kind. But maybe, it's a wrong assumption.
...
I tried the following:
* Plug the 2 keys in the host, and restart completely the host
* In the VM settings, add the device by selecting one of the existing keys.
* In the VM settings, add a port information (0001) in the filter so that only one key would be assigned to the VM.
* Start the VM
* In the Devices / USB devices menu above the VM, I know have: 1 Unknown device [0325] (status Retenu = kept ?), 1 AKS HASP HL 3.25 [0325] (status Occupé = Occupied ?)
* In the Device Manager of the host: no key is visible

So, it seems that Virtual Box tried to assign the first key to the VM, but that it didn't work well.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Problem with multiple USB devices

Post by mpack »

One note about terminology: you keep saying "affect" when it would less confusing if you said connect, join or mount.

I'm not sure that the port plays any part in selection of a device. It's merely a current location (an address), it does not help in uniquely identifying a device (at least not with the way filtering currently works).

I should also say that if your practise is to have the device plugged in before starting the VM then that will often cause problems, because the host will own the device and doesn't always give it up easily. Restarting the host doesn't help at all.

Try this (I don't want to know if this is what you prefer, I only want to know if it works - because I don't have two identical USB devices here to test with) :
  1. Shut down all VMs, open the first VM's settings and create a filter for the HASP key in vm settings | USB.
  2. Unplug all keys.
  3. Start one VM. (VM1) When it reaches the desktop, plug in one HASP key.
  4. If you get a "new hardware found" message, then allow the VirtualBox software to install the USB filter driver on the host.
  5. Unplug the key, shut down VM1, then repeat steps (1-4) with the second VM (VM2).
  6. VM2 is still running, make sure it has the focus then plug in a HASP key. Confirm that VM2 picks it up.
  7. Leave VM2 running, start VM1. When it reaches the desktop, and while making sure that the VM1 window still has the focus, plug in a second HASP key. Confirm that VM1 picks up this key.
Report anything unexpected.
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

mpack wrote:Try this (I don't want to know if this is what you prefer, I only want to know if it works - because I don't have two identical USB devices here to test with) :
  1. Shut down all VMs, open the first VM's settings and create a filter for the HASP key in vm settings | USB.
  2. Unplug all keys.
  3. Start one VM. (VM1) When it reaches the desktop, plug in one HASP key.
  4. If you get a "new hardware found" message, then allow the VirtualBox software to install the USB filter driver on the host.
  5. Unplug the key, shut down VM1, then repeat steps (1-4) with the second VM (VM2).
  6. VM2 is still running, make sure it has the focus then plug in a HASP key. Confirm that VM2 picks it up.
  7. Leave VM2 running, start VM1. When it reaches the desktop, and while making sure that the VM1 window still has the focus, plug in a second HASP key. Confirm that VM1 picks up this key.
Report anything unexpected.
I did the following (results are not what you expected as I understand it):
Note: HASP keys have a light on them which is on when they are connected and correctly mounted.
  1. Start the host (Win 8.1), with no keys
  2. Plug the 2 keys (both lights are on)
  3. Start Virtual Box
  4. Add a filter for HASP in VM settings for VM1 (Win XP)
  5. Unplug all keys
  6. Start VM1 and log in
  7. Keep focus in VM1 and plug one key => The key isn't connected to the guest, but is connected to the host, light is on
  8. Unplug the key
  9. Shutdown VM1
  10. Plug one key (light is on)
  11. Add a filter for HASP in VM settings for VM2 (Win 7)
  12. Unplug key
  13. Start VM2 and log in
  14. Keep focus in VM2 and plug one key => The key isn't connected to the guest, but is connected to the host, light is on
  15. As the keys don't seem to be mounted automatically to the host when I plug them after the host was started, I'm not sure how to proceed so I did the following: Connect the key to VM2 using the Device menu above the VM => the key is connected to VM2 (after light switching off and then on)
  16. Start VM1 and log in
  17. Keep focus in VM1 and plug the second key => the light of the first key shuts down meaning it's not connected to anything and stays off, the second key is connected to the host, light on for the second key
I haven't been able to have the key automatically connected to the VM when I plug the key in while the VM is running:
  1. Start the host with no key
  2. Start VM1 and log in
  3. Keep focus in VM1 and plug one key => The key is connected to the host
  4. Connect manually the key to the VM using the Device menu => The key is now connected to the guest
  5. Unplug the key => The guest sees that the key is gone
  6. Plug again the key => The key is connected to the host
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Problem with multiple USB devices

Post by mpack »

NicoV wrote: 7. Keep focus in VM1 and plug one key => The key isn't connected to the guest, but is connected to the host, light is on...
VirtualBox needs to install a host driver (filter driver) which intercepts messages from the USB device and redirects them to the VM. If the VM does not grab the USB device, but a USB filter is defined, then it's likely that your host permissions is not allowing the filter driver to be installed.

When you attach a USB device to a VM for the first time on a Windows host you should get a "New hardware found" dialog. This is not the guest saying that it's detected the HASP key, it is VirtualBox on the host detecting that a device has been inserted which matches a filter definition, and it's asking to install the corresponding host filter driver. If you cancel this dialog, or if Windows 8 is setup to to silently block this driver message, then USB will not work in the guest.

On Win8-64 hosts I expect you need to have admin rights, and you should also check the setting for "Driver Signature Enforcement" (which is active even in admin mode), making sure that it isn't set to silently reject non-MS drivers.
NicoV
Posts: 8
Joined: 26. Aug 2014, 11:46

Re: Problem with multiple USB devices

Post by NicoV »

Hi, and thanks for the help so far.

Yesterday, I ended up with Virtual Box refusing to start any VM. Even if I created a new VM, it wouldn't run.
That happened after several things : trying to disable Driver Signature Enforcement, updating Virtual Box to the last version (after seeing messages in Windows Event log that VB should be reinstalled after Windows being updated), various attempts to make HASP keys work.

Seeing the amount of problems I encountered with my configuration (Win 8.1 host, 2 HASP keys, ...), I decided to completely reinstall the computer from scratch, but downgrading it to Win 7, which I hope will be easier (and it will probably mean one VM less at least). I'm still in the process of reinstalling everything (downgrading a laptop from Win 8.1 to Win 7 is far from being straightforward...), and I don't have much available time in the next days. I'll keep you posted on the results when I have finished installation, whether it works or not. Thanks again.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Problem with multiple USB devices

Post by mpack »

AFAIK, Driver Signature Enforcement is a feature of 64bit versions of Win7 and later.

You don't need to disable it completely (MS have worked hard to make that difficult), just make sure it at least prompts you.

And I'm not sure what "the VirtualBox latest version" means to you: that requires me to assume that you know what the latest version is (I don't have update alerts enabled, so I don't know what the last alert was). If you mean 4.3.14 then I would avoid that for now - you don't need the additional complications. I would stick with 4.3.12.
Post Reply