diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 97c16453005223bf10093a81d762f5bb553b7190..c0c31955a8b256492fc5e06359a011faf9367872 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2145,7 +2145,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags) } def = esxVMX_ParseConfig(priv->host, vmx, datastoreName, directoryName, - priv->host->apiVersion); + priv->host->productVersion); if (def != NULL) { xml = virDomainDefFormat(def, flags); @@ -2188,7 +2188,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, } def = esxVMX_ParseConfig(priv->host, nativeConfig, "?", "?", - priv->host->apiVersion); + priv->host->productVersion); if (def != NULL) { xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); @@ -2222,7 +2222,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, return NULL; } - vmx = esxVMX_FormatConfig(priv->host, def, priv->host->apiVersion); + vmx = esxVMX_FormatConfig(priv->host, def, priv->host->productVersion); virDomainDefFree(def); @@ -2445,7 +2445,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED) } /* Build VMX from domain XML */ - vmx = esxVMX_FormatConfig(priv->host, def, priv->host->apiVersion); + vmx = esxVMX_FormatConfig(priv->host, def, priv->host->productVersion); if (vmx == NULL) { goto failure; diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c index 52c97e555a5a7579e78b1b40b2e0acac0c6913e1..142f2f7662be5539876d710c7e0d9e5a8954783f 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -725,7 +725,7 @@ esxVMX_ParseFileName(esxVI_Context *ctx, const char *fileName, virDomainDefPtr esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, const char *datastoreName, const char *directoryName, - esxVI_APIVersion apiVersion) + esxVI_ProductVersion productVersion) { virConfPtr conf = NULL; virDomainDefPtr def = NULL; @@ -775,42 +775,41 @@ esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, goto failure; } - switch (apiVersion) { - case esxVI_APIVersion_25: + /* + * virtualHW.version compatibility matrix: + * + * 4 7 API + * ESX 3.5 + 2.5 + * ESX 4.0 + + 4.0 + * GSX 2.0 + + 2.5 + */ + switch (productVersion) { + case esxVI_ProductVersion_ESX35: if (virtualHW_version != 4) { ESX_ERROR(VIR_ERR_INTERNAL_ERROR, - _("Expecting VMX entry 'virtualHW.version' to be 4 for " - "VI API version 2.5 but found %lld"), + _("Expecting VMX entry 'virtualHW.version' to be 4 " + "but found %lld"), virtualHW_version); goto failure; } break; - case esxVI_APIVersion_40: + case esxVI_ProductVersion_GSX20: + case esxVI_ProductVersion_ESX40: if (virtualHW_version != 4 && virtualHW_version != 7) { ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry 'virtualHW.version' to be 4 or 7 " - "for VI API version 4.0 but found %lld"), + "but found %lld"), virtualHW_version); goto failure; } break; - case esxVI_APIVersion_Unknown: - if (virtualHW_version != 4 && virtualHW_version != 7) { - ESX_ERROR(VIR_ERR_INTERNAL_ERROR, - _("Expecting VMX entry 'virtualHW.version' to be 4 or 7 " - "but found %lld"), virtualHW_version); - goto failure; - } - - break; - default: ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", - _("Expecting VI API version 2.5 or 4.0")); + _("Unexpected product version")); goto failure; } @@ -2207,7 +2206,7 @@ esxVMX_FormatFileName(esxVI_Context *ctx ATTRIBUTE_UNUSED, const char *src) char * esxVMX_FormatConfig(esxVI_Context *ctx, virDomainDefPtr def, - esxVI_APIVersion apiVersion) + esxVI_ProductVersion productVersion) { int i; int sched_cpu_affinity_length; @@ -2228,18 +2227,19 @@ esxVMX_FormatConfig(esxVI_Context *ctx, virDomainDefPtr def, virBufferAddLit(&buffer, "config.version = \"8\"\n"); /* vmx:virtualHW.version */ - switch (apiVersion) { - case esxVI_APIVersion_25: + switch (productVersion) { + case esxVI_ProductVersion_ESX35: virBufferAddLit(&buffer, "virtualHW.version = \"4\"\n"); break; - case esxVI_APIVersion_40: + case esxVI_ProductVersion_GSX20: + case esxVI_ProductVersion_ESX40: virBufferAddLit(&buffer, "virtualHW.version = \"7\"\n"); break; default: ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", - _("Expecting VI API version 2.5 or 4.0")); + _("Unexpected product version")); goto failure; } diff --git a/src/esx/esx_vmx.h b/src/esx/esx_vmx.h index c07f8b3a58b645adcf175322248300cf341e2ccb..081b67d87264cca2438783ede7a44c4aad4ec356 100644 --- a/src/esx/esx_vmx.h +++ b/src/esx/esx_vmx.h @@ -58,7 +58,7 @@ esxVMX_ParseFileName(esxVI_Context *ctx, const char *fileName, virDomainDefPtr esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx, const char *datastoreName, const char *directoryName, - esxVI_APIVersion apiVersion); + esxVI_ProductVersion productVersion); int esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def); @@ -96,7 +96,7 @@ esxVMX_FormatFileName(esxVI_Context *ctx, const char *src); char * esxVMX_FormatConfig(esxVI_Context *ctx, virDomainDefPtr def, - esxVI_APIVersion apiVersion); + esxVI_ProductVersion productVersion); int esxVMX_FormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer); diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index b26a7036f807ab4605bc1649065117e1596fb04b..0a8b99efcbb6617a0e56097b8f3e2dc3bf218191 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -17,7 +17,8 @@ static char *abs_srcdir = NULL; # define MAX_FILE 4096 static int -testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion) +testCompareFiles(const char *vmx, const char *xml, + esxVI_ProductVersion productVersion) { int result = -1; char vmxData[MAX_FILE]; @@ -37,7 +38,7 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion) } def = esxVMX_ParseConfig(NULL, vmxData, "datastore", "directory", - apiVersion); + productVersion); if (def == NULL) { err = virGetLastError(); @@ -70,7 +71,7 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion) struct testInfo { const char *input; const char *output; - esxVI_APIVersion version; + esxVI_ProductVersion version; }; static int @@ -112,7 +113,7 @@ mymain(int argc, char **argv) return EXIT_FAILURE; } -# define DO_TEST(_in, _out, _version) \ +# define DO_TEST(_in, _out, _version) \ do { \ struct testInfo info = { _in, _out, _version }; \ virResetLastError(); \ @@ -122,58 +123,58 @@ mymain(int argc, char **argv) } \ } while (0) - DO_TEST("case-insensitive-1", "case-insensitive-1", esxVI_APIVersion_25); - DO_TEST("case-insensitive-2", "case-insensitive-2", esxVI_APIVersion_25); + DO_TEST("case-insensitive-1", "case-insensitive-1", esxVI_ProductVersion_ESX35); + DO_TEST("case-insensitive-2", "case-insensitive-2", esxVI_ProductVersion_ESX35); - DO_TEST("minimal", "minimal", esxVI_APIVersion_25); - DO_TEST("minimal-64bit", "minimal-64bit", esxVI_APIVersion_25); + DO_TEST("minimal", "minimal", esxVI_ProductVersion_ESX35); + DO_TEST("minimal-64bit", "minimal-64bit", esxVI_ProductVersion_ESX35); - DO_TEST("graphics-vnc", "graphics-vnc", esxVI_APIVersion_25); + DO_TEST("graphics-vnc", "graphics-vnc", esxVI_ProductVersion_ESX35); - DO_TEST("scsi-driver", "scsi-driver", esxVI_APIVersion_25); - DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_APIVersion_25); + DO_TEST("scsi-driver", "scsi-driver", esxVI_ProductVersion_ESX35); + DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_ProductVersion_ESX35); - DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_APIVersion_25); - DO_TEST("harddisk-ide-file", "harddisk-ide-file", esxVI_APIVersion_25); + DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_ProductVersion_ESX35); + DO_TEST("harddisk-ide-file", "harddisk-ide-file", esxVI_ProductVersion_ESX35); - DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", esxVI_APIVersion_25); - DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", esxVI_APIVersion_25); - DO_TEST("cdrom-ide-file", "cdrom-ide-file", esxVI_APIVersion_25); - DO_TEST("cdrom-ide-device", "cdrom-ide-device", esxVI_APIVersion_25); + DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", esxVI_ProductVersion_ESX35); + DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", esxVI_ProductVersion_ESX35); + DO_TEST("cdrom-ide-file", "cdrom-ide-file", esxVI_ProductVersion_ESX35); + DO_TEST("cdrom-ide-device", "cdrom-ide-device", esxVI_ProductVersion_ESX35); - DO_TEST("floppy-file", "floppy-file", esxVI_APIVersion_25); - DO_TEST("floppy-device", "floppy-device", esxVI_APIVersion_25); + DO_TEST("floppy-file", "floppy-file", esxVI_ProductVersion_ESX35); + DO_TEST("floppy-device", "floppy-device", esxVI_ProductVersion_ESX35); - DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_APIVersion_25); - DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_APIVersion_25); + DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_ProductVersion_ESX35); - DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25); - DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25); + DO_TEST("ethernet-custom", "ethernet-custom", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_ProductVersion_ESX35); - 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("ethernet-generated", "ethernet-generated", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-static", "ethernet-static", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-other", "ethernet-other", esxVI_ProductVersion_ESX35); - 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); - DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_APIVersion_25); - DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_APIVersion_25); - DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_APIVersion_25); + DO_TEST("serial-file", "serial-file", esxVI_ProductVersion_ESX35); + DO_TEST("serial-device", "serial-device", esxVI_ProductVersion_ESX35); + DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_ProductVersion_ESX35); + DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_ProductVersion_ESX35); + DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_ProductVersion_ESX35); + DO_TEST("serial-pipe-server-vm", "serial-pipe", esxVI_ProductVersion_ESX35); - DO_TEST("parallel-file", "parallel-file", esxVI_APIVersion_25); - DO_TEST("parallel-device", "parallel-device", esxVI_APIVersion_25); + DO_TEST("parallel-file", "parallel-file", esxVI_ProductVersion_ESX35); + DO_TEST("parallel-device", "parallel-device", esxVI_ProductVersion_ESX35); - DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", esxVI_APIVersion_25); - DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", esxVI_APIVersion_25); - DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", esxVI_APIVersion_25); - DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", esxVI_APIVersion_25); + DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", esxVI_ProductVersion_ESX35); + DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", esxVI_ProductVersion_ESX35); + DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", esxVI_ProductVersion_ESX35); + DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", esxVI_ProductVersion_ESX35); - DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", esxVI_APIVersion_25); - DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", esxVI_APIVersion_25); - DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_APIVersion_25); - DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_APIVersion_25); + DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", esxVI_ProductVersion_ESX35); + DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", esxVI_ProductVersion_ESX35); + DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_ProductVersion_ESX35); + DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_ProductVersion_ESX35); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 40386eb2b18e3f568b19c68b33861cb33151c28e..14901fa8a84e989b3b5c04e012ab933a99daabfe 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -65,7 +65,8 @@ testESXCapsInit(void) } static int -testCompareFiles(const char *xml, const char *vmx, esxVI_APIVersion apiVersion) +testCompareFiles(const char *xml, const char *vmx, + esxVI_ProductVersion productVersion) { int result = -1; char xmlData[MAX_FILE]; @@ -89,7 +90,7 @@ testCompareFiles(const char *xml, const char *vmx, esxVI_APIVersion apiVersion) goto failure; } - formatted = esxVMX_FormatConfig(NULL, def, apiVersion); + formatted = esxVMX_FormatConfig(NULL, def, productVersion); if (formatted == NULL) { goto failure; @@ -112,7 +113,7 @@ testCompareFiles(const char *xml, const char *vmx, esxVI_APIVersion apiVersion) struct testInfo { const char *input; const char *output; - esxVI_APIVersion version; + esxVI_ProductVersion version; }; static int @@ -170,52 +171,52 @@ mymain(int argc, char **argv) return EXIT_FAILURE; } - DO_TEST("minimal", "minimal", esxVI_APIVersion_25); - DO_TEST("minimal-64bit", "minimal-64bit", esxVI_APIVersion_25); + DO_TEST("minimal", "minimal", esxVI_ProductVersion_ESX35); + DO_TEST("minimal-64bit", "minimal-64bit", esxVI_ProductVersion_ESX35); - DO_TEST("graphics-vnc", "graphics-vnc", esxVI_APIVersion_25); + DO_TEST("graphics-vnc", "graphics-vnc", esxVI_ProductVersion_ESX35); - DO_TEST("scsi-driver", "scsi-driver", esxVI_APIVersion_25); - DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_APIVersion_25); + DO_TEST("scsi-driver", "scsi-driver", esxVI_ProductVersion_ESX35); + DO_TEST("scsi-writethrough", "scsi-writethrough", esxVI_ProductVersion_ESX35); - DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_APIVersion_25); - DO_TEST("harddisk-ide-file", "harddisk-ide-file", esxVI_APIVersion_25); + DO_TEST("harddisk-scsi-file", "harddisk-scsi-file", esxVI_ProductVersion_ESX35); + DO_TEST("harddisk-ide-file", "harddisk-ide-file", esxVI_ProductVersion_ESX35); - DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", esxVI_APIVersion_25); - DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", esxVI_APIVersion_25); - DO_TEST("cdrom-ide-file", "cdrom-ide-file", esxVI_APIVersion_25); - DO_TEST("cdrom-ide-device", "cdrom-ide-device", esxVI_APIVersion_25); + DO_TEST("cdrom-scsi-file", "cdrom-scsi-file", esxVI_ProductVersion_ESX35); + DO_TEST("cdrom-scsi-device", "cdrom-scsi-device", esxVI_ProductVersion_ESX35); + DO_TEST("cdrom-ide-file", "cdrom-ide-file", esxVI_ProductVersion_ESX35); + DO_TEST("cdrom-ide-device", "cdrom-ide-device", esxVI_ProductVersion_ESX35); - DO_TEST("floppy-file", "floppy-file", esxVI_APIVersion_25); - DO_TEST("floppy-device", "floppy-device", esxVI_APIVersion_25); + DO_TEST("floppy-file", "floppy-file", esxVI_ProductVersion_ESX35); + DO_TEST("floppy-device", "floppy-device", esxVI_ProductVersion_ESX35); - DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_APIVersion_25); - DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_APIVersion_25); + DO_TEST("ethernet-e1000", "ethernet-e1000", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-vmxnet2", "ethernet-vmxnet2", esxVI_ProductVersion_ESX35); - DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25); - DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25); + DO_TEST("ethernet-custom", "ethernet-custom", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_ProductVersion_ESX35); - 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("ethernet-generated", "ethernet-generated", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-static", "ethernet-static", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_ProductVersion_ESX35); + DO_TEST("ethernet-other", "ethernet-other", esxVI_ProductVersion_ESX35); - 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); + DO_TEST("serial-file", "serial-file", esxVI_ProductVersion_ESX35); + DO_TEST("serial-device", "serial-device", esxVI_ProductVersion_ESX35); + DO_TEST("serial-pipe", "serial-pipe", esxVI_ProductVersion_ESX35); - DO_TEST("parallel-file", "parallel-file", esxVI_APIVersion_25); - DO_TEST("parallel-device", "parallel-device", esxVI_APIVersion_25); + DO_TEST("parallel-file", "parallel-file", esxVI_ProductVersion_ESX35); + DO_TEST("parallel-device", "parallel-device", esxVI_ProductVersion_ESX35); - DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", esxVI_APIVersion_25); - DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", esxVI_APIVersion_25); - DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", esxVI_APIVersion_25); - DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", esxVI_APIVersion_25); + DO_TEST("esx-in-the-wild-1", "esx-in-the-wild-1", esxVI_ProductVersion_ESX35); + DO_TEST("esx-in-the-wild-2", "esx-in-the-wild-2", esxVI_ProductVersion_ESX35); + DO_TEST("esx-in-the-wild-3", "esx-in-the-wild-3", esxVI_ProductVersion_ESX35); + DO_TEST("esx-in-the-wild-4", "esx-in-the-wild-4", esxVI_ProductVersion_ESX35); - DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", esxVI_APIVersion_25); - DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", esxVI_APIVersion_25); - DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_APIVersion_25); - DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_APIVersion_25); + DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", esxVI_ProductVersion_ESX35); + DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", esxVI_ProductVersion_ESX35); + DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_ProductVersion_ESX35); + DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_ProductVersion_ESX35); virCapabilitiesFree(caps);