vsphere/internal/virtualdevice/virtual_machine_device_subresource.go
func (r *Subresource) FindVirtualDevice(l object.VirtualDeviceList) (types.BaseVirtualDevice, error) {
	if key := r.Get("key").(int); key > 0 {
		log.Printf("[DEBUG] FindVirtualDevice: Looking for device with key %d", key)
		if dev := l.FindByKey(int32(key)); dev != nil {
			log.Printf("[DEBUG] FindVirtualDevice: Device found: %s", l.Name(dev))
			return dev, nil
		}
		return nil, fmt.Errorf("could not find device with key %d", key)
	}
	return r.FindVirtualDeviceByAddr(l)
}
func (r *Subresource) FindVirtualDevice(l object.VirtualDeviceList) (types.BaseVirtualDevice, error) {
	if key := r.Get("key").(int); key > 0 {
		log.Printf("[DEBUG] FindVirtualDevice: Looking for device with key %d", key)
		if dev := l.FindByKey(int32(key)); dev != nil {
			log.Printf("[DEBUG] FindVirtualDevice: Device found: %s", l.Name(dev))
			return dev, nil
		}
		return nil, fmt.Errorf("could not find device with key %d", key)
	}
	return r.FindVirtualDeviceByAddr(l)
}
// FindVirtualDevice will attempt to find an address by its device key if it is
// > 0, otherwise it will attempt to locate it by its device address.