Physical Platform Resources

ESXi hosts allow direct access to physical devices in limited scenarios.
Many vSphere devices are implemented as virtual devices. Access attempts from the guest are trapped and implemented in software. For example, the keyboard is implemented by trapping I/O port access in the guest and transmitting keycode data obtained using a remote console connection; it is not possible to connect the physical keyboard to any VM.
Several categories of devices can be configured for direct access, including USB, storage, optical disc drives, virtual GPU, and PCI passthrough (DirectPath I/O) devices. Use of physical "passthrough" resources is uncommon, because it prevents vMotion. Some physical resources can be configured for access and still allow vMotion.
Physical device access can be revoked by removing an associated virtual device from its VM configuration.

USB

In its hardware devices field, data object
VirtualMachineConfigInfo
may contain the type
VirtualUSB
. Virtual devices can have a backing field, which specifies access to a particular physical device. For USB connectivity, the VM must have a compatible virtual controller configured for the VM. Programs can set the type of backing object:
  • vim.vm.device.VirtualUSB.USBBackingInfo
    – USB device is attached to the ESXi host as a passthrough device, which disallows vMotion.
  • vim.vm.device.VirtualUSB.RemoteHostBackingInfo
    – USB device is attached to a particular remote ESXi host, which remains attached to the device during vMotion.
  • vim.vm.device.VirtualUSB.RemoteClientBackingInfo
    – USB device gets forwarded over the network along with the VM’s remote console.
See data object
VirtualUSB
in the
vSphere API Reference
for details. You can use the
esxcli
command to find host-attached USB devices for connection to a VM. The following command prints available devices, including VID (Vendor ID) and PID (Product ID), which programs use to configure backing objects types above:
esxcli hardware usb passthrough device list
You can also attach USB devices to a VM using the Host Client. See procedure "Add a USB Device to a Virtual Machine in the VMware Host Client" on https://docs.vmware.com.

Storage

Passthrough storage devices are known as Raw Device Mappings (RDM) and represent essentially a passthrough of SCSI commands to a particular LUN. RDM can be used with vMotion if LUN IDs are kept consistent across participating ESXi hosts.
Configuring an RDM occurs through the
vim.vm.ConfigInfo.hardware.devices[]
array, with instances of type
vim.vm.device.VirtualDisk
that have backing field of type
vim.vm.device.VirtualDisk.RawDiskVer2BackingInfo
.

Physical CD-ROM or DVD

A physical disc drive on a host can be attached directly to a VM. Such drives are automatically detected by the host; no configuration is required. You can configure VMs to access a physical disc drive. See procedure "Add a CD or DVD Drive to a Virtual Machine in the vSphere Client" on https://docs.vmware.com.

Virtual GPU (vGPU)

When used in conjunction with an nVidia graphics card and the nVidia GRID software package, a vGPU can be passed through to one or more VMs for GPU or general purpose GPU (GPGPU) acceleration.

PCI Passthrough

ESXi allows specific PCI devices to be configured for passthrough use by a VM instead of by the host. This feature is called DirectPath I/O and is used in limited cases for improved low-latency performance. When operating in this configuration, the PCI device must be behind a VT-d bridge that implements an IOMMU. VMkernel arranges for this IOMMU to be programmed with only pages that the guest is allowed to access. This ensures that the guest can program the PCI device to access only pages that the guest should access. If the VM powers off or becomes unavailable, the PCI device receives a PCI “reset” to clear any pending DMA transactions before detaching the IOMMU domain from the device.
The host configuration that indicates which devices are eligible for assignment to VMs is through the
vim.host.PciPassthruSystem
managed object, accessible using the host’s
ConfigManager.pciPassthruSystem
. The
UpdatePassthruConfig
method on this managed object can be used to enable or disable PCI passthrough for a particular PCI bus address (bus:slot:function). Making a device eligible for passthrough usually requires host reboot. Devices not configured for PCI passthrough on the host are instead claimed by ESXi and are thus unavailable to VMs.
The VM configuration uses
vim.vm.ConfigInfo.hardware.devices[]
. When an instance in that array is of type
vim.vm.device.VirtualPCIPassthrough
, the backing field has type
vim.vm.device.VirtualPCIPassthrough.DeviceBackingInfo
and this object describes the exact PCI device that is being passed through.
To enable power-on of a VM, the administrator must specify a PCI device that can be configured for assignment to the VM.

Physical Network

ESXi does not allow guests to have direct access to a physical network except when the administrator configures a virtual switch with a network interface attached to specific physical network interfaces. Any VMs expected to have external network access may be configured to have their virtual network interfaces connected to this virtual switch. See Using a Distributed Virtual Switch for information about configuring virtual switches and virtual network interface backings.
Alternatively, the administrator can configure a virtual switch to connect with a specific VLAN on the physical network and then connect VMs to that virtual switch. This provides logical isolation of the VMs from the physical network. See Adding a Virtual Port Group for information about configuration of the management network.