mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
ESX driver accept VI API version 4.0
* src/esx/esx_driver.c src/esx/esx_vi.c src/esx/esx_vi.h src/esx/esx_vmx.c src/esx/esx_vmx.h: extend the VI API version checks to accept version 4.0 and takes care of the virtualHW.version change from 4 to 7.
This commit is contained in:
parent
b557a36890
commit
84255632cb
@ -2011,7 +2011,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
|
||||
goto failure;
|
||||
}
|
||||
|
||||
def = esxVMX_ParseConfig(domain->conn, vmx);
|
||||
def = esxVMX_ParseConfig(domain->conn, vmx, priv->host->serverVersion);
|
||||
|
||||
if (def != NULL) {
|
||||
xml = virDomainDefFormat(domain->conn, def, flags);
|
||||
@ -2041,6 +2041,8 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
|
||||
const char *nativeConfig,
|
||||
unsigned int flags ATTRIBUTE_UNUSED)
|
||||
{
|
||||
esxPrivate *priv = (esxPrivate *)conn->privateData;
|
||||
int serverVersion = -1;
|
||||
virDomainDefPtr def = NULL;
|
||||
char *xml = NULL;
|
||||
|
||||
@ -2050,7 +2052,11 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
def = esxVMX_ParseConfig(conn, nativeConfig);
|
||||
if (! priv->phantom) {
|
||||
serverVersion = priv->host->serverVersion;
|
||||
}
|
||||
|
||||
def = esxVMX_ParseConfig(conn, nativeConfig, serverVersion);
|
||||
|
||||
if (def != NULL) {
|
||||
xml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_INACTIVE);
|
||||
|
@ -266,19 +266,27 @@ esxVI_Context_Connect(virConnectPtr conn, esxVI_Context *ctx, const char *url,
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (STREQ(ctx->service->about->apiType, "HostAgent")) {
|
||||
if (STRNEQ(ctx->service->about->apiVersion, "2.5.0") &&
|
||||
STRNEQ(ctx->service->about->apiVersion, "2.5u2")) {
|
||||
if (STREQ(ctx->service->about->apiType, "HostAgent") ||
|
||||
STREQ(ctx->service->about->apiType, "VirtualCenter")) {
|
||||
if (STRPREFIX(ctx->service->about->apiVersion, "2.5")) {
|
||||
ctx->apiVersion = 25;
|
||||
} else if (STRPREFIX(ctx->service->about->apiVersion, "4.0")) {
|
||||
ctx->apiVersion = 40;
|
||||
} else {
|
||||
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"Expecting VI API version '2.5.0' or '2.5u2' but "
|
||||
"found '%s'", ctx->service->about->apiVersion);
|
||||
"Expecting VI API major/minor version '2.5' or '4.0' "
|
||||
"but found '%s'", ctx->service->about->apiVersion);
|
||||
goto failure;
|
||||
}
|
||||
} else if (STREQ(ctx->service->about->apiType, "VirtualCenter")) {
|
||||
if (STRNEQ(ctx->service->about->apiVersion, "2.5u2")) {
|
||||
|
||||
if (STRPREFIX(ctx->service->about->version, "3.5")) {
|
||||
ctx->serverVersion = 35;
|
||||
} else if (STRPREFIX(ctx->service->about->version, "4.0")) {
|
||||
ctx->serverVersion = 40;
|
||||
} else {
|
||||
ESX_VI_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"Expecting VI API version '2.5u2' but found '%s'",
|
||||
ctx->service->about->apiVersion);
|
||||
"Expecting server major/minor version '3.5' or '4.0' "
|
||||
"but found '%s'", ctx->service->about->version);
|
||||
goto failure;
|
||||
}
|
||||
} else {
|
||||
|
@ -52,6 +52,8 @@ struct _esxVI_Context {
|
||||
char *username;
|
||||
char *password;
|
||||
esxVI_ServiceContent *service;
|
||||
int apiVersion;
|
||||
int serverVersion;
|
||||
esxVI_UserSession *session;
|
||||
esxVI_ManagedObjectReference *datacenter;
|
||||
esxVI_ManagedObjectReference *vmFolder;
|
||||
|
@ -37,7 +37,8 @@ domain-xml <=> vmx
|
||||
|
||||
|
||||
config.version = "8" # essential
|
||||
virtualHW.version = "4" # essential
|
||||
virtualHW.version = "4" # essential for ESX 3.5
|
||||
virtualHW.version = "7" # essential for ESX 4.0
|
||||
|
||||
|
||||
??? <=> guestOS = "<value>" # essential, FIXME: not representable
|
||||
@ -405,7 +406,7 @@ def->parallels[0]...
|
||||
|
||||
|
||||
virDomainDefPtr
|
||||
esxVMX_ParseConfig(virConnectPtr conn, const char *vmx)
|
||||
esxVMX_ParseConfig(virConnectPtr conn, const char *vmx, int serverVersion)
|
||||
{
|
||||
virConfPtr conf = NULL;
|
||||
virDomainDefPtr def = NULL;
|
||||
@ -442,8 +443,8 @@ esxVMX_ParseConfig(virConnectPtr conn, const char *vmx)
|
||||
|
||||
if (config_version != 8) {
|
||||
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"Expecting VMX entry 'config.version' to be \"8\" but "
|
||||
"found \"%lld\"", config_version);
|
||||
"Expecting VMX entry 'config.version' to be 8 but found "
|
||||
"%lld", config_version);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
@ -452,10 +453,41 @@ esxVMX_ParseConfig(virConnectPtr conn, const char *vmx)
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (virtualHW_version != 4) {
|
||||
switch (serverVersion) {
|
||||
case 35:
|
||||
if (virtualHW_version != 4) {
|
||||
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"Expecting VMX entry 'virtualHW.version' to be 4 for "
|
||||
"server version 3.5 but found %lld", virtualHW_version);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 40:
|
||||
if (virtualHW_version != 7) {
|
||||
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"Expecting VMX entry 'virtualHW.version' to be 7 for "
|
||||
"server version 4.0 but found %lld", virtualHW_version);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case -1:
|
||||
if (virtualHW_version != 4 && virtualHW_version != 7) {
|
||||
ESX_ERROR(conn, 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(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
"Expecting VMX entry 'virtualHW.version' to be \"4\" but "
|
||||
"found \"%lld\"", virtualHW_version);
|
||||
"Expecting server version 3.5 or 4.0 but got %d",
|
||||
serverVersion);
|
||||
goto failure;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "domain_conf.h"
|
||||
|
||||
virDomainDefPtr
|
||||
esxVMX_ParseConfig(virConnectPtr conn, const char *vmx);
|
||||
esxVMX_ParseConfig(virConnectPtr conn, const char *vmx, int serverVersion);
|
||||
|
||||
int
|
||||
esxVMX_ParseSCSIController(virConnectPtr conn, virConfPtr conf,
|
||||
|
Loading…
Reference in New Issue
Block a user