[Libvir] PATCH: RFC: env var to set default connection URI

Richard W.M. Jones rjones at redhat.com
Sun Jan 20 12:21:41 UTC 2008


Daniel P. Berrange wrote:
> Currently, if the app provides NULL as the connect URI, we always connect
> to a Xen hypervisor. 
> 
> virsh provides a VIR_DEFAULT_CONNECT_URI env var which can be used to 
> override this.  virt-install/virt-manager never use NULL, and now try
> to 'guess' a default URI based on whether /dev/kvm or /proc/xen exist.
> 
> Users have requested that VIR_DEFAULT_CONNECT_URI apply to other apps
> besides virsh. 
> 
> So this patch adds support for LIBVIRT_DEFAULT_URI env variable which will
> be used if the connect URI is NULL. If that variable is not set it will
> still default to Xen. 
> 
> 
> diff -r 673c98e11c78 src/libvirt.c
> --- a/src/libvirt.c	Wed Jan 16 09:27:56 2008 -0500
> +++ b/src/libvirt.c	Wed Jan 16 09:28:00 2008 -0500
> @@ -516,8 +516,13 @@ do_open (const char *name,
>      xmlURIPtr uri;
>  
>      /* Convert NULL or "" to xen:/// for back compat */
> -    if (!name || name[0] == '\0')
> -        name = "xen:///";
> +    if (!name || name[0] == '\0') {
> +        char *defname = getenv("LIBVIRT_DEFAULT_URI");
> +        if (defname && *defname)
> +            name = defname;
> +        else
> +            name = "xen:///";
> +    }
>  
>      /* Convert xen -> xen:/// for back compat */
>      if (!strcasecmp(name, "xen"))

I agree with Soren's comment.

The patch above is fine, but you'll also need to change virsh and don't 
forget to document this on the uri.html page.

Rich.

-- 
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080120/13c40910/attachment-0001.bin>


More information about the libvir-list mailing list