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

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



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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


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