您的位置:首页 > 其它

A tool to enable VMQ in windows 2008 R2 machine.

2010-01-04 15:26 375 查看
什么是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,仅供学习之用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: