[libvirt] VMware support and Server 2.0.1
Daniel P. Berrange
berrange at redhat.com
Mon Aug 3 09:16:34 UTC 2009
On Sun, Aug 02, 2009 at 03:45:43PM +0200, Matthias Bolte wrote:
>
> 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);
ACK
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list