[libvirt] [PATCH] esx: Add support for the VMXNET 2 (Enhanced) NIC model

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a test case and document it.
---
 docs/drvesx.html.in                            |    5 +-
 src/esx/esx_vmx.c                              |   60 +++++++++++++++++-------
 tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.vmx |    9 ++++
 tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml |   20 ++++++++
 tests/vmx2xmltest.c                            |    1 +
 tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.vmx |   14 ++++++
 tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.xml |   15 ++++++
 tests/xml2vmxtest.c                            |    1 +
 8 files changed, 106 insertions(+), 19 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.xml

diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index 422a7f0..d454904 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -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>
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index c2e9be6..52c97e5 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -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 */
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.vmx
new file mode 100644
index 0000000..1c3f063
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.vmx
@@ -0,0 +1,9 @@
+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"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml b/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml
new file mode 100644
index 0000000..090f7ce
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-vmxnet2.xml
@@ -0,0 +1,20 @@
+<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>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index f3b3b5e..b26a703 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -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);
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.vmx
new file mode 100644
index 0000000..50709e2
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.vmx
@@ -0,0 +1,14 @@
+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"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.xml b/tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.xml
new file mode 100644
index 0000000..7d6d0e5
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-vmxnet2.xml
@@ -0,0 +1,15 @@
+<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>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index f9c4730..40386eb 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -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);
-- 
1.6.3.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]