VMware Cloud Community
leedudmish
Contributor
Contributor

Usb Device Info

Hi All,

have a bit of a query wondering someone may be able to help with. Below is based on Esxi 6.5.

We have a number of VM's on a host which we are passing through a usb device to each virtual machine, the issue we have is that the devices are all the same make model so from and ESXI perspective they all have the same name - this is driven by the vendorid and product id of the device firmware and as I understand is not able to be modified at all and there does not appear to be a notes section on the device to differentiate.

I am able to run the command "lsusb" on the host via ssh which lists all the usb devices attached to the ESXI host - they all have the same name however the difference being the bus and device ID are unique which is great as we can correlate this to each device as we plug them in.

However the info I need is to be able to do is correlate that bus and device id to a virtual machine it is being presented to so we know what device is mapped to which virtual machine.

I have tried the powercli command Get-UsbDevice -VM machinename however this just returns a value of USB1 which does not help us at all, I have checked the VMX file of a machine with a device mapped and there is no information contained within that on the usb device id.

Hopeful someone out there may have a good idea of getting the info we need or another idea of what we can do to correlate the usb devices to a VM.

Thanks

Lee

Reply
0 Kudos
4 Replies
bluefirestorm
Champion
Champion

Unless you are looking for some specific script but this is the manual way.

There should be information about the bus and device ID in the vmx configuration file of the VM which takes the form

pciPassthru[n].id = "nn:nn.n"

So you should be able to see as well in the vmware.log or from the ESXi host client as the passthrough device should have been pre-assigned and not randomly picked at startup.

Example:

pciPassthru0.id = "09:00.0"

Reply
0 Kudos
leedudmish
Contributor
Contributor

Hi bluefirestorm,

Thanks for the quick response the device is not in pass-through mode it is a usb device attached to the vm via the gui so I dont think the above line exists in the vmx file.

Will take a look at the vmware.log and see what we can see.

Cheers,

Lee

Reply
0 Kudos
bluefirestorm
Champion
Champion

Sorry about that I misinterpreted the USB pass through. So it is a straightforward USB passthrough just like USB thumb drives.

Yes, the vmware.log might be the next best thing. For Fusion/Workstation VMs, usually there is a path and sometimes a serial number of the device. I would think it would be the same for ESXi VMs to allow autoconnect either by path or by vendor/device ID. So either the path or serial number would help along the way.

Assuming the path is shown in the vmware.log, just plug the same serial number USB device to the same VM using different ports to work out the different paths.

Reply
0 Kudos
ArtooJunior
Contributor
Contributor

I have been having this same issue and finally ended up using get-usbdevice as a boolean operator to show just the VMs and hosts as follows:

Foreach    ($vm in (Get-VM)){

If((get-usbdevice $vm) -ne $null){

Write-Host "Virtual Machine" $vm "currently running on" $vm.vmhost

}

}

Reply
0 Kudos