code: func (vm *VirtualMachine) getVirtualDeviceByPath(ctx context.Context, diskPath string) (types.BaseVirtualDevice, error) {
  	vmDevices, err := vm.Device(ctx)
  	if err != nil {
  		klog.Errorf("Failed to get the devices for VM: %q. err: %+v", vm.InventoryPath, err)
  		return nil, err
  	}
  
  	// filter vm devices to retrieve device for the given vmdk file identified by disk path
  	for _, device := range vmDevices {
  		if vmDevices.TypeName(device) == "VirtualDisk" {
  			virtualDevice := device.GetVirtualDevice()
  			if backing, ok := virtualDevice.Backing.(*types.VirtualDiskFlatVer2BackingInfo); ok {
  				if matchVirtualDiskAndVolPath(backing.FileName, diskPath) {
  					klog.V(LogLevel).Infof("Found VirtualDisk backing with filename %q for diskPath %q", backing.FileName, diskPath)
  					return device, nil
  				}
  			}
  		}
  	}
  	return nil, nil
  }
docs: // getVirtualDeviceByPath gets the virtual device by path