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

[libvirt] [PATCH] esx: Fix 'vpx' MAC address range and allow arbitrary MAC addresses



The MAC addresses with 00:50:56 prefix are split into several ranges:

  00:50:56:00:00:00 - 00:50:56:3f:ff:ff  'static' range (manually assigned)
  00:50:56:80:00:00 - 00:50:56:bf:ff:ff  'vpx' range (assigned by a VI Client)

Erroneously the 'vpx' range was assumed to be larger and to occupy the
remaining addresses of the 00:50:56 prefix that are not part of the 'static'
range.

00:50:56 was used as prefix for generated MAC addresses, this is not possible
anymore, because there are gaps in the allowed ranges. Therefore, change the
prefix to 00:0c:29 which is the prefix for auto generated MAC addresses anyway.

Allow arbitrary MAC addresses to be used and set the checkMACAddress VMX option
to false in case the MAC address doesn't fall into any predefined range.

* docs/drvesx.html.in: update website accordingly
* src/esx/esx_driver.c: set the auto generation prefix to 00:0c:29
* src/esx/esx_vmx.c: fix MAC address range handling and allow arbitrary MAC
  addresses
* tests/vmx2xml*, tests/xml2vmx*: add some basic MAC address range tests
---
 docs/drvesx.html.in                              |   74 ++++++++++++++++++++--
 src/esx/esx_driver.c                             |    2 +-
 src/esx/esx_vmx.c                                |   49 +++++++++------
 tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx |    8 +++
 tests/vmx2xmldata/vmx2xml-ethernet-generated.xml |   19 ++++++
 tests/vmx2xmldata/vmx2xml-ethernet-other.vmx     |    8 +++
 tests/vmx2xmldata/vmx2xml-ethernet-other.xml     |   19 ++++++
 tests/vmx2xmldata/vmx2xml-ethernet-static.vmx    |    7 ++
 tests/vmx2xmldata/vmx2xml-ethernet-static.xml    |   19 ++++++
 tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx       |    7 ++
 tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml       |   19 ++++++
 tests/vmx2xmltest.c                              |    5 ++
 tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx |   13 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-generated.xml |   14 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-other.vmx     |   13 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-other.xml     |   14 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-static.vmx    |   12 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-static.xml    |   14 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx       |   12 ++++
 tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml       |   14 ++++
 tests/xml2vmxtest.c                              |    5 ++
 21 files changed, 320 insertions(+), 27 deletions(-)
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-generated.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-other.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-other.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-static.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-static.xml
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-generated.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-other.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-other.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-static.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-static.xml
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx
 create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml

diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index b7909ff..44a144f 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -16,8 +16,8 @@
         SOAP based
         <a href="http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/";>
         VMware Virtual Infrastructure API</a> (VI API) to communicate with the
-        ESX server, like the VMware Virtual Infrastructure Client does. Since
-        version 4.0 this API is called
+        ESX server, like the VMware Virtual Infrastructure Client (VI client)
+        does. Since version 4.0 this API is called
         <a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/";>
         VMware vSphere API</a>.
     </p>
@@ -159,7 +159,7 @@ type://[username ]hostname[:port]/[?extraparameters]
         There are several specialties in the domain XML config for ESX domains.
     </p>
 
-    <h3>Restrictions</h3>
+    <h3><a name="restrictions">Restrictions</h3>
     <p>
         There are some restrictions for some values of the domain XML config.
         The driver will complain if this restrictions are violated.
@@ -173,12 +173,13 @@ type://[username ]hostname[:port]/[?extraparameters]
         </li>
         <li>
             Valid MAC address prefixes are <code>00:0c:29</code> and
-            <code>00:50:56</code>
+            <code>00:50:56</code>. <span class="since">Since 0.7.6</span>
+            arbitrary <a href="#macaddresses">MAC addresses</a> are supported.
         </li>
     </ul>
 
 
-    <h3>Datastore references</h3>
+    <h3><a name="datastore">Datastore references</h3>
     <p>
         Storage is managed in datastores. VMware uses a special path format to
         reference files in a datastore. Basically, the datastore name is put
