VMware Cloud Community
MaaTaa
Contributor
Contributor
Jump to solution

How to create a VMDirectPath IO (Paththrough) device by using PowerCLI

Hi all,

 

I would like to create a VMDirectPath IO (Paththrough) device by using CLI.

Could you please provide me the command to achieve this through PowerCLI?

 

Thank you

MaaTaa

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The following will enable Passthru on devices that are capable and where Passthru is not yet enabled.

$esxName = 'MyEsx'

$esx = Get-VMHost -Name $esxName

$ptMgr = Get-View -Id $esx.ExtensionData.ConfigManager.PciPassthruSystem

$config = @()

$ptMgr.PciPassthruInfo | where{$_.PassthruCapable -and -not $_.PassthruEnabled} | %{

    $ptConfig = New-Object VMware.Vim.HostPciPassthruConfig

    $ptConfig.Id = $_.Id

    $ptConfig.PassthruEnabled = $true

    $config += $ptConfig

}

if($config){

    $ptMgr.UpdatePassthruConfig($config)

}

else{

    Write-Host "No Passthru capable devices found"

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Do you mean the complete scenario, i.e. enabling devices on the ESXi node, reserving memory on the VM and changing the vNIC on the VM?

Or just the vNIC setting on the VM?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
MaaTaa
Contributor
Contributor
Jump to solution

I want to 1) make a PCI device enable for passthrough on the ESXi node and 2) attach the passthrough device to a VM.

I found that Add-PassthroughDevice command can be used for 2).
I am looking for a command for 1).

Thank you.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The following will enable Passthru on devices that are capable and where Passthru is not yet enabled.

$esxName = 'MyEsx'

$esx = Get-VMHost -Name $esxName

$ptMgr = Get-View -Id $esx.ExtensionData.ConfigManager.PciPassthruSystem

$config = @()

$ptMgr.PciPassthruInfo | where{$_.PassthruCapable -and -not $_.PassthruEnabled} | %{

    $ptConfig = New-Object VMware.Vim.HostPciPassthruConfig

    $ptConfig.Id = $_.Id

    $ptConfig.PassthruEnabled = $true

    $config += $ptConfig

}

if($config){

    $ptMgr.UpdatePassthruConfig($config)

}

else{

    Write-Host "No Passthru capable devices found"

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

To enable it on a vNIC for example, have a look at 1.  Re: How to Disable / Enable a VM's Network Adapter DirectPath I/O Parameter


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
MaaTaa
Contributor
Contributor
Jump to solution

Hi LucD,

Thanks a lot for your help. That worked perfectly.

Reply
0 Kudos
tgbennett
Enthusiast
Enthusiast
Jump to solution

Hi,

I realize this is an older thread but it was very useful in setting up GPU passthrough devices for NVIDIA M60 GPU's. I am running into a problem when adding the GPU's to a vm in that it only lets me add two then throws an error.

After configuring the host with your commands when I add the Passthrough devices to a vm using

$esx | get-passthroughdevice | Where {($_.State -eq "Active") -and ($_.Name -like "NVIDIATesla*")} | add-PassThroughDevice -VM $MyVM I get the error Add-PassthroughDevice The maximum number of PCI devices has been reached for VM after two are added. There are four devices. I also tried a foreach and tried adding only the third with

$MyGPUs = $esx | get-passthroughdevice | Where {($_.State -eq "Active") -and ($_.Name -like "NVIDIATesla*")}

add-PassThroughDevice -VM $MyVM -PassthroughDevice $MyGPUs[3].

Is there something else I can try? Maybe there is a PciPassthruConfig object for a vm similar to New-Object VMware.Vim.HostPciPassthruConfig like New-Object VMware.Vim.VMPciPassthruConfig.

Do you have any suggestions?

Reply
0 Kudos