Tue Feb 14 15:37:17 EST 2007 Mark McLoughlin <markmc@redhat.com>

Note: potential ABI break here, but people should
        only really be using virError structs returned from
        libvirt itself.

        * include/libvirt/virterror.h: add virNetwork
        to virError

        * src/internal.h, src/virterror.c: add network param
        to __virRaiseError()

        * src/conf.c, src/hash.c, src/libvirt.c, src/proxy_internal.c,
        src/qemu_internal.c, src/sexpr.c, src/test.c, src/xen_internal.c,
        src/xend_internal.c, src/xm_internal.c, src/xml.c, src/xmlrpc.c,
        src/xs_internal.c: update.
This commit is contained in:
Mark McLoughlin 2007-02-14 15:40:53 +00:00
parent 5be54b40cb
commit 8ce3203ad3
17 changed files with 57 additions and 35 deletions

View File

@ -1,3 +1,20 @@
Tue Feb 14 15:37:17 EST 2007 Mark McLoughlin <markmc@redhat.com>
Note: potential ABI break here, but people should
only really be using virError structs returned from
libvirt itself.
* include/libvirt/virterror.h: add virNetwork
to virError
* src/internal.h, src/virterror.c: add network param
to __virRaiseError()
* src/conf.c, src/hash.c, src/libvirt.c, src/proxy_internal.c,
src/qemu_internal.c, src/sexpr.c, src/test.c, src/xen_internal.c,
src/xend_internal.c, src/xm_internal.c, src/xml.c, src/xmlrpc.c,
src/xs_internal.c: update.
Tue Feb 14 15:33:05 EST 2007 Mark McLoughlin <markmc@redhat.com> Tue Feb 14 15:33:05 EST 2007 Mark McLoughlin <markmc@redhat.com>
* include/libvirt/libvirt.h.in: add the networks APIs * include/libvirt/libvirt.h.in: add the networks APIs

View File

