]> xenbits.xensource.com Git - libvirt.git/commitdiff
Wed Apr 18 11:12:00 BST 2007 Richard W.M. Jones <rjones@redhat.com>
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 18 Apr 2007 10:14:07 +0000 (10:14 +0000)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 18 Apr 2007 10:14:07 +0000 (10:14 +0000)
* src/test.c, src/libvirt.c, src/virterror.c,
  include/libvirt/virterror.h: Add a VIR_FROM_TEST error class
  and ensure that test driver errors are from this class.
  Tidy up the error messages generated by the test driver when
  user doesn't add a path to the URL and avoid open ("/").

ChangeLog
include/libvirt/virterror.h
src/libvirt.c
src/test.c
src/virterror.c
tests/.cvsignore

index 3f0cf55cdf0cf67b7ea375302f93f68252949529..edfcd56551e1bfe0c912c95095827e89b3f755f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Apr 18 11:12:00 BST 2007 Richard W.M. Jones  <rjones@redhat.com>
+
+       * src/test.c, src/libvirt.c, src/virterror.c,
+         include/libvirt/virterror.h: Add a VIR_FROM_TEST error class
+         and ensure that test driver errors are from this class.
+         Tidy up the error messages generated by the test driver when
+         user doesn't add a path to the URL and avoid open ("/").
+
 Wed Apr 18 11:57:28 CEST 2007 Daniel Veillard <veillard@redhat.com>
 
        * docs/remote.html docs/site.html docs/*.html: added a stub for
index 93078764ceb48c93ebfa534bdabe5f2517c04e7c..68591d6de7f93c5606b60e777d32f2c4c1f7efc4 100644 (file)
@@ -49,6 +49,7 @@ typedef enum {
     VIR_FROM_CONF,     /* Error in the configuration file handling */
     VIR_FROM_QEMU,      /* Error at the QEMU daemon */
     VIR_FROM_NET,       /* Error when operating on a network */
+    VIR_FROM_TEST,     /* Error from test driver */
 } virErrorDomain;
 
 
index 5ff80bffb1f242ae4fdada69f02b652bcde08513..35b035ae4b263c51dbb323502ed941c96cd07e17 100644 (file)
@@ -64,15 +64,15 @@ virInitialize(void)
      * Note that the order is important: the first ones have a higher
      * priority when calling virConnectOpen.
      */
-#ifdef WITH_XEN
-    if (xenUnifiedRegister () == -1) return -1;
-#endif
 #ifdef WITH_TEST
     if (testRegister() == -1) return -1;
 #endif
 #ifdef WITH_QEMU
     if (qemuRegister() == -1) return -1;
 #endif
+#ifdef WITH_XEN
+    if (xenUnifiedRegister () == -1) return -1;
+#endif
 
     return(0);
 }
index 7f4a3815eb76c063c214da56bf33265cc7f69afd..98d6be9a00f4bec3c66b2fb18357f93a387b9afa 100644 (file)
@@ -213,7 +213,7 @@ testError(virConnectPtr con,
         return;
 
     errmsg = __virErrorMsg(error, info);
-    __virRaiseError(con, dom, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
+    __virRaiseError(con, dom, NULL, VIR_FROM_TEST, error, VIR_ERR_ERROR,
                     errmsg, info, NULL, 0, 0, errmsg, info, 0);
 }
 
@@ -722,13 +722,19 @@ int testOpen(virConnectPtr conn,
         return VIR_DRV_OPEN_DECLINED;
     }
 
-    if (!uri->scheme ||
-        strcmp(uri->scheme, "test") ||
-        !uri->path) {
+    if (!uri->scheme || strcmp(uri->scheme, "test") != 0) {
         xmlFreeURI(uri);
         return VIR_DRV_OPEN_DECLINED;
     }
 
+    /* From this point on, the connection is for us. */
+    if (!uri->path
+        || uri->path[0] == '\0'
+        || (uri->path[0] == '/' && uri->path[1] == '\0')) {
+        testError (conn, NULL, VIR_ERR_INVALID_ARG,
+                   _("testOpen: supply a path or use test:///default"));
+        return VIR_DRV_OPEN_ERROR;
+    }
 
     if ((connid = getNextConnection()) < 0) {
         testError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("too many connections"));
@@ -738,12 +744,12 @@ int testOpen(virConnectPtr conn,
     /* Allocate per-connection private data. */
     priv = conn->privateData = malloc (sizeof (struct _testPrivate));
     if (!priv) {
-        testError(NULL, NULL, VIR_ERR_NO_MEMORY, "allocating private data");
+        testError(conn, NULL, VIR_ERR_NO_MEMORY, _("allocating private data"));
         return VIR_DRV_OPEN_ERROR;
     }
     priv->handle = -1;
 
-    if (!strcmp(uri->path, "/default")) {
+    if (strcmp(uri->path, "/default") == 0) {
         ret = testOpenDefault(conn,
                               connid);
     } else {
index 05cbefc42baa485d6dbe1b016be125c9acbcce6f..d5aab17176fe6033a56fea2eb00fa679b728b51c 100644 (file)
@@ -274,6 +274,9 @@ virDefaultErrorFunc(virErrorPtr err)
         case VIR_FROM_NET:
             dom = "Network ";
             break;
+        case VIR_FROM_TEST:
+            dom = "Test ";
+            break;
     }
     if ((err->dom != NULL) && (err->code != VIR_ERR_INVALID_DOMAIN)) {
         domain = err->dom->name;
index aee6f0320a7b2ed1c947d86aa0ade6196ca8ce3a..b8ee537d5c23fb1b7518a40fbfebcb47dbe2d4c7 100644 (file)
@@ -9,6 +9,7 @@ virshtest
 conftest
 reconnect
 xmconfigtest
+xencapstest
 *.gcda
 *.gcno