From: Richard W.M. Jones Date: Wed, 18 Apr 2007 10:14:07 +0000 (+0000) Subject: Wed Apr 18 11:12:00 BST 2007 Richard W.M. Jones X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=dbcc662ea394fe90a5538a82cdc88af543d41471;p=libvirt.git Wed Apr 18 11:12:00 BST 2007 Richard W.M. Jones * 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 ("/"). --- diff --git a/ChangeLog b/ChangeLog index 3f0cf55cdf..edfcd56551 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Apr 18 11:12:00 BST 2007 Richard W.M. Jones + + * 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 * docs/remote.html docs/site.html docs/*.html: added a stub for diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 93078764ce..68591d6de7 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -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; diff --git a/src/libvirt.c b/src/libvirt.c index 5ff80bffb1..35b035ae4b 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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); } diff --git a/src/test.c b/src/test.c index 7f4a3815eb..98d6be9a00 100644 --- a/src/test.c +++ b/src/test.c @@ -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 { diff --git a/src/virterror.c b/src/virterror.c index 05cbefc42b..d5aab17176 100644 --- a/src/virterror.c +++ b/src/virterror.c @@ -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; diff --git a/tests/.cvsignore b/tests/.cvsignore index aee6f0320a..b8ee537d5c 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore @@ -9,6 +9,7 @@ virshtest conftest reconnect xmconfigtest +xencapstest *.gcda *.gcno