Skip navigation

Q: How can I tell which virtual machines are using Virtual Machine Device Queues with Hyper-V?

A: I wrote a basic Windows PowerShell script that exposes the properties VMQOffloadUsage, which tells you if the port is using Virtual Machine Device Queues (VMDq), and VMQOffloadWeight, which tells you the weight of the port for when the virtual machine (VM) manager is deciding which VM gets to use VMDq.

The script is below (you can change the colors I use to emphasize if VMDq is enabled or not):

# Display VMDq Status of all VMs on a host

param($computer = ".") 

$ns = "root\virtualization" 

# get all the VMs on the passed host
$vmList = gwmi -namespace $ns -computerName $computer Msvm_ComputerSystem
foreach ($vm in $vmList)
{
    $vmName = $vm.ElementName
    # get its related vssd 
    $vssd = gwmi -namespace $ns -computerName $computer -query "associators of {$vm} where AssocClass=Msvm_SettingsDefineState" 

    # get its synthetic and enumlated NICs 
    $nics = gwmi -namespace $ns -computerName $computer -query "associators of {$vssd} where AssocClass=Msvm_VirtualSystemSettingDataComponent" | 
        where {$_.ResourceType -eq 10 -and ($_.ResourceSubType -eq 'Microsoft Synthetic Ethernet Port' -or 
                                            $_.ResourceSubType -eq 'Microsoft Emulated Ethernet Port')}
     
    foreach ($nic in $nics) 
    { 
       if($nic.Connection -ne $null)
       {
            # get the connected port. 
            $connectedPort = [wmi]$nic.Connection[0] 
            $PortName = $connectedPort.Name
            $PortVMQUsage = $connectedPort.VMQOffloadUsage
            $PortVMQWeight = $connectedPort.VMQOffloadWeight
            if($PortVMQUsage -eq 1)
            {
                write-host -ForegroundColor Green "$vmName using VMDq - Weight "$PortVMQWeight""
            }
            else
            {
                write-host -ForegroundColor DarkRed "$vmName not using VMDq - Weight "$PortVMQWeight""
            }
            write-host "(Port "$PortName")`n"
        }  
    } 
}

To use it, just call the script and pass the Hyper-V host. For example, I entered the following:

PS D:\projects\PowerShell> .\VMVMDqStatus.ps1 savdalbfs01.savilltech.net

And the output below is what I received. The output shows the VM, if VMDq is being used currently, its weight and the name of the actual SwitchPort used by the VM:

savdalthinpc not using VMDq - Weight 100
(Port 951a97d7-69eb-4f1f-bad9-bb3be194aa4f)

savdalync01 not using VMDq - Weight 100
(Port 6711796a-6f84-4b3b-a01e-dc002a208e5e)

savdalclient.savilltech.net not using VMDq - Weight 100
(Port 74b637b6-96c9-451d-a3f6-cf3d1104f983)

savloncli01 not using VMDq - Weight 100
(Port 1ad33209-e202-44dc-b188-5a2d533d2f40)

savdalclient2.savilltech.net not using VMDq - Weight 100
(Port 243d239a-fa75-4f9e-a5ad-b0af81fc6f04)

hypervserv not using VMDq - Weight 100
(Port 845929e1-5b14-4e4b-a029-c8c2f4dbc2b7)

savdalvmm12 not using VMDq - Weight 100
(Port 3e022e1e-78c2-487b-9d11-98dcae97cc20)

savdalfs01 using VMDq - Weight 100
(Port 31dc05f9-c0bb-47ab-88db-f29ce3422d1a)

APPVSequence not using VMDq - Weight 100
(Port aff16ebf-e955-4019-92c2-0d90fee32591)

savdalfim01 not using VMDq - Weight 100
(Port d3bd871d-ba59-413f-81c3-890c82607989)

savdalappv01 not using VMDq - Weight 100
(Port 9f66bbbd-baf4-4ba5-a7a9-b13925046512)

PXETest not using VMDq - Weight 100
(Port d201e42f-33d5-42ec-b1f7-f46999f0a982)

savdalts01 using VMDq - Weight 100
(Port 784bd776-adbf-4f5e-af51-469da9b7908a)

savdalex10 not using VMDq - Weight 100
(Port 45e2415d-5f42-49c7-ba5b-4bc07c26f059)

savdalex10 not using VMDq - Weight 100
(Port 602e7de0-6ff5-40da-b859-1dd475aa6295)

savdalrodc01 not using VMDq - Weight 100
(Port abd4051f-6186-40ed-b6cc-a60b5d12de99)
 

Get more answers at John Savill's FAQs for Windows.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish