提交 23b24972 编写于 作者: M Matthias Bolte 提交者: Daniel Veillard

ESX remove phantom mode

* src/esx/esx_driver.c: remove phantom mode
上级 8ce9f2b1
......@@ -58,7 +58,6 @@ static int esxDomainGetMaxVcpus(virDomainPtr domain);
typedef struct _esxPrivate {
esxVI_Context *host;
esxVI_Context *vCenter;
int phantom; // boolean
virCapsPtr caps;
char *transport;
int32_t maxVcpus;
......@@ -81,12 +80,6 @@ esxSupportsLongMode(virConnectPtr conn)
char edxLongModeBit = '?';
char edxFirstBit = '?';
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (priv->supportsLongMode != esxVI_Boolean_Undefined) {
return priv->supportsLongMode;
}
......@@ -179,19 +172,10 @@ esxSupportsLongMode(virConnectPtr conn)
static virCapsPtr
esxCapsInit(virConnectPtr conn)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
esxVI_Boolean supportsLongMode = esxVI_Boolean_Undefined;
esxVI_Boolean supportsLongMode = esxSupportsLongMode(conn);
virCapsPtr caps = NULL;
virCapsGuestPtr guest = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return NULL;
}
supportsLongMode = esxSupportsLongMode(conn);
if (supportsLongMode == esxVI_Boolean_Undefined) {
return NULL;
}
......@@ -258,7 +242,6 @@ esxCapsInit(virConnectPtr conn)
/*
* URI format: {esx|gsx}://[<user>@]<server>[:<port>][?transport={http|https}][&vcenter=<vcenter>][&no_verify={0|1}]
* esx:///phantom
*
* If no port is specified the default port is set dependent on the scheme and
* transport parameter:
......@@ -274,11 +257,6 @@ esxCapsInit(virConnectPtr conn)
*
* If the no_verify parameter is set to 1, this disables libcurl client checks
* of the server's certificate. The default value it 0.
*
* The esx:///phantom URI may be used for tasks that don't require an actual
* connection to the hypervisor like domxml-{from,to}-native:
*
* virsh -c esx:///phantom domxml-from-native vmware-vmx dummy.vmx
*/
static virDrvOpenStatus
esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
......@@ -291,7 +269,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
int noVerify = 0; // boolean
char *username = NULL;
char *password = NULL;
int phantom = 0; // boolean
/* Decline if the URI is NULL or the scheme is neither 'esx' nor 'gsx' */
if (conn->uri == NULL || conn->uri->scheme == NULL ||
......@@ -300,14 +277,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
return VIR_DRV_OPEN_DECLINED;
}
/* Check for 'esx:///phantom' URI */
if (conn->uri->server == NULL && conn->uri->path != NULL &&
STREQ(conn->uri->path, "/phantom")) {
phantom = 1;
}
if (! phantom) {
/* Decline non-phantom URIs without server part, or missing auth */
/* Decline URIs without server part, or missing auth */
if (conn->uri->server == NULL || auth == NULL || auth->cb == NULL) {
return VIR_DRV_OPEN_DECLINED;
}
......@@ -315,7 +285,6 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
if (conn->uri->path != NULL) {
VIR_WARN("Ignoring unexpected path '%s' in URI", conn->uri->path);
}
}
/* Allocate per-connection private data */
if (VIR_ALLOC(priv) < 0) {
......@@ -323,16 +292,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto failure;
}
priv->phantom = phantom;
priv->maxVcpus = -1;
priv->supportsVMotion = esxVI_Boolean_Undefined;
priv->supportsLongMode = esxVI_Boolean_Undefined;
priv->usedCpuTimeCounterId = -1;
/* Request credentials and login to non-phantom host/vCenter */
if (! phantom) {
if (esxUtil_ParseQuery(conn, &priv->transport, &vCenter,
&noVerify) < 0) {
/* Request credentials and login to host/vCenter */
if (esxUtil_ParseQuery(conn, &priv->transport, &vCenter, &noVerify) < 0) {
goto failure;
}
......@@ -472,23 +438,19 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
VIR_FREE(url);
VIR_FREE(vCenter);
VIR_FREE(password);
VIR_FREE(username);
}
VIR_FREE(vCenter);
}
conn->privateData = priv;
if (! phantom) {
/* Setup capabilities */
priv->caps = esxCapsInit(conn);
if (priv->caps == NULL) {
goto failure;
}
}
return VIR_DRV_OPEN_SUCCESS;
......@@ -518,7 +480,6 @@ esxClose(virConnectPtr conn)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
if (! priv->phantom) {
esxVI_EnsureSession(conn, priv->host);
esxVI_Logout(conn, priv->host);
......@@ -530,7 +491,6 @@ esxClose(virConnectPtr conn)
esxVI_Logout(conn, priv->vCenter);
esxVI_Context_Free(&priv->vCenter);
}
}
virCapabilitiesFree(priv->caps);
......@@ -552,12 +512,6 @@ esxSupportsVMotion(virConnectPtr conn)
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (priv->supportsVMotion != esxVI_Boolean_Undefined) {
return priv->supportsVMotion;
}
......@@ -615,12 +569,6 @@ esxSupportsFeature(virConnectPtr conn, int feature)
esxPrivate *priv = (esxPrivate *)conn->privateData;
esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return -1;
}
switch (feature) {
case VIR_DRV_FEATURE_MIGRATION_V1:
supportsVMotion = esxSupportsVMotion(conn);
......@@ -655,12 +603,6 @@ esxGetVersion(virConnectPtr conn, unsigned long *version)
char *temp;
unsigned int major, minor, release;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return -1;
}
temp = (char *)priv->host->service->about->version;
/* Expecting 'major.minor.release' format */
......@@ -703,12 +645,6 @@ esxGetHostname(virConnectPtr conn)
const char *domainName = NULL;
char *complete = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......@@ -802,12 +738,6 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
memset(nodeinfo, 0, sizeof(virNodeInfo));
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......@@ -948,15 +878,7 @@ static char *
esxGetCapabilities(virConnectPtr conn)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
char *xml = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return NULL;
}
xml = virCapabilitiesFormatXML(priv->caps);
char *xml = virCapabilitiesFormatXML(priv->caps);
if (xml == NULL) {
virReportOOMError(conn);
......@@ -978,12 +900,6 @@ esxListDomains(virConnectPtr conn, int *ids, int maxids)
esxVI_VirtualMachinePowerState powerState;
int count = 0;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (ids == NULL || maxids < 0) {
goto failure;
}
......@@ -1050,12 +966,6 @@ esxNumberOfDomains(virConnectPtr conn)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return -1;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
return -1;
}
......@@ -1080,12 +990,6 @@ esxDomainLookupByID(virConnectPtr conn, int id)
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......@@ -1169,12 +1073,6 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
char uuid_string[VIR_UUID_STRING_BUFLEN];
virDomainPtr domain = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......@@ -1261,12 +1159,6 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......@@ -1347,12 +1239,6 @@ esxDomainSuspend(virDomainPtr domain)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1413,12 +1299,6 @@ esxDomainResume(virDomainPtr domain)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1477,12 +1357,6 @@ esxDomainShutdown(virDomainPtr domain)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1532,12 +1406,6 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1588,12 +1456,6 @@ esxDomainDestroy(virDomainPtr domain)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1667,12 +1529,6 @@ esxDomainGetMaxMemory(virDomainPtr domain)
esxVI_DynamicProperty *dynamicProperty = NULL;
unsigned long memoryMB = 0;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1732,12 +1588,6 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1792,12 +1642,6 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -1866,12 +1710,6 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
esxVI_PerfMetricIntSeries *perfMetricIntSeries = NULL;
esxVI_Long *value = NULL;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -2123,12 +1961,6 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (nvcpus < 1) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
"Requested number of virtual CPUs must al least be 1");
......@@ -2200,12 +2032,6 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (priv->maxVcpus > 0) {
return priv->maxVcpus;
}
......@@ -2275,12 +2101,6 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
virDomainDefPtr def = NULL;
char *xml = NULL;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return NULL;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -2371,8 +2191,6 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
unsigned int flags ATTRIBUTE_UNUSED)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
esxVI_Context *ctx = NULL;
esxVI_APIVersion apiVersion = esxVI_APIVersion_Unknown;
virDomainDefPtr def = NULL;
char *xml = NULL;
......@@ -2382,12 +2200,8 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
if (! priv->phantom) {
ctx = priv->host;
apiVersion = priv->host->apiVersion;
}
def = esxVMX_ParseConfig(conn, ctx, nativeConfig, "?", "?", apiVersion);
def = esxVMX_ParseConfig(conn, priv->host, nativeConfig, "?", "?",
priv->host->apiVersion);
if (def != NULL) {
xml = virDomainDefFormat(conn, def, VIR_DOMAIN_XML_INACTIVE);
......@@ -2409,12 +2223,6 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
virDomainDefPtr def = NULL;
char *vmx = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return NULL;
}
if (STRNEQ(nativeFormat, "vmware-vmx")) {
ESX_ERROR(conn, VIR_ERR_INVALID_ARG,
"Unsupported config format '%s'", nativeFormat);
......@@ -2447,12 +2255,6 @@ esxListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
esxVI_VirtualMachinePowerState powerState;
int count = 0;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (names == NULL || maxnames < 0) {
goto failure;
}
......@@ -2531,12 +2333,6 @@ esxNumberOfDefinedDomains(virConnectPtr conn)
{
esxPrivate *priv = (esxPrivate *)conn->privateData;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
return -1;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
return -1;
}
......@@ -2559,12 +2355,6 @@ esxDomainCreate(virDomainPtr domain)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -2634,12 +2424,6 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
esxVI_TaskInfoState taskInfoState;
virDomainPtr domain = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......@@ -2812,12 +2596,6 @@ esxDomainUndefine(virDomainPtr domain)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -2918,12 +2696,6 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
unsigned int mask = 0;
int i = 0;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (*nparams < 3) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
"Parameter array must have space for 3 items");
......@@ -3055,12 +2827,6 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
esxVI_TaskInfoState taskInfoState;
int i;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(domain->conn, priv->host) < 0) {
goto failure;
}
......@@ -3239,12 +3005,6 @@ esxDomainMigratePerform(virDomainPtr domain,
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
if (priv->phantom) {
ESX_ERROR(domain->conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (priv->vCenter == NULL) {
ESX_ERROR(domain->conn, VIR_ERR_INVALID_ARG,
"Migration not possible without a vCenter");
......@@ -3379,12 +3139,6 @@ esxNodeGetFreeMemory(virConnectPtr conn)
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage = NULL;
if (priv->phantom) {
ESX_ERROR(conn, VIR_ERR_OPERATION_INVALID,
"Not possible with a phantom connection");
goto failure;
}
if (esxVI_EnsureSession(conn, priv->host) < 0) {
goto failure;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册