diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in index b7909ff1e3..44a144f12a 100644 --- a/docs/drvesx.html.in +++ b/docs/drvesx.html.in @@ -16,8 +16,8 @@ SOAP based VMware Virtual Infrastructure API (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 VMware vSphere API.

@@ -159,7 +159,7 @@ type://[username@]hostname[:port]/[?extraparameters] There are several specialties in the domain XML config for ESX domains.

-

Restrictions

+

Restrictions

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]

  • Valid MAC address prefixes are 00:0c:29 and - 00:50:56 + 00:50:56. Since 0.7.6 + arbitrary MAC addresses are supported.
  • -

    Datastore references

    +

    Datastore references

    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]

    -

    Available hardware

    +

    MAC addresses

    +

    + VMware has registered two MAC address prefixes for domains: + 00:0c:29 and 00:50:56. These prefixes are + split into ranges for different purposes. +

    + + + + + + + + + + + + + + + + + +
    RangePurpose
    + 00:0c:29:00:00:00 - 00:0c:29:ff:ff:ff + + 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. +
    + 00:50:56:00:00:00 - 00:50:56:3f:ff:ff + + MAC addresses from this range can by manually assigned by the + user in the VI client. +
    + 00:50:56:80:00:00 - 00:50:56:bf:ff:ff + + A VI client autogenerates MAC addresses from this range for + newly defined domains. +
    +

    + 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. + Since 0.7.6 the ESX driver sets the prefix + for generated MAC addresses to 00:0c:29. Before 0.7.6 + the 00:50:56 prefix was used. Sometimes this resulted in + the generation of out-of-range MAC address that were rejected by the + ESX server. +

    +

    + Also since 0.7.6 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. +

    +
    +ethernet0.checkMACAddress = "false"
    +
    + + +

    Available hardware

    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 30e21e0744..f86654a0ba 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 d3cad1ddbb..4b334b6cad 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 = <=> ethernet0.generatedAddress = "" + ethernet0.generatedAddressOffset = "0" # ? ethernet0.addressType = "static" # default to "generated" @@ -277,10 +277,15 @@ def->nets[0]... ethernet0.addressType = "vpx" # default to "generated" ->mac = <=> ethernet0.generatedAddress = "" + + ethernet0.addressType = "static" # default to "generated" +->mac = <=> ethernet0.address = "" + 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 0000000000..f27e0a008f --- /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 0000000000..ffb203b74f --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml @@ -0,0 +1,19 @@ + + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + + + + + diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx new file mode 100644 index 0000000000..da46a70d46 --- /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 0000000000..4c44fbc6b9 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml @@ -0,0 +1,19 @@ + + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + + + + + diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx new file mode 100644 index 0000000000..8b7a5b3bf3 --- /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 0000000000..7ef2d3ded2 --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml @@ -0,0 +1,19 @@ + + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + + + + + diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx new file mode 100644 index 0000000000..b4d9172764 --- /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 0000000000..1d90f3182b --- /dev/null +++ b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml @@ -0,0 +1,19 @@ + + 00000000-0000-0000-0000-000000000000 + 32768 + 32768 + 1 + + hvm + + + destroy + restart + destroy + + + + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 150a58d17d..0cb387b2c6 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 0000000000..ae825a54fa --- /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 0000000000..aac8a74fb0 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml @@ -0,0 +1,14 @@ + + ethernet-generated + 564d9bef-acd9-b4e0-c8f0-aea8b9103515 + 4096 + + hvm + + + + + + + + diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx new file mode 100644 index 0000000000..452076ad93 --- /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 0000000000..cf1ce7c9c8 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-other.xml @@ -0,0 +1,14 @@ + + ethernet-static + 564d9bef-acd9-b4e0-c8f0-aea8b9103515 + 4096 + + hvm + + + + + + + + diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx new file mode 100644 index 0000000000..154a28bfa4 --- /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 0000000000..b803de4228 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-static.xml @@ -0,0 +1,14 @@ + + ethernet-static + 564d9bef-acd9-b4e0-c8f0-aea8b9103515 + 4096 + + hvm + + + + + + + + diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx new file mode 100644 index 0000000000..31283f6d58 --- /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 0000000000..1490238ec2 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml @@ -0,0 +1,14 @@ + + ethernet-vpx + 564d9bef-acd9-b4e0-c8f0-aea8b9103515 + 4096 + + hvm + + + + + + + + diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index abf1f32bb9..b5b7cc8143 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);