The supported virtualHW.version doesn't depend on the API version, but on the product version. --- src/esx/esx_driver.c | 8 ++-- src/esx/esx_vmx.c | 46 +++++++++++++------------- src/esx/esx_vmx.h | 4 +- tests/vmx2xmltest.c | 85 +++++++++++++++++++++++++------------------------ tests/xml2vmxtest.c | 73 ++++++++++++++++++++++--------------------- 5 files changed, 109 insertions(+), 107 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 97c1645..c0c3195 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 c2e9be6..84c4aef 100644 --- a/src/esx/esx_vmx.c +++ b/src/esx/esx_vmx.c @@ -724,7 +724,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; @@ -774,42 +774,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; } @@ -2189,7 +2188,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; @@ -2210,18 +2209,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 c07f8b3..081b67d 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 f3b3b5e..12229b9 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,57 +123,57 @@ 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-e1000", "ethernet-e1000", 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 f9c4730..e7720bf 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,51 +171,51 @@ 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-e1000", "ethernet-e1000", 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); -- 1.6.3.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list