[libvirt] ESX [12/12]: Remove phantom mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* src/esx/esx_driver.c: remove phantom mode
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 91de407..bbba445 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -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,21 +277,13 @@ 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;
+    /* Decline URIs without server part, or missing auth */
+    if (conn->uri->server == NULL || auth == NULL || auth->cb == NULL) {
+        return VIR_DRV_OPEN_DECLINED;
     }
 
-    if (! phantom) {
-        /* Decline non-phantom URIs without server part, or missing auth */
-        if (conn->uri->server == NULL || auth == NULL || auth->cb == NULL) {
-            return VIR_DRV_OPEN_DECLINED;
-        }
-
-        if (conn->uri->path != NULL) {
-            VIR_WARN("Ignoring unexpected path '%s' in URI", conn->uri->path);
-        }
+    if (conn->uri->path != NULL) {
+        VIR_WARN("Ignoring unexpected path '%s' in URI", conn->uri->path);
     }
 
     /* Allocate per-connection private data */
@@ -323,171 +292,164 @@ 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) {
-            goto failure;
+    /* Request credentials and login to host/vCenter */
+    if (esxUtil_ParseQuery(conn, &priv->transport, &vCenter, &noVerify) < 0) {
+        goto failure;
+    }
+
+    if (esxUtil_ResolveHostname(conn, conn->uri->server, hostIpAddress,
+                                NI_MAXHOST) < 0) {
+        goto failure;
+    }
+
+    if (vCenter != NULL &&
+        esxUtil_ResolveHostname(conn, vCenter, vCenterIpAddress,
+                                NI_MAXHOST) < 0) {
+        goto failure;
+    }
+
+    /*
+     * Set the port dependent on the transport protocol if no port is
+     * specified. This allows us to rely on the port parameter being
+     * correctly set when building URIs later on, without the need to
+     * distinguish between the situations port == 0 and port != 0
+     */
+    if (conn->uri->port == 0) {
+        if (STRCASEEQ(conn->uri->scheme, "esx")) {
+            if (STRCASEEQ(priv->transport, "https")) {
+                conn->uri->port = 443;
+            } else {
+                conn->uri->port = 80;
+            }
+        } else { /* GSX */
+            if (STRCASEEQ(priv->transport, "https")) {
+                conn->uri->port = 8333;
+            } else {
+                conn->uri->port = 8222;
+            }
         }
+    }
 
-        if (esxUtil_ResolveHostname(conn, conn->uri->server, hostIpAddress,
-                                    NI_MAXHOST) < 0) {
+    /* Login to host */
+    if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport,
+                    conn->uri->server, conn->uri->port) < 0) {
+        virReportOOMError(conn);
+        goto failure;
+    }
+
+    if (conn->uri->user != NULL) {
+        username = strdup(conn->uri->user);
+
+        if (username == NULL) {
+            virReportOOMError(conn);
             goto failure;
         }
+    } else {
+        username = esxUtil_RequestUsername(auth, "root", conn->uri->server);
 
-        if (vCenter != NULL &&
-            esxUtil_ResolveHostname(conn, vCenter, vCenterIpAddress,
-                                    NI_MAXHOST) < 0) {
+        if (username == NULL) {
+            ESX_ERROR(conn, VIR_ERR_AUTH_FAILED, "Username request failed");
             goto failure;
         }
+    }
 
-        /*
-         * Set the port dependent on the transport protocol if no port is
-         * specified. This allows us to rely on the port parameter being
-         * correctly set when building URIs later on, without the need to
-         * distinguish between the situations port == 0 and port != 0
-         */
-        if (conn->uri->port == 0) {
-            if (STRCASEEQ(conn->uri->scheme, "esx")) {
-                if (STRCASEEQ(priv->transport, "https")) {
-                    conn->uri->port = 443;
-                } else {
-                    conn->uri->port = 80;
-                }
-            } else { /* GSX */
-                if (STRCASEEQ(priv->transport, "https")) {
-                    conn->uri->port = 8333;
-                } else {
-                    conn->uri->port = 8222;
-                }
-            }
-        }
+    if (esxVI_Context_Alloc(conn, &priv->host) < 0) {
+        goto failure;
+    }
 
-        /* Login to host */
-        if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport,
-                        conn->uri->server, conn->uri->port) < 0) {
-            virReportOOMError(conn);
+    password = esxUtil_RequestPassword(auth, username, conn->uri->server);
+
+    if (password == NULL) {
+        ESX_ERROR(conn, VIR_ERR_AUTH_FAILED, "Password request failed");
+        goto failure;
+    }
+
+    if (esxVI_Context_Connect(conn, priv->host, url, hostIpAddress,
+                              username, password, noVerify) < 0) {
+        goto failure;
+    }
+
+    if (STRCASEEQ(conn->uri->scheme, "esx")) {
+        if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
+            priv->host->productVersion != esxVI_ProductVersion_ESX40) {
+            ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+                      "%s is neither an ESX 3.5 host nor an ESX 4.0 host",
+                      conn->uri->server);
             goto failure;
         }
