提交 c6375aa7 编写于 作者: M Matthias Bolte

esx: Add support for the VMXNET 2 (Enhanced) NIC model

Add a test case and document it.
上级 cad91306
......@@ -307,10 +307,11 @@ ethernet0.checkMACAddress = "false"
<dd>
AMD PCnet32 network card for older guests.
</dd>
<dt><code>vmxnet</code>, <code>vmxnet3</code></dt>
<dt><code>vmxnet</code>, <code>vmxnet2</code>, <code>vmxnet3</code></dt>
<dd>
Special VMware VMXnet network card, requires VMware tools inside
the guest.
the guest. See <a href="http://kb.vmware.com/kb/1001805">VMware KB1001805</a>
for details.
</dd>
<dt><code>e1000</code></dt>
<dd>
......
......@@ -265,6 +265,7 @@ def->disks[0]...
def->nets[0]...
->model = <model> <=> ethernet0.virtualDev = "<model>" # default depends on guestOS value
ethernet0.features = "15" # if present and virtualDev is "vmxnet" => vmxnet2 (enhanced)
ethernet0.addressType = "generated" # default to "generated"
......@@ -1705,6 +1706,9 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
char virtualDev_name[48] = "";
char *virtualDev = NULL;
char features_name[48] = "";
long long features = 0;
char vnet_name[48] = "";
char *vnet = NULL;
......@@ -1737,6 +1741,7 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
ESX_BUILD_VMX_NAME(generatedAddress);
ESX_BUILD_VMX_NAME(address);
ESX_BUILD_VMX_NAME(virtualDev);
ESX_BUILD_VMX_NAME(features);
ESX_BUILD_VMX_NAME(networkName);
ESX_BUILD_VMX_NAME(vnet);
......@@ -1797,21 +1802,34 @@ esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
goto failure;
}
/* vmx:virtualDev -> def:model */
if (esxUtil_GetConfigString(conf, virtualDev_name, &virtualDev, 1) < 0) {
/* vmx:virtualDev, vmx:features -> def:model */
if (esxUtil_GetConfigString(conf, virtualDev_name, &virtualDev, 1) < 0 ||
esxUtil_GetConfigLong(conf, features_name, &features, 0, 1) < 0) {
goto failure;
}
if (virtualDev != NULL &&
STRCASENEQ(virtualDev, "vlance") &&
STRCASENEQ(virtualDev, "vmxnet") &&
STRCASENEQ(virtualDev, "vmxnet3") &&
STRCASENEQ(virtualDev, "e1000")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'vlance' or 'vmxnet' or "
"'vmxnet3' or 'e1000' but found '%s'"), virtualDev_name,
virtualDev);
goto failure;
if (virtualDev != NULL) {
if (STRCASENEQ(virtualDev, "vlance") &&
STRCASENEQ(virtualDev, "vmxnet") &&
STRCASENEQ(virtualDev, "vmxnet3") &&
STRCASENEQ(virtualDev, "e1000")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry '%s' to be 'vlance' or 'vmxnet' or "
"'vmxnet3' or 'e1000' but found '%s'"), virtualDev_name,
virtualDev);
goto failure;
}
if (STRCASEEQ(virtualDev, "vmxnet") && features == 15) {
VIR_FREE(virtualDev);
virtualDev = strdup("vmxnet2");
if (virtualDev == NULL) {
virReportOOMError();
goto failure;
}
}
}
/* vmx:networkName -> def:data.bridge.brname */
......@@ -2744,21 +2762,29 @@ esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
virBufferVSprintf(buffer, "ethernet%d.present = \"true\"\n", controller);
/* def:model -> vmx:virtualDev */
/* def:model -> vmx:virtualDev, vmx:features */
if (def->model != NULL) {
if (STRCASENEQ(def->model, "vlance") &&
STRCASENEQ(def->model, "vmxnet") &&
STRCASENEQ(def->model, "vmxnet2") &&
STRCASENEQ(def->model, "vmxnet3") &&
STRCASENEQ(def->model, "e1000")) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting domain XML entry 'devices/interfase/model' "
"to be 'vlance' or 'vmxnet' or 'vmxnet3' or 'e1000' "
"but found '%s'"), def->model);
"to be 'vlance' or 'vmxnet' or 'vmxnet2' or 'vmxnet3' "
"or 'e1000' but found '%s'"), def->model);
return -1;
}
virBufferVSprintf(buffer, "ethernet%d.virtualDev = \"%s\"\n",
controller, def->model);
if (STRCASEEQ(def->model, "vmxnet2")) {
virBufferVSprintf(buffer, "ethernet%d.virtualDev = \"vmxnet\"\n",
controller);
virBufferVSprintf(buffer, "ethernet%d.features = \"15\"\n",
controller);
} else {
virBufferVSprintf(buffer, "ethernet%d.virtualDev = \"%s\"\n",
controller, def->model);
}
}
/* def:type, def:ifname -> vmx:connectionType */
......
config.version = "8"
virtualHW.version = "4"
ethernet0.present = "true"
ethernet0.virtualDev = "vmxnet"
ethernet0.features = "15"
ethernet0.networkName = "VM Network"
ethernet0.connectionType = "bridged"
ethernet0.addressType = "static"
ethernet0.address = "00:50:56:11:22:33"
<domain type='vmware'>
<uuid>00000000-0000-0000-0000-000000000000</uuid>
<memory>32768</memory>
<currentMemory>32768</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686'>hvm</type>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<interface type='bridge'>
<mac address='00:50:56:11:22:33'/>
<source bridge='VM Network'/>
<model type='vmxnet2'/>
</interface>
</devices>
</domain>
......@@ -145,6 +145,7 @@ mymain(int argc, char **argv)
DO_TEST("floppy-device", "floppy-device", esxVI_APIVersion_25);
DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_APIVersion_25);
DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_APIVersion_25);
DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25);
DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25);
......
config.version = "8"
virtualHW.version = "4"
guestOS = "other"
uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
displayName = "ethernet-vmxnet2"
memsize = "4"
numvcpus = "1"
ethernet0.present = "true"
ethernet0.virtualDev = "vmxnet"
ethernet0.features = "15"
ethernet0.networkName = "VM Network"
ethernet0.connectionType = "bridged"
ethernet0.addressType = "static"
ethernet0.address = "00:50:56:11:22:33"
<domain type='vmware'>
<name>ethernet-vmxnet2</name>
<uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
<memory>4096</memory>
<os>
<type>hvm</type>
</os>
<devices>
<interface type='bridge'>
<mac address='00:50:56:11:22:33'/>
<source bridge='VM Network'/>
<model type='vmxnet2'/>
</interface>
</devices>
</domain>
......@@ -190,6 +190,7 @@ mymain(int argc, char **argv)
DO_TEST("floppy-device", "floppy-device", esxVI_APIVersion_25);
DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_APIVersion_25);
DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_APIVersion_25);
DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25);
DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册