提交 1d8099f4 编写于 作者: M Matthias Bolte

esx: Fix virtualHW.version generation

The supported virtualHW.version doesn't depend on the API version,
but on the product version.
上级 abce152a
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册