@@ -197,7 +198,68 @@ type://[username ]hostname[:port]/[?extraparameters]
     </p>
 
 
-    <h3>Available hardware</h3>
+    <h3><a name="macaddresses">MAC addresses</h3>
+    <p>
+        VMware has registered two MAC address prefixes for domains:
+        <code>00:0c:29</code> and <code>00:50:56</code>. These prefixes are
+        split into ranges for different purposes.
+    </p>
+    <table class="top_table">
+        <tr>
+            <th>Range</th>
+            <th>Purpose</th>
+        </tr>
+        <tr>
+            <td>
+                <code>00:0c:29:00:00:00</code> - <code>00:0c:29:ff:ff:ff</code>
+            </td>
+            <td>
+                An ESX server autogenerates MAC addresses from this range if
+                the VMX file doesn't contain a MAC address when trying to start
+                a domain.
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <code>00:50:56:00:00:00</code> - <code>00:50:56:3f:ff:ff</code>
+            </td>
+            <td>
+                MAC addresses from this range can by manually assigned by the
+                user in the VI client.
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <code>00:50:56:80:00:00</code> - <code>00:50:56:bf:ff:ff</code>
+            </td>
+            <td>
+                A VI client autogenerates MAC addresses from this range for
+                newly defined domains.
+            </td>
+        </tr>
+    </table>
+    <p>
+        The VMX files generated by the ESX driver always contain a MAC address,
+        because libvirt generates a random one if an interface element in the
+        domain XML file lacks a MAC address.
+        <span class="since">Since 0.7.6</span> the ESX driver sets the prefix
+        for generated MAC addresses to <code>00:0c:29</code>. Before 0.7.6
+        the <code>00:50:56</code> prefix was used. Sometimes this resulted in
+        the generation of out-of-range MAC address that were rejected by the
+        ESX server.
+    </p>
+    <p>
+        Also <span class="since">since 0.7.6</span> every MAC address outside
+        this ranges can be used. For such MAC addresses the ESX server-side
+        check is disabled in the VMX file to stop the ESX server from rejecting
+        out-of-predefined-range MAC addresses.
+    </p>
+<pre>
+ethernet0.checkMACAddress = "false"
+</pre>
+
+
+    <h3><a name="hardware">Available hardware</h3>
     <p>
         VMware ESX supports different models of SCSI controllers and network
         cards.
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 30e21e0..f86654a 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -184,7 +184,7 @@ esxCapsInit(virConnectPtr conn)
         return NULL;
     }
 
-    virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x50, 0x56 });
+    virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
     virCapabilitiesAddHostMigrateTransport(caps, "esx");
 
     /* i686 */
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index d3cad1d..4b334b6 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -266,8 +266,8 @@ def->nets[0]...
 
 
                                         ethernet0.addressType = "generated"     # default to "generated"
-                                        ethernet0.generatedAddressOffset = "0"  # ?
 ->mac = <value>                   <=>   ethernet0.generatedAddress = "<value>"
+                                        ethernet0.generatedAddressOffset = "0"  # ?
 
 
                                         ethernet0.addressType = "static"        # default to "generated"
@@ -277,10 +277,15 @@ def->nets[0]...
                                         ethernet0.addressType = "vpx"           # default to "generated"
 ->mac = <value>                   <=>   ethernet0.generatedAddress = "<value>"
 
+
+                                        ethernet0.addressType = "static"        # default to "generated"
+->mac = <value>                   <=>   ethernet0.address = "<value>"
+                                        ethernet0.checkMACAddress = "false"     # mac address outside the VMware prefixes
+
                                                                                 # 00:0c:29 prefix for autogenerated mac's -> ethernet0.addressType = "generated"
                                                                                 # 00:50:56 prefix for manual configured mac's
                                                                                 #          00:50:56:00:00:00 - 00:50:56:3f:ff:ff -> ethernet0.addressType = "static"