+    } else { /* GSX */
+        if (priv->host->productVersion != esxVI_ProductVersion_GSX20) {
+            ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+                      "%s isn't a GSX 2.0 host", conn->uri->server);
+            goto failure;
+        }
+    }
 
-        if (conn->uri->user != NULL) {
-            username = strdup(conn->uri->user);
+    VIR_FREE(url);
+    VIR_FREE(password);
+    VIR_FREE(username);
 
-            if (username == NULL) {
-                virReportOOMError(conn);
-                goto failure;
-            }
-        } else {
-            username = esxUtil_RequestUsername(auth, "root", conn->uri->server);
+    /* Login to vCenter */
+    if (vCenter != NULL) {
+        if (virAsprintf(&url, "%s://%s/sdk", priv->transport,
+                        vCenter) < 0) {
+            virReportOOMError(conn);
+            goto failure;
+        }
 
-            if (username == NULL) {
-                ESX_ERROR(conn, VIR_ERR_AUTH_FAILED, "Username request failed");
-                goto failure;
-            }
+        if (esxVI_Context_Alloc(conn, &priv->vCenter) < 0) {
+            goto failure;
         }
 
-        if (esxVI_Context_Alloc(conn, &priv->host) < 0) {
+        username = esxUtil_RequestUsername(auth, "administrator", vCenter);
+
+        if (username == NULL) {
+            ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
+                      "Username request failed");
             goto failure;
         }
 
-        password = esxUtil_RequestPassword(auth, username, conn->uri->server);
+        password = esxUtil_RequestPassword(auth, username, vCenter);
 
         if (password == NULL) {
-            ESX_ERROR(conn, VIR_ERR_AUTH_FAILED, "Password request failed");
+            ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
+                      "Password request failed");
             goto failure;
         }
 
-        if (esxVI_Context_Connect(conn, priv->host, url, hostIpAddress,
-                                  username, password, noVerify) < 0) {
+        if (esxVI_Context_Connect(conn, priv->vCenter, url,
+                                  vCenterIpAddress, username, password,
+                                  noVerify) < 0) {
             goto failure;
         }
 
-        if (STRCASEEQ(conn->uri->scheme, "esx")) {
-            if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
-                priv->host->productVersion != esxVI_ProductVersion_ESX40) {
-                ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
-                          "%s is neither an ESX 3.5 host nor an ESX 4.0 host",
-                          conn->uri->server);
-                goto failure;
-            }
-        } else { /* GSX */
-            if (priv->host->productVersion != esxVI_ProductVersion_GSX20) {
-                ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
-                          "%s isn't a GSX 2.0 host", conn->uri->server);
-                goto failure;
-            }
+        if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
+            priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
+            ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
+                      "%s is neither a vCenter 2.5 server nor a vCenter "
+                      "4.0 server",
+                      conn->uri->server);
+            goto failure;
         }
 
         VIR_FREE(url);
+        VIR_FREE(vCenter);
         VIR_FREE(password);
         VIR_FREE(username);
