+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
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);
}
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"));
/* 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 {