-                                                                                #          00:50:56:40:00:00 - 00:50:56:ff:ff:ff -> ethernet0.addressType = "vpx"
+                                                                                #          00:50:56:80:00:00 - 00:50:56:bf:ff:ff -> ethernet0.addressType = "vpx"
                                                                                 # 00:05:69 old prefix from esx 1.5
 
 
@@ -2602,6 +2607,7 @@ esxVMX_FormatEthernet(virConnectPtr conn, virDomainNetDefPtr def,
                       int controller, virBufferPtr buffer)
 {
     char mac_string[VIR_MAC_STRING_BUFLEN];
+    unsigned int prefix, suffix;
 
     if (controller < 0 || controller > 3) {
         ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
@@ -2654,33 +2660,36 @@ esxVMX_FormatEthernet(virConnectPtr conn, virDomainNetDefPtr def,
         return -1;
     }
 
+    /* def:mac -> vmx:addressType, vmx:(generated)Address, vmx:checkMACAddress */
     virFormatMacAddr(def->mac, mac_string);
 
-    if (def->mac[0] == 0x00 && def->mac[1] == 0x0c && def->mac[2] == 0x29) {
+    prefix = (def->mac[0] << 16) | (def->mac[1] << 8) | def->mac[2];
+    suffix = (def->mac[3] << 16) | (def->mac[4] << 8) | def->mac[5];
+
+    if (prefix == 0x000c29) {
         virBufferVSprintf(buffer, "ethernet%d.addressType = \"generated\"\n",
                           controller);
         virBufferVSprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
                           controller, mac_string);
         virBufferVSprintf(buffer, "ethernet%d.generatedAddressOffset = \"0\"\n",
                           controller);
-    } else if (def->mac[0] == 0x00 && def->mac[1] == 0x50 && def->mac[2] == 0x56) {
-        if (def->mac[3] <= 0x3f) {
-            virBufferVSprintf(buffer, "ethernet%d.addressType = \"static\"\n",
-                              controller);
-            virBufferVSprintf(buffer, "ethernet%d.address = \"%s\"\n",
-                              controller, mac_string);
-        } else {
-            virBufferVSprintf(buffer, "ethernet%d.addressType = \"vpx\"\n",
-                              controller);
-            virBufferVSprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
-                              controller, mac_string);
-        }
+    } else if (prefix == 0x005056 && suffix <= 0x3fffff) {
+        virBufferVSprintf(buffer, "ethernet%d.addressType = \"static\"\n",
+                          controller);
+        virBufferVSprintf(buffer, "ethernet%d.address = \"%s\"\n",
+                          controller, mac_string);
+    } else if (prefix == 0x005056 && suffix >= 0x800000 && suffix <= 0xbfffff) {
+        virBufferVSprintf(buffer, "ethernet%d.addressType = \"vpx\"\n",
+                          controller);
+        virBufferVSprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
+                          controller, mac_string);
     } else {
-        ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
-                  "Unsupported MAC address prefix '%02X:%02X:%02X', expecting "
-                  "'00:0c:29' or '00:50:56'",
-                  def->mac[0], def->mac[1], def->mac[2]);
-        return -1;
+        virBufferVSprintf(buffer, "ethernet%d.addressType = \"static\"\n",
+                          controller);
+        virBufferVSprintf(buffer, "ethernet%d.address = \"%s\"\n",
+                          controller, mac_string);
+        virBufferVSprintf(buffer, "ethernet%d.checkMACAddress = \"false\"\n",
+                          controller);
     }
 
     return 0;
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx
new file mode 100644
index 0000000..f27e0a0
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx
@@ -0,0 +1,8 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "generated"
+ethernet0.generatedAddress = "00:0C:29:11:22:33"
+ethernet0.generatedAddressOffset = "0"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml
new file mode 100644
index 0000000..ffb203b
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml
@@ -0,0 +1,19 @@
+<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:0c:29:11:22:33'/>
+      <source bridge='VM Network'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx
new file mode 100644
index 0000000..da46a70
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx
@@ -0,0 +1,8 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.checkMACAddress = "false"
+ethernet0.addressType = "static"
+ethernet0.address = "00:12:34:56:78:90"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.xml b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml
new file mode 100644
index 0000000..4c44fbc
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml
@@ -0,0 +1,19 @@
+<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:12:34:56:78:90'/>
+      <source bridge='VM Network'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx
new file mode 100644
index 0000000..8b7a5b3
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx
@@ -0,0 +1,7 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+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-static.xml b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml
new file mode 100644
index 0000000..7ef2d3d
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml
@@ -0,0 +1,19 @@
+<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'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx
new file mode 100644
index 0000000..b4d9172
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx
@@ -0,0 +1,7 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:87:65:43"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml
new file mode 100644
index 0000000..1d90f31
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml
@@ -0,0 +1,19 @@
+<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:87:65:43'/>
+      <source bridge='VM Network'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 150a58d..0cb387b 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -139,6 +139,11 @@ mymain(int argc, char **argv)
     DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25);
     DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25);
 