-
-        /* Login to vCenter */
-        if (vCenter != NULL) {
-            if (virAsprintf(&url, "%s://%s/sdk", priv->transport,
-                            vCenter) < 0) {
-                virReportOOMError(conn);
-                goto failure;
-            }
-
-            if (esxVI_Context_Alloc(conn, &priv->vCenter) < 0) {
-                goto failure;
-            }
-
-            username = esxUtil_RequestUsername(auth, "administrator", vCenter);
-
-            if (username == NULL) {
-                ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
-                          "Username request failed");
-                goto failure;
-            }
-
-            password = esxUtil_RequestPassword(auth, username, vCenter);
-
-            if (password == NULL) {
-                ESX_ERROR(conn, VIR_ERR_AUTH_FAILED,
-                          "Password request failed");
-                goto failure;
-            }
-
-            if (esxVI_Context_Connect(conn, priv->vCenter, url,
-                                      vCenterIpAddress, username, password,
-                                      noVerify) < 0) {
-                goto failure;
-            }
-
-            if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
-                priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
-                ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
-                          "%s is neither a vCenter 2.5 server nor a vCenter "
-                          "4.0 server",
-                          conn->uri->server);
-                goto failure;
-            }
-
-            VIR_FREE(url);
-            VIR_FREE(password);
-            VIR_FREE(username);
-        }
-
-        VIR_FREE(vCenter);
     }
 
     conn->privateData = priv;
 
-    if (! phantom) {
-        /* Setup capabilities */
-        priv->caps = esxCapsInit(conn);
+    /* Setup capabilities */
+    priv->caps = esxCapsInit(conn);
 
-        if (priv->caps == NULL) {
-            goto failure;
-        }
+    if (priv->caps == NULL) {
+        goto failure;
     }
 
     return VIR_DRV_OPEN_SUCCESS;
@@ -518,18 +480,16 @@ esxClose(virConnectPtr conn)
 {
     esxPrivate *priv = (esxPrivate *)conn->privateData;
 
-    if (! priv->phantom) {
-        esxVI_EnsureSession(conn, priv->host);
+    esxVI_EnsureSession(conn, priv->host);
 
-        esxVI_Logout(conn, priv->host);
-        esxVI_Context_Free(&priv->host);
+    esxVI_Logout(conn, priv->host);
+    esxVI_Context_Free(&priv->host);
 
-        if (priv->vCenter != NULL) {
-            esxVI_EnsureSession(conn, priv->vCenter);
+    if (priv->vCenter != NULL) {
+        esxVI_EnsureSession(conn, priv->vCenter);
 
-            esxVI_Logout(conn, priv->vCenter);
-            esxVI_Context_Free(&priv->vCenter);
-        }
+        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;
     }
@@ -943,15 +873,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);
@@ -973,12 +895,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;
     }
@@ -1045,12 +961,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;
     }
@@ -1075,12 +985,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;
     }
@@ -1164,12 +1068,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;
     }
@@ -1256,12 +1154,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;
     }
@@ -1342,12 +1234,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;
     }
@@ -1408,12 +1294,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;
     }
@@ -1472,12 +1352,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;
     }
@@ -1527,12 +1401,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;
     }
@@ -1583,12 +1451,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;
     }
@@ -1662,12 +1524,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;
     }
@@ -1727,12 +1583,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;
     }
@@ -1787,12 +1637,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;
     }
@@ -1861,12 +1705,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;
     }
@@ -2118,12 +1956,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");
@@ -2195,12 +2027,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;
     }
@@ -2270,12 +2096,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;
     }
@@ -2366,8 +2186,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;
 
@@ -2377,12 +2195,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);
@@ -2404,12 +2218,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);
@@ -2442,12 +2250,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;
     }
@@ -2526,12 +2328,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;
     }
@@ -2554,12 +2350,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;
     }
@@ -2629,12 +2419,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;
     }
@@ -2767,7 +2551,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
     }
 
     domain = virGetDomain(conn, def->name, def->uuid);
- 
+
     if (domain != NULL) {
         domain->id = -1;
     }
@@ -2807,12 +2591,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;
     }
@@ -2913,12 +2691,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");
@@ -3050,12 +2822,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;
     }
@@ -3234,12 +3000,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");
@@ -3374,12 +3134,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;
     }
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]