]> xenbits.xensource.com Git - libvirt.git/commitdiff
Improve error message for disabled client-side drivers
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 9 Jun 2010 22:52:05 +0000 (00:52 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 11 Jun 2010 16:24:13 +0000 (18:24 +0200)
Report that libvirt was built without that driver instead of
trying to connect to a libvirtd, when we know that this is
going to fail.

src/libvirt.c

index 2754fd03174fdc678ac0847d725e2847f94c2ced..fd3587f3bf4be5cfc99384307ffcb40ad9778da3 100644 (file)
@@ -1210,6 +1210,34 @@ do_open (const char *name,
     ret->flags = flags & VIR_CONNECT_RO;
 
     for (i = 0; i < virDriverTabCount; i++) {
+        /* We're going to probe the remote driver next. So we have already
+         * probed all other client-side-only driver before, but none of them
+         * accepted the URI.
+         * If the scheme corresponds to a known but disabled client-side-only
+         * driver then report a useful error, instead of a cryptic one about
+         * not being able to connect to libvirtd or not being able to find
+         * certificates. */
+        if (virDriverTab[i]->no == VIR_DRV_REMOTE &&
+            ret->uri != NULL && ret->uri->scheme != NULL &&
+            (
+#ifndef WITH_PHYP
+             STRCASEEQ(ret->uri->scheme, "phyp") ||
+#endif
+#ifndef WITH_ESX
+             STRCASEEQ(ret->uri->scheme, "esx") ||
+             STRCASEEQ(ret->uri->scheme, "gsx") ||
+#endif
+#ifndef WITH_XENAPI
+             STRCASEEQ(ret->uri->scheme, "xenapi") ||
+#endif
+             false)) {
+            virReportErrorHelper(NULL, VIR_FROM_NONE, VIR_ERR_INVALID_ARG,
+                                 __FILE__, __FUNCTION__, __LINE__,
+                                 _("libvirt was built without the '%s' driver"),
+                                 ret->uri->scheme);
+            goto failed;
+        }
+
         DEBUG("trying driver %d (%s) ...",
               i, virDriverTab[i]->name);
         res = virDriverTab[i]->open (ret, auth, flags);