+    DO_TEST("ethernet-generated", "ethernet-generated", esxVI_APIVersion_25);
+    DO_TEST("ethernet-static", "ethernet-static", esxVI_APIVersion_25);
+    DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_APIVersion_25);
+    DO_TEST("ethernet-other", "ethernet-other", esxVI_APIVersion_25);
+
     DO_TEST("serial-file", "serial-file", esxVI_APIVersion_25);
     DO_TEST("serial-device", "serial-device", esxVI_APIVersion_25);
     DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_APIVersion_25);
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx
new file mode 100644
index 0000000..ae825a5
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx
@@ -0,0 +1,13 @@
+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-generated"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "generated"
+ethernet0.generatedAddress = "00:0C:29:11:22:33"
+ethernet0.generatedAddressOffset = "0"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml b/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml
new file mode 100644
index 0000000..aac8a74
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+  <name>ethernet-generated</name>
+  <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+  <memory>4096</memory>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <interface type='bridge'>
+      <mac address='00:0c:29:11:22:33'/>
+      <source bridge='VM Network'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx
new file mode 100644
index 0000000..452076a
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx
@@ -0,0 +1,13 @@
+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-static"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "static"
+ethernet0.address = "00:12:34:56:78:90"
+ethernet0.checkMACAddress = "false"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-other.xml b/tests/xml2vmxdata/xml2vmx-ethernet-other.xml
new file mode 100644
index 0000000..cf1ce7c
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-other.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+  <name>ethernet-static</name>
+  <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+  <memory>4096</memory>
+  <os>
+    <type>hvm</type>
+  </os>
+  <devices>
+    <interface type='bridge'>
+      <mac address='00:12:34:56:78:90'/>
+      <source bridge='VM Network'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx
new file mode 100644
index 0000000..154a28b
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx
@@ -0,0 +1,12 @@
+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-static"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+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-static.xml b/tests/xml2vmxdata/xml2vmx-ethernet-static.xml
new file mode 100644
index 0000000..b803de4
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-static.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+  <name>ethernet-static</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'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx
new file mode 100644
index 0000000..31283f6
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx
@@ -0,0 +1,12 @@
+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-vpx"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:87:65:43"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml
new file mode 100644
index 0000000..1490238
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+  <name>ethernet-vpx</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:87:65:43'/>
+      <source bridge='VM Network'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index abf1f32..b5b7cc8 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -192,6 +192,11 @@ mymain(int argc, char **argv)
     DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25);
     DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25);
 
+    DO_TEST("ethernet-generated", "ethernet-generated", esxVI_APIVersion_25);
+    DO_TEST("ethernet-static", "ethernet-static", esxVI_APIVersion_25);
+    DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_APIVersion_25);
+    DO_TEST("ethernet-other", "ethernet-other", esxVI_APIVersion_25);
+
     DO_TEST("serial-file", "serial-file", esxVI_APIVersion_25);
     DO_TEST("serial-device", "serial-device", esxVI_APIVersion_25);
     DO_TEST("serial-pipe", "serial-pipe", esxVI_APIVersion_25);
-- 
1.6.0.4


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