A tool to enable VMQ in windows 2008 R2 machine.

什么是VMQ:

全称为Virtual Machine Queue,虚拟机队列 (VMQ)。是Windows 2008 R2提供的一个网络优化功能。支持 VMQ 功能的网络适配器能够为各个虚拟网络适配器创建唯一的网络队列,然后将队列直接连接到虚拟机的内存。此连接可以将数据包直接从系统管理程序发送到虚拟机,跳过虚拟化堆栈中的多个处理。不过因为目前只有Intel才能提供支持VMQ的硬件,所以默认也是禁用的。

 

VMQ Tool:

  Code logic:

    1. Find the VMQ capable NICs.

    2. Register some info.

    3. Disable/enable VMQ capable NICs.

 

  Find the VMQ capable NICs:

 

 

// Find the NIC with device name "Intel(R) Gigabit ET Dual Port*"

 

 

// It's hard code here, in my machine, the NICs support VMQ all with name like "Intel(R) Gigabit ET Dual Port".Should

 

 

// you got any better method to find the VMQ capable NICs, please share with me.

 

 

string nicString = " select * from win32_networkadapter where (name like '%Intel(R) Gigabit ET Dual Port%') and (NetConnectionStatus =2) ";

 

 

ManagementObjectSearcher mos = new ManagementObjectSearcher(nicString);

 

 

ManagementObjectCollection moc = mos.Get();

 

 

   Register some info.---------关键部分,通过写注册表来启用VMQ.

private

 

 

static void RegInfo()

{

 

 

RegistryKey hkml = Registry.LocalMachine;

 

 

RegistryKey system = hkml.OpenSubKey("SYSTEM", true);

 

 

RegistryKey currentControlSet = system.OpenSubKey("CurrentControlSet", true);

 

 

RegistryKey services = currentControlSet.OpenSubKey("services", true);

 

 

RegistryKey VMSMP = services.OpenSubKey("VMSMP", true);

 

 

RegistryKey Parameters = VMSMP.OpenSubKey("Parameters", true);

Parameters.SetValue(

 

"BelowTenGigVmqEnabled", "00000001", RegistryValueKind.DWord);

Parameters.SetValue(

 

"10GigVmqEnabled", "00000001", RegistryValueKind.DWord);

 

 

RegistryKey Control = currentControlSet.OpenSubKey("Control", true);

 

 

RegistryKey Class = Control.OpenSubKey("Class", true);

 

 

RegistryKey deviceID = Class.OpenSubKey("{4D36E972-E325-11CE-BFC1-08002BE10318}", true);

 

 

foreach (string index in indexList)

{

 

 

RegistryKey indexid = deviceID.OpenSubKey(index, true);

indexid.SetValue(

 

"*VMQLookaheadSplit", 1);

indexid.SetValue(

 

"*VMQVlanFiltering", 1);

indexid.SetValue(

 

"*VMQ", 1);

}

}

  

Disable/enable VMQ capable NICs:

 

//Diable NIC:

ManagementObject network

network.InvokeMethod(

 

"Disable", null); 

 

    // Enable NIC:

ManagementObject

 

 

network

network.InvokeMethod(

 

"Enable", null);

 

 

下载VMQTool 

 

工具使用时,请用最高管理员账户打开cmd运行。

关于源码,其实关键部分都已经包含在文章中。如果还需要全部源码,请留下email,仅供学习之用。

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值