@ -72,6 +72,7 @@ struct _virError {
char *str3; /* extra string information */ char *str3; /* extra string information */
int int1; /* extra number information */ int int1; /* extra number information */
int int2; /* extra number information */ int int2; /* extra number information */
virNetworkPtr net; /* the network if available */
}; };
/** /**

View File

@ -95,7 +95,7 @@ virConfError(virConfPtr conf ATTRIBUTE_UNUSED,
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, __virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
errmsg, info, NULL, line, 0, errmsg, info, line); errmsg, info, NULL, line, 0, errmsg, info, line);
} }

View File

@ -617,7 +617,7 @@ virHashError(virConnectPtr conn, virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(conn, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }

View File

@ -200,6 +200,7 @@ char *virDomainGetVMInfo(virDomainPtr domain,
************************************************************************/ ************************************************************************/
void __virRaiseError(virConnectPtr conn, void __virRaiseError(virConnectPtr conn,
virDomainPtr dom, virDomainPtr dom,
virNetworkPtr net,
int domain, int domain,
int code, int code,
virErrorLevel level, virErrorLevel level,

View File

@ -107,7 +107,7 @@ virLibConnError(virConnectPtr conn, virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(conn, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }
@ -133,7 +133,7 @@ virLibDomainError(virDomainPtr domain, virErrorNumber error,
if (error != VIR_ERR_INVALID_DOMAIN) { if (error != VIR_ERR_INVALID_DOMAIN) {
conn = domain->conn; conn = domain->conn;
} }
__virRaiseError(conn, domain, VIR_FROM_DOM, error, VIR_ERR_ERROR, __virRaiseError(conn, domain, NULL, VIR_FROM_DOM, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }
@ -159,8 +159,7 @@ virLibNetworkError(virNetworkPtr network, virErrorNumber error,
if (error != VIR_ERR_INVALID_NETWORK) { if (error != VIR_ERR_INVALID_NETWORK) {
conn = network->conn; conn = network->conn;
} }
/* XXX: should be able to pass network pointer here */ __virRaiseError(conn, NULL, network, VIR_FROM_NET, error, VIR_ERR_ERROR,
__virRaiseError(conn, NULL, VIR_FROM_NET, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }

View File

@ -116,7 +116,7 @@ virProxyError(virConnectPtr conn, virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(conn, NULL, VIR_FROM_PROXY, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_PROXY, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }

View File

@ -61,7 +61,7 @@ qemuError(virConnectPtr con,
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(con, dom, VIR_FROM_QEMU, error, VIR_ERR_ERROR, __virRaiseError(con, dom, NULL, VIR_FROM_QEMU, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info, 0); errmsg, info, NULL, 0, 0, errmsg, info, 0);
} }
@ -244,7 +244,7 @@ qemuOpenClientUNIX(virConnectPtr conn, const char *path, int autostart) {
return (-1); return (-1);
} }
conn->handle = fd; conn->qemud_fd = fd;
return (0); return (0);
} }
@ -269,7 +269,7 @@ static int qemuProcessRequest(virConnectPtr conn,
/* Block sending entire outgoing packet */ /* Block sending entire outgoing packet */
while (outLeft) { while (outLeft) {
int got = write(conn->handle, out+outDone, outLeft); int got = write(conn->qemud_fd, out+outDone, outLeft);
if (got < 0) { if (got < 0) {
return -1; return -1;
} }
@ -279,7 +279,7 @@ static int qemuProcessRequest(virConnectPtr conn,
/* Block waiting for header to come back */ /* Block waiting for header to come back */
while (inLeft) { while (inLeft) {
int done = read(conn->handle, in+inGot, inLeft); int done = read(conn->qemud_fd, in+inGot, inLeft);
if (done <= 0) { if (done <= 0) {
return -1; return -1;
} }
@ -307,7 +307,7 @@ static int qemuProcessRequest(virConnectPtr conn,
/* Now block reading in body */ /* Now block reading in body */
inLeft = reply->header.dataSize; inLeft = reply->header.dataSize;
while (inLeft) { while (inLeft) {
int done = read(conn->handle, in+inGot, inLeft); int done = read(conn->qemud_fd, in+inGot, inLeft);
if (done <= 0) { if (done <= 0) {
return -1; return -1;
} }
@ -389,11 +389,11 @@ static int qemuOpen(virConnectPtr conn,
return -1; return -1;
} }
conn->handle = -1; conn->qemud_fd = -1;
qemuOpenConnection(conn, uri, flags & VIR_DRV_OPEN_RO ? 1 : 0); qemuOpenConnection(conn, uri, flags & VIR_DRV_OPEN_RO ? 1 : 0);
xmlFreeURI(uri); xmlFreeURI(uri);
if (conn->handle < 0) { if (conn->qemud_fd < 0) {
return -1; return -1;
} }
@ -402,9 +402,9 @@ static int qemuOpen(virConnectPtr conn,
static int qemuClose (virConnectPtr conn) { static int qemuClose (virConnectPtr conn) {
if (conn->handle != -1) { if (conn->qemud_fd != -1) {
close(conn->handle); close(conn->qemud_fd);
conn->handle = -1; conn->qemud_fd = -1;
} }
return 0; return 0;
} }

View File

@ -38,7 +38,7 @@ virSexprError(virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(NULL, NULL, VIR_FROM_SEXPR, error, VIR_ERR_ERROR, __virRaiseError(NULL, NULL, NULL, VIR_FROM_SEXPR, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }

View File

@ -198,7 +198,7 @@ testError(virConnectPtr con,
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(con, dom, VIR_FROM_XEN, error, VIR_ERR_ERROR, __virRaiseError(con, dom, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info, 0); errmsg, info, NULL, 0, 0, errmsg, info, 0);
} }

View File

@ -17,7 +17,7 @@
#include "internal.h" #include "internal.h"
static virError lastErr = /* the last error */ static virError lastErr = /* the last error */
{ 0, 0, NULL, VIR_ERR_NONE, NULL, NULL, NULL, NULL, NULL, 0, 0 }; { 0, 0, NULL, VIR_ERR_NONE, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL };
static virErrorFunc virErrorHandler = NULL; /* global error handlet */ static virErrorFunc virErrorHandler = NULL; /* global error handlet */
static void *virUserData = NULL; /* associated data */ static void *virUserData = NULL; /* associated data */
@ -230,7 +230,7 @@ virConnSetErrorFunc(virConnectPtr conn, void *userData,
void void
virDefaultErrorFunc(virErrorPtr err) virDefaultErrorFunc(virErrorPtr err)
{ {
const char *lvl = "", *dom = "", *domain = ""; const char *lvl = "", *dom = "", *domain = "", *network = "";
int len; int len;
if ((err == NULL) || (err->code == VIR_ERR_OK)) if ((err == NULL) || (err->code == VIR_ERR_OK))
@ -277,24 +277,27 @@ virDefaultErrorFunc(virErrorPtr err)
} }
if ((err->dom != NULL) && (err->code != VIR_ERR_INVALID_DOMAIN)) { if ((err->dom != NULL) && (err->code != VIR_ERR_INVALID_DOMAIN)) {
domain = err->dom->name; domain = err->dom->name;
} else if ((err->net != NULL) && (err->code != VIR_ERR_INVALID_NETWORK)) {
network = err->net->name;
} }
len = strlen(err->message); len = strlen(err->message);
if ((err->domain == VIR_FROM_XML) && (err->code == VIR_ERR_XML_DETAIL) && if ((err->domain == VIR_FROM_XML) && (err->code == VIR_ERR_XML_DETAIL) &&
(err->int1 != 0)) (err->int1 != 0))
fprintf(stderr, "libvir: %s%s %s: line %d: %s", fprintf(stderr, "libvir: %s%s %s%s: line %d: %s",
dom, lvl, domain, err->int1, err->message); dom, lvl, domain, network, err->int1, err->message);
else if ((len == 0) || (err->message[len - 1] != '\n')) else if ((len == 0) || (err->message[len - 1] != '\n'))
fprintf(stderr, "libvir: %s%s %s: %s\n", fprintf(stderr, "libvir: %s%s %s%s: %s\n",
dom, lvl, domain, err->message); dom, lvl, domain, network, err->message);
else else
fprintf(stderr, "libvir: %s%s %s: %s", fprintf(stderr, "libvir: %s%s %s%s: %s",
dom, lvl, domain, err->message); dom, lvl, domain, network, err->message);
} }
/** /**
* __virRaiseError: * __virRaiseError:
* @conn: the connection to the hypervisor if available * @conn: the connection to the hypervisor if available
* @dom: the domain if available * @dom: the domain if available
* @net: the network if available
* @domain: the virErrorDomain indicating where it's coming from * @domain: the virErrorDomain indicating where it's coming from
* @code: the virErrorNumber code for the error * @code: the virErrorNumber code for the error
* @level: the virErrorLevel for the error * @level: the virErrorLevel for the error
@ -310,7 +313,7 @@ virDefaultErrorFunc(virErrorPtr err)
* immediately if a callback is found and store it for later handling. * immediately if a callback is found and store it for later handling.
*/ */
void void
__virRaiseError(virConnectPtr conn, virDomainPtr dom, __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net,
int domain, int code, virErrorLevel level, int domain, int code, virErrorLevel level,
const char *str1, const char *str2, const char *str3, const char *str1, const char *str2, const char *str3,
int int1, int int2, const char *msg, ...) int int1, int int2, const char *msg, ...)
@ -349,6 +352,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom,
virResetError(to); virResetError(to);
to->conn = conn; to->conn = conn;
to->dom = dom; to->dom = dom;
to->net = net;
to->domain = domain; to->domain = domain;
to->code = code; to->code = code;
to->message = str; to->message = str;

View File

@ -476,7 +476,7 @@ virXenError(virErrorNumber error, const char *info, int value)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, __virRaiseError(NULL, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info, value); errmsg, info, NULL, value, 0, errmsg, info, value);
} }

View File

@ -153,7 +153,7 @@ virXendError(virConnectPtr conn, virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(conn, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }
@ -174,7 +174,7 @@ virXendErrorInt(virConnectPtr conn, virErrorNumber error, int val)
return; return;
errmsg = __virErrorMsg(error, NULL); errmsg = __virErrorMsg(error, NULL);
__virRaiseError(conn, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
errmsg, NULL, NULL, val, 0, errmsg, val); errmsg, NULL, NULL, val, 0, errmsg, val);
} }

View File

@ -116,7 +116,7 @@ xenXMError(virConnectPtr conn, virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(conn, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XEND, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }

View File

@ -34,7 +34,7 @@ virXMLError(virErrorNumber error, const char *info, int value)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(NULL, NULL, VIR_FROM_XML, error, VIR_ERR_ERROR, __virRaiseError(NULL, NULL, NULL, VIR_FROM_XML, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info, value); errmsg, info, NULL, value, 0, errmsg, info, value);
} }

View File

@ -39,7 +39,7 @@ static void xmlRpcError(virErrorNumber error, const char *info, int value)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(NULL, NULL, VIR_FROM_RPC, error, VIR_ERR_ERROR, __virRaiseError(NULL, NULL, NULL, VIR_FROM_RPC, error, VIR_ERR_ERROR,
errmsg, info, NULL, value, 0, errmsg, info, value); errmsg, info, NULL, value, 0, errmsg, info, value);
} }

View File

@ -106,7 +106,7 @@ virXenStoreError(virConnectPtr conn, virErrorNumber error, const char *info)
return; return;
errmsg = __virErrorMsg(error, info); errmsg = __virErrorMsg(error, info);
__virRaiseError(conn, NULL, VIR_FROM_XENSTORE, error, VIR_ERR_ERROR, __virRaiseError(conn, NULL, NULL, VIR_FROM_XENSTORE, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info); errmsg, info, NULL, 0, 0, errmsg, info);
} }