From 8ce3203ad3321aa1fb487ffc0a2bb7731790ccad Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 14 Feb 2007 15:40:53 +0000 Subject: [PATCH] Tue Feb 14 15:37:17 EST 2007 Mark McLoughlin 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. --- ChangeLog | 17 +++++++++++++++++ include/libvirt/virterror.h | 1 + src/conf.c | 2 +- src/hash.c | 2 +- src/internal.h | 1 + src/libvirt.c | 7 +++---- src/proxy_internal.c | 2 +- src/qemu_internal.c | 20 ++++++++++---------- src/sexpr.c | 2 +- src/test.c | 2 +- src/virterror.c | 22 +++++++++++++--------- src/xen_internal.c | 2 +- src/xend_internal.c | 4 ++-- src/xm_internal.c | 2 +- src/xml.c | 2 +- src/xmlrpc.c | 2 +- src/xs_internal.c | 2 +- 17 files changed, 57 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1446c02a6c..2a52db41d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Tue Feb 14 15:37:17 EST 2007 Mark McLoughlin + + 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 * include/libvirt/libvirt.h.in: add the networks APIs diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 80d43f9cd9..cc0c95fa23 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -72,6 +72,7 @@ struct _virError { char *str3; /* extra string information */ int int1; /* extra number information */ int int2; /* extra number information */ + virNetworkPtr net; /* the network if available */ }; /** diff --git a/src/conf.c b/src/conf.c index 714194c08c..b59daef35d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -95,7 +95,7 @@ virConfError(virConfPtr conf ATTRIBUTE_UNUSED, return; 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); } diff --git a/src/hash.c b/src/hash.c index 8d7dd73063..2145af0b09 100644 --- a/src/hash.c +++ b/src/hash.c @@ -617,7 +617,7 @@ virHashError(virConnectPtr conn, virErrorNumber error, const char *info) return; 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); } diff --git a/src/internal.h b/src/internal.h index d30a0a0d3b..237dfef47f 100644 --- a/src/internal.h +++ b/src/internal.h @@ -200,6 +200,7 @@ char *virDomainGetVMInfo(virDomainPtr domain, ************************************************************************/ void __virRaiseError(virConnectPtr conn, virDomainPtr dom, + virNetworkPtr net, int domain, int code, virErrorLevel level, diff --git a/src/libvirt.c b/src/libvirt.c index c93058c6f8..c4a82289a3 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -107,7 +107,7 @@ virLibConnError(virConnectPtr conn, virErrorNumber error, const char *info) return; 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); } @@ -133,7 +133,7 @@ virLibDomainError(virDomainPtr domain, virErrorNumber error, if (error != VIR_ERR_INVALID_DOMAIN) { 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); } @@ -159,8 +159,7 @@ virLibNetworkError(virNetworkPtr network, virErrorNumber error, if (error != VIR_ERR_INVALID_NETWORK) { conn = network->conn; } - /* XXX: should be able to pass network pointer here */ - __virRaiseError(conn, NULL, VIR_FROM_NET, error, VIR_ERR_ERROR, + __virRaiseError(conn, NULL, network, VIR_FROM_NET, error, VIR_ERR_ERROR, errmsg, info, NULL, 0, 0, errmsg, info); } diff --git a/src/proxy_internal.c b/src/proxy_internal.c index 1323b3db2e..1e6e453cf8 100644 --- a/src/proxy_internal.c +++ b/src/proxy_internal.c @@ -116,7 +116,7 @@ virProxyError(virConnectPtr conn, virErrorNumber error, const char *info) return; 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); } diff --git a/src/qemu_internal.c b/src/qemu_internal.c index c5e226bc84..c5fe11303c 100644 --- a/src/qemu_internal.c +++ b/src/qemu_internal.c @@ -61,7 +61,7 @@ qemuError(virConnectPtr con, return; 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); } @@ -244,7 +244,7 @@ qemuOpenClientUNIX(virConnectPtr conn, const char *path, int autostart) { return (-1); } - conn->handle = fd; + conn->qemud_fd = fd; return (0); } @@ -269,7 +269,7 @@ static int qemuProcessRequest(virConnectPtr conn, /* Block sending entire outgoing packet */ while (outLeft) { - int got = write(conn->handle, out+outDone, outLeft); + int got = write(conn->qemud_fd, out+outDone, outLeft); if (got < 0) { return -1; } @@ -279,7 +279,7 @@ static int qemuProcessRequest(virConnectPtr conn, /* Block waiting for header to come back */ while (inLeft) { - int done = read(conn->handle, in+inGot, inLeft); + int done = read(conn->qemud_fd, in+inGot, inLeft); if (done <= 0) { return -1; } @@ -307,7 +307,7 @@ static int qemuProcessRequest(virConnectPtr conn, /* Now block reading in body */ inLeft = reply->header.dataSize; while (inLeft) { - int done = read(conn->handle, in+inGot, inLeft); + int done = read(conn->qemud_fd, in+inGot, inLeft); if (done <= 0) { return -1; } @@ -389,11 +389,11 @@ static int qemuOpen(virConnectPtr conn, return -1; } - conn->handle = -1; + conn->qemud_fd = -1; qemuOpenConnection(conn, uri, flags & VIR_DRV_OPEN_RO ? 1 : 0); xmlFreeURI(uri); - if (conn->handle < 0) { + if (conn->qemud_fd < 0) { return -1; } @@ -402,9 +402,9 @@ static int qemuOpen(virConnectPtr conn, static int qemuClose (virConnectPtr conn) { - if (conn->handle != -1) { - close(conn->handle); - conn->handle = -1; + if (conn->qemud_fd != -1) { + close(conn->qemud_fd); + conn->qemud_fd = -1; } return 0; } diff --git a/src/sexpr.c b/src/sexpr.c index 1eaa023104..12599518cb 100644 --- a/src/sexpr.c +++ b/src/sexpr.c @@ -38,7 +38,7 @@ virSexprError(virErrorNumber error, const char *info) return; 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); } diff --git a/src/test.c b/src/test.c index 6762ec8917..4025f99dcf 100644 --- a/src/test.c +++ b/src/test.c @@ -198,7 +198,7 @@ testError(virConnectPtr con, return; 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); } diff --git a/src/virterror.c b/src/virterror.c index 23446c1f45..8a4ac03529 100644 --- a/src/virterror.c +++ b/src/virterror.c @@ -17,7 +17,7 @@ #include "internal.h" 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 void *virUserData = NULL; /* associated data */ @@ -230,7 +230,7 @@ virConnSetErrorFunc(virConnectPtr conn, void *userData, void virDefaultErrorFunc(virErrorPtr err) { - const char *lvl = "", *dom = "", *domain = ""; + const char *lvl = "", *dom = "", *domain = "", *network = ""; int len; 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)) { domain = err->dom->name; + } else if ((err->net != NULL) && (err->code != VIR_ERR_INVALID_NETWORK)) { + network = err->net->name; } len = strlen(err->message); if ((err->domain == VIR_FROM_XML) && (err->code == VIR_ERR_XML_DETAIL) && (err->int1 != 0)) - fprintf(stderr, "libvir: %s%s %s: line %d: %s", - dom, lvl, domain, err->int1, err->message); + fprintf(stderr, "libvir: %s%s %s%s: line %d: %s", + dom, lvl, domain, network, err->int1, err->message); else if ((len == 0) || (err->message[len - 1] != '\n')) - fprintf(stderr, "libvir: %s%s %s: %s\n", - dom, lvl, domain, err->message); + fprintf(stderr, "libvir: %s%s %s%s: %s\n", + dom, lvl, domain, network, err->message); else - fprintf(stderr, "libvir: %s%s %s: %s", - dom, lvl, domain, err->message); + fprintf(stderr, "libvir: %s%s %s%s: %s", + dom, lvl, domain, network, err->message); } /** * __virRaiseError: * @conn: the connection to the hypervisor if available * @dom: the domain if available + * @net: the network if available * @domain: the virErrorDomain indicating where it's coming from * @code: the virErrorNumber code 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. */ void -__virRaiseError(virConnectPtr conn, virDomainPtr dom, +__virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net, int domain, int code, virErrorLevel level, const char *str1, const char *str2, const char *str3, int int1, int int2, const char *msg, ...) @@ -349,6 +352,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom, virResetError(to); to->conn = conn; to->dom = dom; + to->net = net; to->domain = domain; to->code = code; to->message = str; diff --git a/src/xen_internal.c b/src/xen_internal.c index cd11bcd5c2..f885c662f0 100644 --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -476,7 +476,7 @@ virXenError(virErrorNumber error, const char *info, int value) return; 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); } diff --git a/src/xend_internal.c b/src/xend_internal.c index 71056a9188..23bf12b297 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -153,7 +153,7 @@ virXendError(virConnectPtr conn, virErrorNumber error, const char *info) return; 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); } @@ -174,7 +174,7 @@ virXendErrorInt(virConnectPtr conn, virErrorNumber error, int val) return; 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); } diff --git a/src/xm_internal.c b/src/xm_internal.c index 7ad64b51a1..6f8c5be61d 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -116,7 +116,7 @@ xenXMError(virConnectPtr conn, virErrorNumber error, const char *info) return; 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); } diff --git a/src/xml.c b/src/xml.c index b89a420efc..0c7db5805f 100644 --- a/src/xml.c +++ b/src/xml.c @@ -34,7 +34,7 @@ virXMLError(virErrorNumber error, const char *info, int value) return; 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); } diff --git a/src/xmlrpc.c b/src/xmlrpc.c index 795dc36394..d58f88714c 100644 --- a/src/xmlrpc.c +++ b/src/xmlrpc.c @@ -39,7 +39,7 @@ static void xmlRpcError(virErrorNumber error, const char *info, int value) return; 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); } diff --git a/src/xs_internal.c b/src/xs_internal.c index 6e63a2b8b2..9dca5b29ec 100644 --- a/src/xs_internal.c +++ b/src/xs_internal.c @@ -106,7 +106,7 @@ virXenStoreError(virConnectPtr conn, virErrorNumber error, const char *info) return; 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); }