* esx_driver.c: core driver functions for managing VMware ESX hosts
*
* Copyright (C) 2010-2012 Red Hat, Inc.
- * Copyright (C) 2009-2012 Matthias Bolte <matthias.bolte@googlemail.com>
+ * Copyright (C) 2009-2013 Matthias Bolte <matthias.bolte@googlemail.com>
* Copyright (C) 2009 Maximilian Wilhelm <max@rfc2324.org>
*
* This library is free software; you can redistribute it and/or
static int
-esxConnectToHost(virConnectPtr conn,
+esxConnectToHost(esxPrivate *priv,
+ virConnectPtr conn,
virConnectAuthPtr auth,
char **vCenterIpAddress)
{
esxVI_String *propertyNameList = NULL;
esxVI_ObjectContent *hostSystem = NULL;
esxVI_Boolean inMaintenanceMode = esxVI_Boolean_Undefined;
- esxPrivate *priv = conn->privateData;
esxVI_ProductVersion expectedProductVersion = STRCASEEQ(conn->uri->scheme, "esx")
? esxVI_ProductVersion_ESX
: esxVI_ProductVersion_GSX;
static int
-esxConnectToVCenter(virConnectPtr conn,
+esxConnectToVCenter(esxPrivate *priv,
+ virConnectPtr conn,
virConnectAuthPtr auth,
const char *hostname,
const char *hostSystemIpAddress)
char *unescapedPassword = NULL;
char *password = NULL;
char *url = NULL;
- esxPrivate *priv = conn->privateData;
if (hostSystemIpAddress == NULL &&
(priv->parsedUri->path == NULL || STREQ(priv->parsedUri->path, "/"))) {
priv->supportsLongMode = esxVI_Boolean_Undefined;
priv->usedCpuTimeCounterId = -1;
- conn->privateData = priv;
-
/*
* Set the port dependent on the transport protocol if no port is
* specified. This allows us to rely on the port parameter being
if (STRCASEEQ(conn->uri->scheme, "esx") ||
STRCASEEQ(conn->uri->scheme, "gsx")) {
/* Connect to host */
- if (esxConnectToHost(conn, auth,
+ if (esxConnectToHost(priv, conn, auth,
&potentialVCenterIpAddress) < 0) {
goto cleanup;
}
}
}
- if (esxConnectToVCenter(conn, auth,
+ if (esxConnectToVCenter(priv, conn, auth,
vCenterIpAddress,
priv->host->ipAddress) < 0) {
goto cleanup;
priv->primary = priv->host;
} else { /* VPX */
/* Connect to vCenter */
- if (esxConnectToVCenter(conn, auth,
+ if (esxConnectToVCenter(priv, conn, auth,
conn->uri->server,
NULL) < 0) {
goto cleanup;
goto cleanup;
}
+ conn->privateData = priv;
+ priv = NULL;
result = VIR_DRV_OPEN_SUCCESS;
cleanup:
- if (result == VIR_DRV_OPEN_ERROR) {
- esxFreePrivate(&priv);
- }
-
+ esxFreePrivate(&priv);
VIR_FREE(potentialVCenterIpAddress);
return result;