Introduction


Using a USB device with ESX… without. Has this ever happened to you? For one reason or another, you’ve been forced to suffer at the hands of a corporation that forces its customers to use hardware based methods to comply with licensing restrictions. These hardware methods often take the form of a USB-based dongle that has to exist physical on the server. Of course, as organizations continue to virtualize more and more of their environments; these hardware devices grow more and more bothersome. Although there are products on the market that allow virtualized servers to talk to USB hubs over TCP/IP, with VMware vSphere 4.1, VMware has added USB pass-through capability to ESX allowing you to skip the need to buy one of these TCP/IP devices and simply plug a USB device directly into your server.

USB devices are added to vSphere-based virtual machines in two steps:

  1. You must add a USB Controller to any virtual machine to which you’d like to add a USB device.
  2. You must then associate any installed USB devices to individual virtual machines.

Add a USB Controller to a Virtual Machine



This process begins with you editing the properties of an existing virtual machine and adding a USB Controller device. You can see the inception of this process in Figure 1 below. You don’t even need to shut down the virtual machine to add the USB controller device. In the figure below, I began the process of adding the USB controller to a running virtual machine. To add the USB controller device, select USB Controller and click the Next button.


Figure 1: Add a USB Controller to the virtual machine

Once you move on with the process, you’ll see a screen like the one shown in Figure 2. This is an informational screen that lets you know that a newly installed USB Controller will allow the installation of USB devices on the virtual machine and that the controller itself has no configurable settings.


Figure 2: USB Controller device information

Moving on, you are presented with another informational screen – shown in Figure 3 – that finalizes the process of adding the USB Controller to the virtual machine. Click the Finish button to continue.


Figure 3: Finalize the installation of the USB controller device

Once the USB controller device has been added to the virtual machine, switching to the virtual machine console reveals that the virtual machine’s operating system – in this case, Windows 7 64-bit – is adding appropriate drivers to the guest virtual machine. You can see this in action in Figure 4.


Figure 4: Windows 7 is adding appropriate drivers

In Figure 5, you’ll see that his virtual machine now contains USB devices.


Figure 5: The virtual machine has USB devices

As a note, I’d like to point out that, although you could add a USB controller to vSphere 4.0-baed virtual machines, doing so yielded no result.
Associate a USB Device with a Virtual Machine



At this point, the virtual machine is ready to receive a USB device from the server. I should note that the process is not automatic; you still need to associate a USB device with an individual virtual machine. This is actually preferable to an automated process since it allows you to decide which virtual machine should get the device rather than just having a virtual machine grab a new device.

I’ve attached to my VMware ESXi server a SanDisk Cruzer flash drive that I will now associate with a running Windows 7 virtual machine.

The second phase begins by once again opening the properties for one of your virtual machines. From the virtual machine’s properties window, make sure you’re on the Hardware tab and, from this tab, click the Add button to add a new device. In the Device Type window, choose USB Device and click the Next button. You can see the Device Type screen in Figure 6 below.


Figure 6: Add a new USB device

Once you move to the next step of the process, you are asked to decide which USB-attached device you wish to associate with the virtual machine. In Figure 7, you will see that I’ve selected the SanDisk Cruzer device.

You will also notice an option on this screen that reads Support vMotion while device is connected. When you select this option, if you vMotion a virtual machine to another ESX/ESXi host, the USB device will follow. This is yet another example of VMware’s continuing efforts to decouple hardware state from the computing environment and make actual servers simple stateless compute nodes.

When a virtual machine is vMotioned away from a host – assuming that all connected USB devices are configured to allow vMotion – that host maintains its connections to the USB devices. As soon as you suspend or shut down that virtual machine, however, these USB connections are lost until such time that you migrate the virtual machine back to the original host.

Once you choose your device, click the Next button.


Figure 7: Choose the device you wish to associate

A was the case with the USB controller device, you will see a summary page for the installation of the USB device on the virtual machine as well. Figure 8 gives you a look at this page. Click the Finish button to complete the process.


Figure 8: Summary information about the new USB device

