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

Re: [libvirt] VMware support and Server 2.0.1



2009/7/30 Timo Makinen <tmakinen ee oulu fi>:
> On Thu, Jul 30, 2009 at 03:22:59AM +0200, Matthias Bolte wrote:
>> 2009/7/29 Timo Makinen <tmakinen ee oulu fi>:
>> > On Wed, Jul 29, 2009 at 06:12:59PM +0200, Matthias Bolte wrote:
>> >> 2009/7/27 Timo Makinen <tmakinen ee oulu fi>:
>> >> Could you do some basic testing beside listing and dumpxml, as I have
>> >> currently no VMware GSX installation at hand? Just test if the
>> >> following commands work as expected in virsh:
>> >>
>> >> - start
>> >> - shutdown
>> >> - reboot
>> >> - suspend
>> >> - resume
>> >> - nodeinfo
>> >> - dominfo
>> >>
>> >> Regards,
>> >>   Matthias
>> >
>> > All these worked out of the box.
>>
>> Nice!
>>
>> Could you test the attached patch? It adds handling for the port in
>> the URI, extends the version checking for GSX 2.0 and fixes the bug in
>> VMX parsing.
>>
>> Matthias
>
> Works like a charm now. :)
>
>   - Timo
>

Fine!

The attached second GSX patch adds a gsx:// scheme to the ESX driver,
so you can connect to a GSX host using

virsh -c gsx://host

and the driver will select the port automatically dependent on the
scheme and transport. Here gsx scheme and default transport https
result in port 8333.

Matthias
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 73c33ad..dba6305 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -67,16 +67,23 @@ typedef struct _esxPrivate {
 
 
 /*
- * URI format: esx://[<user>@]<server>[:<port>][?transport={http|https}][&vcenter=<vcenter>][&no_verify={0|1}]
+ * 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:
+ * - esx+http  80
+ * - esx+https 433
+ * - gsx+http  8222
+ * - gsx+https 8333
+ *
  * If no transport parameter is specified https is used.
  *
  * The vcenter parameter is only necessary for migration, because the vCenter
  * server is in charge to initiate a migration between two ESX hosts.
  *
  * If the no_verify parameter is set to 1, this disables libcurl client checks
- * of the server's certificate.
+ * 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:
@@ -95,9 +102,10 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
     char *password = NULL;
     int phantom = 0; // boolean
 
-    /* Decline if the URI is NULL or the scheme is not 'esx' */
+    /* Decline if the URI is NULL or the scheme is neither 'esx' nor 'gsx' */
     if (conn->uri == NULL || conn->uri->scheme == NULL ||
-        STRNEQ(conn->uri->scheme, "esx")) {
+        (STRCASENEQ(conn->uri->scheme, "esx") &&
+         STRCASENEQ(conn->uri->scheme, "gsx"))) {
         return VIR_DRV_OPEN_DECLINED;
     }
 
@@ -154,10 +162,18 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
          * distinguish between the situations port == 0 and port != 0
          */
         if (conn->uri->port == 0) {
-            if (STRCASEEQ(priv->transport, "https")) {
-                conn->uri->port = 443;
-            } else {
-                conn->uri->port = 80;
+            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;
+                }
             }
         }
 
@@ -199,6 +215,22 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
             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;
+            }
+        }
+
         VIR_FREE(url);
         VIR_FREE(password);
         VIR_FREE(username);
@@ -235,6 +267,15 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
                 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);

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