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 ("/").
This commit is contained in:
Richard W.M. Jones 2007-04-18 10:14:07 +00:00
parent 435ce72149
commit dbcc662ea3
6 changed files with 28 additions and 9 deletions

View File

@ -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

View 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;

View 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);
}

View 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 {

View 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;

View File

@ -9,6 +9,7 @@ virshtest
conftest
reconnect
xmconfigtest
xencapstest
*.gcda
*.gcno