As you can see in Figure 9, the new device is ready to use in the virtual machine.


Figure 9: The new device is ready to use

Clicking the pop up shown in Figure 9 yields the screen shown in Figure 10, which shows you exactly what type and model USB device was added to the virtual machine.


Figure 10: Information about the newly installed USB device
Removing USB Devices and Controllers



Perhaps one of your vendors has realized that making life difficult for customers is no longer in their best business interests and has moved to a software licensing compliance method and given up on hardware dongles. At this point, you’re able to remove that USB device from a virtual machine along with the controller. Although you don’t absolutely need to take the step of actually removing the software components, doing so does keep your environment cleaner.

Before you can consider removing a USB controller device from a virtual machine, you need to first remove any USB devices you have installed after which point you can remove the USB controller. To remove a USB device from a virtual machine, you need to disconnect it in the virtual-machine based operating system. Once you’ve done so, open the properties for the virtual machine, select the USB device and click the Remove button, as shown in Figure 11.


Figure 11: Remove the USB device

The system doesn’t immediately remove the hardware, however. Instead, it marks the device for removal (Figure 12). Once you click the OK button, the device is actually removed from the system.


Figure 12: The USB device is marked for deletion

After you’ve removed the USB device, it’s time to remove the USB controller device using the same process that you used for the USB device, except this time, choose the USB controller device shown in Figures 13 and 14. Click the OK button to complete the removal process.


Figure 13: Begin removing the USB controller device


Figure 14: The USB controller is marked for deletion

When you’re done, you’ll see that both the USB controller and the USB device have been removed from the virtual machine.


Figure 15: USB devices have been removed from the virtual machine
vSphere 4.1 and USB Device Facts and Limitations



While being able to add USB devices directly to a host is good, there are some things that you should keep in mind regarding this feature. First of all, your host hardware needs to be able to actually support either USB 1.1 or USB 2.0 devices. Next, in order to add a USB controller to an ESX/ESXi-based virtual machine, your virtual machine must be running at least virtual hardware version 7.

As you add more and more USB devices to a host and attach those devices to virtual machines on that host, the way that the USB hubs and devices chain together affects exactly how many devices can be supported. Understanding how your physical server handles USB internally will help you to better understand maximums.

There are some hard maximums you need to keep in mind as well:

  • The USB arbitrator can monitor up to 15 USB controllers at the same time. If you’re using a server that has a whole lot of USB controllers and you connect USB devices to controllers numbered beyond 15, the devices cannot be associated with a virtual machine.
  • A single virtual machine can receive up to 20 host-based USB devices.
  • A USB device can be associated with only one virtual machine at any time. You cannot share a USB device between virtual machines.


If you attempt to add a compound USB device – that is, a USB device that includes a USB hub as well as one or more other USB devices – to a virtual machine, vSphere filters out the hub portion of the device and simply passes through the remaining USB devices as separate devices to vSphere.

VMware cautions you to avoid adding unsupported USB devices to a host. The company maintains a list of supported USB devices here. You’ll note that this compatibility list is pretty short at present especially considering the multitude of USB-based devices that are available in the marketplace.

And here’s a critical note: If you have configured any of your virtual machines for hot-adding of either processor or memory, before you actually undertake the hot-adding process, you need to remove USB devices from the virtual machine. The hot adding process disconnects USB devices. So, for example, if you’re using a USB mass storage device and you hot add RAM, you could experience data loss.

Further, if you’ve decided to use USB devices on an ESX/ESXi host that participates in a Distributed Resource Scheduler (DRS) that has Distributed Power Management (DPM), you’ll need to disable DPM on the individual hosts holding USB devices or you may risk intermittent errors as power settings are adjusted.
Thoughts & Summary



Although companies have provided products that work around the need to provide USB connectivity to individual virtual machines, with vSphere 4.1, VMware has provided a more direct connectivity method that negates the need for specialized hardware. All that said, even though VMware has made this possible, some organizations might wish to opt for the third party workaround instead. VMware’s solution is very good but could break down as virtual machines move around to different hosts.




موضوعات مشابه: