diff options
author | Matthias Bolte <matthias.bolte@googlemail.com> | 2009-11-14 19:51:05 +0100 |
---|---|---|
committer | Matthias Bolte <matthias.bolte@googlemail.com> | 2009-11-15 15:22:01 +0100 |
commit | 645f4acafe1cd720782c8c42917f47f965875df8 (patch) | |
tree | bd8e2339b6085fe347d730de149b8d711fd736db | |
parent | esx: Handle 'vmxnet3' in esxVMX_FormatEthernet() (diff) | |
download | libvirt-645f4acafe1cd720782c8c42917f47f965875df8.tar.gz libvirt-645f4acafe1cd720782c8c42917f47f965875df8.tar.bz2 libvirt-645f4acafe1cd720782c8c42917f47f965875df8.zip |
esx: Fix MAC address formatting
VMware uses two MAC address prefixes: 00:0c:29 and 00:50:56. The 00:0c:29
prefix is used for ESX server generated addresses. The 00:50:56 prefix is
split into two parts. MAC addresses above 00:50:56:3f:ff:ff are generated
by a vCenter. The rest of the 00:50:56 prefix can be assigned manually.
Any MAC address within the 00:0c:29 and 00:50:56 prefix can be specified
in a domain XML config and the driver will handle the details internally.
* src/esx/esx_vmx.c: fix MAC address formatting
* tests/xml2vmxdata/*: update test files accordingly
-rw-r--r-- | src/esx/esx_vmx.c | 21 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx | 2 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-esx-in-the-wild-2.vmx | 1 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-esx-in-the-wild-3.vmx | 1 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx | 4 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-ethernet-bridged.vmx | 4 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-ethernet-custom.vmx | 4 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-ethernet-e1000.vmx | 4 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-1.vmx | 1 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-2.vmx | 1 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-3.vmx | 2 | ||||
-rw-r--r-- | tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-4.vmx | 1 |
12 files changed, 34 insertions, 12 deletions
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c index 97ad43ebf..9a9fe0a27 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -277,8 +277,10 @@ def->nets[0]... ethernet0.addressType = "vpx" # default to "generated" ->mac = <value> <=> ethernet0.generatedAddress = "<value>" - # 00:0c:29 prefix for autogenerated mac's + # 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:05:69 old prefix from esx 1.5 @@ -2687,12 +2689,25 @@ esxVMX_FormatEthernet(virConnectPtr conn, virDomainNetDefPtr def, virFormatMacAddr(def->mac, mac_string); - if ((def->mac[0] == 0x00 && def->mac[1] == 0x0c && def->mac[2] == 0x29) || - (def->mac[0] == 0x00 && def->mac[1] == 0x50 && def->mac[2] == 0x56)) { + if (def->mac[0] == 0x00 && def->mac[1] == 0x0c && def->mac[2] == 0x29) { 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 { ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR, "Unsupported MAC address prefix '%02X:%02X:%02X', expecting " diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx index ea14588c9..077d9076b 100644 --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-1.vmx @@ -13,5 +13,5 @@ scsi0:0.fileName = "/vmfs/volumes/498076b2-02796c1a-ef5b-000ae484a6a3/Fedora11/F ethernet0.present = "true" ethernet0.networkName = "VM Network" ethernet0.connectionType = "bridged" -ethernet0.addressType = "generated" +ethernet0.addressType = "vpx" ethernet0.generatedAddress = "00:50:56:91:48:C7" diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-2.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-2.vmx index 05e3d4675..f50754869 100644 --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-2.vmx +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-2.vmx @@ -36,3 +36,4 @@ ethernet0.networkName = "VM Network" ethernet0.connectionType = "bridged" ethernet0.addressType = "generated" ethernet0.generatedAddress = "00:0C:29:3C:98:3E" +ethernet0.generatedAddressOffset = "0" diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-3.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-3.vmx index d418475bd..10559fbc2 100644 --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-3.vmx +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-3.vmx @@ -22,3 +22,4 @@ ethernet0.networkName = "VM Network" ethernet0.connectionType = "bridged" ethernet0.addressType = "generated" ethernet0.generatedAddress = "00:0C:29:F5:C3:0C" +ethernet0.generatedAddressOffset = "0" diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx index 68f6d6d30..068f0f87a 100644 --- a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-4.vmx @@ -13,12 +13,12 @@ scsi0:0.fileName = "/vmfs/volumes/498076b2-02796c1a-ef5b-000ae484a6a3/virtMonSer ethernet0.present = "true" ethernet0.networkName = "VM Network" ethernet0.connectionType = "bridged" -ethernet0.addressType = "generated" +ethernet0.addressType = "vpx" ethernet0.generatedAddress = "00:50:56:91:66:D4" ethernet1.present = "true" ethernet1.networkName = "VM Switch 2" ethernet1.connectionType = "bridged" -ethernet1.addressType = "generated" +ethernet1.addressType = "vpx" ethernet1.generatedAddress = "00:50:56:91:0C:51" serial0.present = "true" serial0.fileType = "file" diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-bridged.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-bridged.vmx index 73ca8a850..7d9c6f7a6 100644 --- a/tests/xml2vmxdata/xml2vmx-ethernet-bridged.vmx +++ b/tests/xml2vmxdata/xml2vmx-ethernet-bridged.vmx @@ -8,5 +8,5 @@ numvcpus = "1" ethernet0.present = "true" ethernet0.networkName = "VM Network" ethernet0.connectionType = "bridged" -ethernet0.addressType = "generated" -ethernet0.generatedAddress = "00:50:56:11:22:33" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:11:22:33" diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-custom.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-custom.vmx index cc42140b1..fb4b116f3 100644 --- a/tests/xml2vmxdata/xml2vmx-ethernet-custom.vmx +++ b/tests/xml2vmxdata/xml2vmx-ethernet-custom.vmx @@ -9,5 +9,5 @@ ethernet0.present = "true" ethernet0.networkName = "VM Network" ethernet0.connectionType = "custom" ethernet0.vnet = "vmnet7" -ethernet0.addressType = "generated" -ethernet0.generatedAddress = "00:50:56:11:22:33" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:11:22:33" diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-e1000.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-e1000.vmx index dd2c86d93..3aed46cad 100644 --- a/tests/xml2vmxdata/xml2vmx-ethernet-e1000.vmx +++ b/tests/xml2vmxdata/xml2vmx-ethernet-e1000.vmx @@ -9,5 +9,5 @@ ethernet0.present = "true" ethernet0.virtualDev = "e1000" ethernet0.networkName = "VM Network" ethernet0.connectionType = "bridged" -ethernet0.addressType = "generated" -ethernet0.generatedAddress = "00:50:56:11:22:33" +ethernet0.addressType = "static" +ethernet0.address = "00:50:56:11:22:33" diff --git a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-1.vmx index 8b2d6a45b..526fe3c4c 100644 --- a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-1.vmx +++ b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-1.vmx @@ -14,3 +14,4 @@ ethernet0.connectionType = "custom" ethernet0.vnet = "/dev/vmnet1" ethernet0.addressType = "generated" ethernet0.generatedAddress = "00:0C:29:D6:2B:D3" +ethernet0.generatedAddressOffset = "0" diff --git a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-2.vmx b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-2.vmx index d811b7f75..34f006dc0 100644 --- a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-2.vmx +++ b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-2.vmx @@ -14,3 +14,4 @@ ethernet0.connectionType = "custom" ethernet0.vnet = "/dev/vmnet1" ethernet0.addressType = "generated" ethernet0.generatedAddress = "00:0C:29:D6:CB:A4" +ethernet0.generatedAddressOffset = "0" diff --git a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-3.vmx b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-3.vmx index 7109fb9a1..a2a35754a 100644 --- a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-3.vmx +++ b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-3.vmx @@ -14,9 +14,11 @@ ethernet0.connectionType = "custom" ethernet0.vnet = "/dev/vmnet1" ethernet0.addressType = "generated" ethernet0.generatedAddress = "00:0C:29:C4:BE:5A" +ethernet0.generatedAddressOffset = "0" ethernet1.present = "true" ethernet1.networkName = "net2" ethernet1.connectionType = "custom" ethernet1.vnet = "/dev/vmnet2" ethernet1.addressType = "generated" ethernet1.generatedAddress = "00:0C:29:C4:BE:64" +ethernet1.generatedAddressOffset = "0" diff --git a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-4.vmx b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-4.vmx index ee9b8c9f0..765d35c24 100644 --- a/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-4.vmx +++ b/tests/xml2vmxdata/xml2vmx-gsx-in-the-wild-4.vmx @@ -14,3 +14,4 @@ ethernet0.connectionType = "custom" ethernet0.vnet = "/dev/vmnet2" ethernet0.addressType = "generated" ethernet0.generatedAddress = "00:0C:29:C5:E3:5D" +ethernet0.generatedAddressOffset = "0" |