diff --git a/ChangeLog b/ChangeLog index 108fe8affb..ad47024e08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +Tue Nov 4 22:20:31 UTC 2008 Daniel P. Berrange + + Move internal error API declarations into their own file + * src/Makefile.am, src/virterror_internal.h: Add file for + internal error reporting APIs. + * src/internal.c: Remove virRaiseError/virReportError API + declarations + * src/conf.c, src/domain_conf.c, src/hash.c, + src/libvirt.c, src/lxc_conf.c, src/lxc_conf.h, + src/lxc_container.c, src/lxc_controller.c, src/lxc_driver.c, + src/network_conf.c, src/network_driver.c, src/nodeinfo.c, + src/openvz_conf.c, src/openvz_conf.h, src/openvz_driver.c, + src/proxy_internal.c, src/qemu_conf.c, src/qemu_conf.h, + src/qemu_driver.c, src/qparams.c, src/remote_internal.c, + src/sexpr.c, src/stats_linux.c, src/storage_backend.c, + src/storage_backend_disk.c, src/storage_backend_fs.c, + src/storage_backend_iscsi.c, src/storage_backend_logical.c, + src/storage_conf.c, src/storage_conf.h, src/storage_driver.c, + src/test.c, src/util.c, src/virterror.c, src/xen_internal.c, + src/xen_unified.c, src/xend_internal.c, src/xm_internal.c, + src/xml.c, src/xmlrpc.c, src/xs_internal.c: Add includes + of new virterror_internal.h file where required, and remove + leading __ from virRaiseError api calls + Tue Nov 4 22:14:31 UTC 2008 Daniel P. Berrange Support passing UUID and ID to qemu/xenner diff --git a/src/Makefile.am b/src/Makefile.am index 8934c3c1d0..95f57ff2f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,7 +50,7 @@ GENERIC_LIB_SOURCES = \ stats_linux.c stats_linux.h \ uuid.c uuid.h \ util.c util.h \ - virterror.c \ + virterror.c virterror_internal.h \ xml.c xml.h # Domain driver generic impl APIs @@ -149,7 +149,7 @@ libvirt_la_SOURCES = \ driver.h \ hash.c hash.h \ internal.h \ - libvirt.c \ + libvirt.c libvirt_internal.h \ $(GENERIC_LIB_SOURCES) \ $(DOMAIN_CONF_SOURCES) \ $(NETWORK_CONF_SOURCES) \ diff --git a/src/conf.c b/src/conf.c index 057ece0f06..bce5025103 100644 --- a/src/conf.c +++ b/src/conf.c @@ -18,7 +18,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "buf.h" #include "conf.h" #include "util.h" @@ -96,13 +96,13 @@ virConfError(virConfParserCtxtPtr ctxt, /* Construct the string 'filename:line: info' if we have that. */ if (ctxt && ctxt->filename) { - __virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, + virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, info, ctxt->filename, NULL, ctxt->line, 0, "%s:%d: %s", ctxt->filename, ctxt->line, info); } else { - format = __virErrorMsg(error, info); - __virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, + format = virErrorMsg(error, info); + virRaiseError(NULL, NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, info, NULL, NULL, ctxt ? ctxt->line : 0, 0, format, info); diff --git a/src/domain_conf.c b/src/domain_conf.c index 13baa29196..2d92b07a62 100644 --- a/src/domain_conf.c +++ b/src/domain_conf.c @@ -29,8 +29,7 @@ #include #include -#include "internal.h" - +#include "virterror_internal.h" #include "domain_conf.h" #include "memory.h" #include "verify.h" @@ -142,7 +141,7 @@ VIR_ENUM_IMPL(virDomainHostdevSubsys, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST, "pci") #define virDomainReportError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_DOMAIN, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_DOMAIN, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) virDomainObjPtr virDomainFindByID(const virDomainObjListPtr doms, diff --git a/src/hash.c b/src/hash.c index 0a5bdcd362..3374244353 100644 --- a/src/hash.c +++ b/src/hash.c @@ -23,7 +23,8 @@ #include #include #include -#include "internal.h" + +#include "virterror_internal.h" #include "hash.h" #include "memory.h" @@ -32,7 +33,7 @@ /* #define DEBUG_GROW */ #define virHashError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) /* @@ -732,8 +733,8 @@ virReleaseConnect(virConnectPtr conn) { virHashFree(conn->storageVols, (virHashDeallocator) virStorageVolFreeName); virResetError(&conn->err); - if (__lastErr.conn == conn) - __lastErr.conn = NULL; + if (virLastErr.conn == conn) + virLastErr.conn = NULL; VIR_FREE(conn->name); @@ -862,8 +863,8 @@ virReleaseDomain(virDomainPtr domain) { if (conn->err.dom == domain) conn->err.dom = NULL; - if (__lastErr.dom == domain) - __lastErr.dom = NULL; + if (virLastErr.dom == domain) + virLastErr.dom = NULL; domain->magic = -1; domain->id = -1; VIR_FREE(domain->name); @@ -998,8 +999,8 @@ virReleaseNetwork(virNetworkPtr network) { if (conn->err.net == network) conn->err.net = NULL; - if (__lastErr.net == network) - __lastErr.net = NULL; + if (virLastErr.net == network) + virLastErr.net = NULL; network->magic = -1; VIR_FREE(network->name); diff --git a/src/internal.h b/src/internal.h index 5682a2df07..8a8d4e132b 100644 --- a/src/internal.h +++ b/src/internal.h @@ -295,30 +295,6 @@ struct _virStorageVol { }; -/************************************************************************ - * * - * API for error handling * - * * - ************************************************************************/ -extern virError __lastErr; -void __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, ...) - ATTRIBUTE_FORMAT(printf, 12, 13); -const char *__virErrorMsg(virErrorNumber error, const char *info); -void __virReportErrorHelper(virConnectPtr conn, int domcode, int errcode, - const char *filename ATTRIBUTE_UNUSED, - const char *funcname ATTRIBUTE_UNUSED, - long long linenr ATTRIBUTE_UNUSED, - const char *fmt, ...) - ATTRIBUTE_FORMAT(printf, 7, 8); /************************************************************************ * * diff --git a/src/libvirt.c b/src/libvirt.c index ea9d901d7e..ae16b10f5d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -31,7 +31,7 @@ #include #endif -#include "internal.h" +#include "virterror_internal.h" #include "driver.h" #include "uuid.h" @@ -325,9 +325,9 @@ virLibConnError(virConnectPtr conn, virErrorNumber error, const char *info) if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); - __virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR, - errmsg, info, NULL, 0, 0, errmsg, info); + errmsg = virErrorMsg(error, info); + virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_ERROR, + errmsg, info, NULL, 0, 0, errmsg, info); } /** @@ -346,9 +346,9 @@ virLibConnWarning(virConnectPtr conn, virErrorNumber error, const char *info) if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); - __virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_WARNING, - errmsg, info, NULL, 0, 0, errmsg, info); + errmsg = virErrorMsg(error, info); + virRaiseError(conn, NULL, NULL, VIR_FROM_NONE, error, VIR_ERR_WARNING, + errmsg, info, NULL, 0, 0, errmsg, info); } /** @@ -369,12 +369,12 @@ virLibDomainError(virDomainPtr domain, virErrorNumber error, if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); + errmsg = virErrorMsg(error, info); if (error != VIR_ERR_INVALID_DOMAIN) { conn = domain->conn; } - __virRaiseError(conn, domain, NULL, VIR_FROM_DOM, error, VIR_ERR_ERROR, - errmsg, info, NULL, 0, 0, errmsg, info); + virRaiseError(conn, domain, NULL, VIR_FROM_DOM, error, VIR_ERR_ERROR, + errmsg, info, NULL, 0, 0, errmsg, info); } /** @@ -395,12 +395,12 @@ virLibNetworkError(virNetworkPtr network, virErrorNumber error, if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); + errmsg = virErrorMsg(error, info); if (error != VIR_ERR_INVALID_NETWORK) { conn = network->conn; } - __virRaiseError(conn, NULL, network, VIR_FROM_NET, error, VIR_ERR_ERROR, - errmsg, info, NULL, 0, 0, errmsg, info); + virRaiseError(conn, NULL, network, VIR_FROM_NET, error, VIR_ERR_ERROR, + errmsg, info, NULL, 0, 0, errmsg, info); } /** @@ -421,12 +421,12 @@ virLibStoragePoolError(virStoragePoolPtr pool, virErrorNumber error, if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); + errmsg = virErrorMsg(error, info); if (error != VIR_ERR_INVALID_STORAGE_POOL) conn = pool->conn; - __virRaiseError(conn, NULL, NULL, VIR_FROM_STORAGE, error, VIR_ERR_ERROR, - errmsg, info, NULL, 0, 0, errmsg, info); + virRaiseError(conn, NULL, NULL, VIR_FROM_STORAGE, error, VIR_ERR_ERROR, + errmsg, info, NULL, 0, 0, errmsg, info); } /** @@ -447,12 +447,12 @@ virLibStorageVolError(virStorageVolPtr vol, virErrorNumber error, if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); + errmsg = virErrorMsg(error, info); if (error != VIR_ERR_INVALID_STORAGE_VOL) conn = vol->conn; - __virRaiseError(conn, NULL, NULL, VIR_FROM_STORAGE, error, VIR_ERR_ERROR, - errmsg, info, NULL, 0, 0, errmsg, info); + virRaiseError(conn, NULL, NULL, VIR_FROM_STORAGE, error, VIR_ERR_ERROR, + errmsg, info, NULL, 0, 0, errmsg, info); } /** @@ -855,13 +855,13 @@ failed: /* If no global error was set, copy any error set in the connection object we're about to dispose of */ - if (__lastErr.code == VIR_ERR_OK) { - memcpy(&__lastErr, &ret->err, sizeof(ret->err)); + if (virLastErr.code == VIR_ERR_OK) { + memcpy(&virLastErr, &ret->err, sizeof(ret->err)); memset(&ret->err, 0, sizeof(ret->err)); } /* Still no error set, then raise a generic error */ - if (__lastErr.code == VIR_ERR_OK) + if (virLastErr.code == VIR_ERR_OK) virLibConnError (NULL, VIR_ERR_INTERNAL_ERROR, _("unable to open connection")); diff --git a/src/lxc_conf.c b/src/lxc_conf.c index b8d6c74929..76f4e9dfba 100644 --- a/src/lxc_conf.c +++ b/src/lxc_conf.c @@ -27,6 +27,7 @@ #include +#include "virterror_internal.h" #include "lxc_conf.h" /* Functions */ diff --git a/src/lxc_conf.h b/src/lxc_conf.h index 857aa2ff5b..5b3db863d2 100644 --- a/src/lxc_conf.h +++ b/src/lxc_conf.h @@ -50,7 +50,7 @@ int lxcLoadDriverConfig(lxc_driver_t *driver); virCapsPtr lxcCapsInit(void); #define lxcError(conn, dom, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_LXC, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_LXC, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) #endif /* LXC_CONF_H */ diff --git a/src/lxc_container.c b/src/lxc_container.c index e94b2d54ca..3caf7b5c6b 100644 --- a/src/lxc_container.c +++ b/src/lxc_container.c @@ -41,6 +41,7 @@ /* For MS_MOVE */ #include +#include "virterror_internal.h" #include "lxc_container.h" #include "util.h" #include "memory.h" diff --git a/src/lxc_controller.c b/src/lxc_controller.c index 58c772e54a..0dc2e71855 100644 --- a/src/lxc_controller.c +++ b/src/lxc_controller.c @@ -34,7 +34,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "util.h" #include "lxc_conf.h" diff --git a/src/lxc_driver.c b/src/lxc_driver.c index 8b30cdd3b0..e878ecf4cb 100644 --- a/src/lxc_driver.c +++ b/src/lxc_driver.c @@ -35,7 +35,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "lxc_conf.h" #include "lxc_container.h" #include "lxc_driver.h" diff --git a/src/network_conf.c b/src/network_conf.c index 99a84dc47d..3c062d334a 100644 --- a/src/network_conf.c +++ b/src/network_conf.c @@ -33,8 +33,7 @@ #include #include -#include "internal.h" - +#include "virterror_internal.h" #include "network_conf.h" #include "memory.h" #include "xml.h" @@ -50,7 +49,7 @@ VIR_ENUM_IMPL(virNetworkForward, "none", "nat", "route" ) #define virNetworkReportError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_NETWORK, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_NETWORK, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets, diff --git a/src/network_driver.c b/src/network_driver.c index f483a258ab..2caf5097e3 100644 --- a/src/network_driver.c +++ b/src/network_driver.c @@ -44,6 +44,7 @@ #include #include +#include "virterror_internal.h" #include "network_driver.h" #include "network_conf.h" #include "driver.h" @@ -73,7 +74,7 @@ static int networkShutdown(void); #define networkLog(level, msg...) fprintf(stderr, msg) #define networkReportError(conn, dom, net, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 52a6035fca..fd58c2bb6c 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -33,7 +33,7 @@ #include #endif -#include "internal.h" +#include "virterror_internal.h" #include "nodeinfo.h" #include "physmem.h" #include "util.h" @@ -63,7 +63,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n while (*buf && c_isspace(*buf)) buf++; if (*buf != ':') { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "parsing cpuinfo processor"); return -1; @@ -76,7 +76,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n while (*buf && c_isspace(*buf)) buf++; if (*buf != ':' || !buf[1]) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "parsing cpuinfo cpu MHz"); return -1; @@ -92,7 +92,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n while (*buf && c_isspace(*buf)) buf++; if (*buf != ':' || !buf[1]) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "parsing cpuinfo cpu cores %c", *buf); return -1; @@ -105,7 +105,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n } if (!nodeinfo->cpus) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "no cpus found"); return -1; @@ -129,7 +129,7 @@ int virNodeInfoPopulate(virConnectPtr conn, struct utsname info; if (uname(&info) < 0) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "cannot extract machine type %s", strerror(errno)); return -1; @@ -148,7 +148,7 @@ int virNodeInfoPopulate(virConnectPtr conn, int ret; FILE *cpuinfo = fopen(CPUINFO_PATH, "r"); if (!cpuinfo) { - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "cannot open %s %s", CPUINFO_PATH, strerror(errno)); return -1; @@ -165,7 +165,7 @@ int virNodeInfoPopulate(virConnectPtr conn, } #else /* XXX Solaris will need an impl later if they port QEMU driver */ - __virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, + virRaiseError(conn, NULL, NULL, 0, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s:%s not implemented on this platform\n", __FILE__, __FUNCTION__); return -1; diff --git a/src/openvz_conf.c b/src/openvz_conf.c index 9fb867f310..914d7ffd7e 100644 --- a/src/openvz_conf.c +++ b/src/openvz_conf.c @@ -43,6 +43,7 @@ #include #include +#include "virterror_internal.h" #include "openvz_conf.h" #include "uuid.h" #include "buf.h" diff --git a/src/openvz_conf.h b/src/openvz_conf.h index ac604dc518..d06a547741 100644 --- a/src/openvz_conf.h +++ b/src/openvz_conf.h @@ -42,7 +42,7 @@ enum { OPENVZ_WARN, OPENVZ_ERR }; fprintf(stderr, "\n"); } #define openvzError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_OPENVZ, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_OPENVZ, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) diff --git a/src/openvz_driver.c b/src/openvz_driver.c index b166b0656c..308d640c7b 100644 --- a/src/openvz_driver.c +++ b/src/openvz_driver.c @@ -47,7 +47,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "openvz_driver.h" #include "event.h" #include "buf.h" diff --git a/src/proxy_internal.c b/src/proxy_internal.c index 47be5d104d..3e755fec1f 100644 --- a/src/proxy_internal.c +++ b/src/proxy_internal.c @@ -21,7 +21,8 @@ #include #include #include -#include "internal.h" + +#include "virterror_internal.h" #include "driver.h" #include "proxy_internal.h" #include "util.h" @@ -93,7 +94,7 @@ struct xenUnifiedDriver xenProxyDriver = { ************************************************************************/ #define virProxyError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_PROXY, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_PROXY, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) /************************************************************************ diff --git a/src/qemu_conf.c b/src/qemu_conf.c index e7cbdf606e..54ac23d237 100644 --- a/src/qemu_conf.c +++ b/src/qemu_conf.c @@ -40,6 +40,7 @@ #include #endif +#include "virterror_internal.h" #include "qemu_conf.h" #include "uuid.h" #include "buf.h" diff --git a/src/qemu_conf.h b/src/qemu_conf.h index 2fb5ae2f96..055f37b0c9 100644 --- a/src/qemu_conf.h +++ b/src/qemu_conf.h @@ -72,7 +72,7 @@ struct qemud_driver { #define qemudReportError(conn, dom, net, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_QEMU, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index cea071ae39..d0c3fd5e91 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -52,6 +52,7 @@ #include #endif +#include "virterror_internal.h" #include "qemu_driver.h" #include "qemu_conf.h" #include "c-ctype.h" diff --git a/src/qparams.c b/src/qparams.c index ed5bddc400..396a56bf4d 100644 --- a/src/qparams.c +++ b/src/qparams.c @@ -26,12 +26,13 @@ #include #include +#include "virterror_internal.h" #include "buf.h" #include "memory.h" #include "qparams.h" #define qparam_report_oom(void) \ - __virReportErrorHelper(NULL, VIR_FROM_NONE, VIR_ERR_NO_MEMORY, \ + virReportErrorHelper(NULL, VIR_FROM_NONE, VIR_ERR_NO_MEMORY, \ __FILE__, __FUNCTION__, __LINE__, NULL) struct qparam_set * diff --git a/src/remote_internal.c b/src/remote_internal.c index 5b82f99079..d8bc37249a 100644 --- a/src/remote_internal.c +++ b/src/remote_internal.c @@ -73,7 +73,7 @@ # define AI_ADDRCONFIG 0 #endif -#include "internal.h" +#include "virterror_internal.h" #include "driver.h" #include "buf.h" #include "qparams.h" @@ -3675,7 +3675,7 @@ remoteAuthenticate (virConnectPtr conn, struct private_data *priv, int in_open, } else if (STRCASEEQ(authtype, "polkit")) { want = REMOTE_AUTH_POLKIT; } else { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown authentication type %s"), authtype); @@ -3686,7 +3686,7 @@ remoteAuthenticate (virConnectPtr conn, struct private_data *priv, int in_open, type = want; } if (type == REMOTE_AUTH_NONE) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("requested authentication type %s rejected"), authtype); @@ -3726,7 +3726,7 @@ remoteAuthenticate (virConnectPtr conn, struct private_data *priv, int in_open, break; default: - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unsupported authentication type %d"), @@ -3756,7 +3756,7 @@ static char *addrToString(struct sockaddr_storage *sa, socklen_t salen) host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV)) != 0) { - __virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("Cannot resolve address %d: %s"), @@ -3765,7 +3765,7 @@ static char *addrToString(struct sockaddr_storage *sa, socklen_t salen) } if (VIR_ALLOC_N(addr, strlen(host) + 1 + strlen(port) + 1) < 0) { - __virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (NULL, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "address"); @@ -3975,7 +3975,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, /* Sets up the SASL library as a whole */ err = sasl_client_init(NULL); if (err != SASL_OK) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("failed to initialize SASL library: %d (%s)"), err, sasl_errstring(err, NULL, NULL)); @@ -3985,7 +3985,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, /* Get local address in form IPADDR:PORT */ salen = sizeof(sa); if (getsockname(priv->sock, (struct sockaddr*)&sa, &salen) < 0) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("failed to get sock address %d (%s)"), errno, strerror(errno)); @@ -3997,7 +3997,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, /* Get remote address in form IPADDR:PORT */ salen = sizeof(sa); if (getpeername(priv->sock, (struct sockaddr*)&sa, &salen) < 0) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("failed to get peer address %d (%s)"), errno, strerror(errno)); @@ -4023,7 +4023,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, &saslconn); if (err != SASL_OK) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("Failed to create SASL client context: %d (%s)"), err, sasl_errstring(err, NULL, NULL)); @@ -4036,7 +4036,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, cipher = gnutls_cipher_get(priv->session); if (!(ssf = (sasl_ssf_t)gnutls_cipher_get_key_size(cipher))) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", _("invalid cipher size for TLS session")); goto cleanup; @@ -4046,7 +4046,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, DEBUG("Setting external SSF %d", ssf); err = sasl_setprop(saslconn, SASL_SSF_EXTERNAL, &ssf); if (err != SASL_OK) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("cannot set external SSF %d (%s)"), err, sasl_errstring(err, NULL, NULL)); @@ -4065,7 +4065,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, err = sasl_setprop(saslconn, SASL_SEC_PROPS, &secprops); if (err != SASL_OK) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_INTERNAL_ERROR, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("cannot set security props %d (%s)"), err, sasl_errstring(err, NULL, NULL)); @@ -4083,7 +4083,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, mechlist = iret.mechlist; if (wantmech) { if (strstr(mechlist, wantmech) == NULL) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("SASL mechanism %s not supported by server"), @@ -4103,7 +4103,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, &clientoutlen, &mech); if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("Failed to start SASL negotiation: %d (%s)"), err, sasl_errdetail(saslconn)); @@ -4120,7 +4120,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, } if ((ncred = remoteAuthMakeCredentials(interact, &cred)) < 0) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", _("Failed to make auth credentials")); @@ -4137,7 +4137,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, } else { msg = "No authentication callback available"; } - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", msg); goto cleanup; @@ -4145,7 +4145,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, VIR_FREE(iret.mechlist); if (clientoutlen > REMOTE_AUTH_SASL_DATA_MAX) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("SASL negotiation data too long: %d bytes"), clientoutlen); @@ -4185,7 +4185,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, &clientout, &clientoutlen); if (err != SASL_OK && err != SASL_CONTINUE && err != SASL_INTERACT) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("Failed SASL step: %d (%s)"), err, sasl_errdetail(saslconn)); @@ -4199,7 +4199,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, cred = NULL; } if ((ncred = remoteAuthMakeCredentials(interact, &cred)) < 0) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", _("Failed to make auth credentials")); goto cleanup; @@ -4214,7 +4214,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, } else { msg = "No authentication callback available"; } - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", msg); goto cleanup; @@ -4262,7 +4262,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, if (!priv->uses_tls) { err = sasl_getprop(saslconn, SASL_SSF, &val); if (err != SASL_OK) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("cannot query SASL ssf on connection %d (%s)"), err, sasl_errstring(err, NULL, NULL)); @@ -4271,7 +4271,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open, ssf = *(const int *)val; DEBUG("SASL SSF value %d", ssf); if (ssf < 56) { /* 56 == DES level, good for Kerberos */ - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("negotiation SSF %d was not strong enough"), ssf); goto cleanup; @@ -4325,7 +4325,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open, if (allowcb) { /* Run the authentication callback */ if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) { - __virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (in_open ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_AUTH_FAILED, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, "%s", _("Failed to collect auth credentials")); return -1; @@ -4509,7 +4509,7 @@ retry_read: /* Check program, version, etc. are what we expect. */ if (hdr.prog != REMOTE_PROGRAM) { - __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, + virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown program (received %x, expected %x)"), @@ -4517,7 +4517,7 @@ retry_read: return -1; } if (hdr.vers != REMOTE_PROTOCOL_VERSION) { - __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, + virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown protocol version (received %x, expected %x)"), @@ -4540,7 +4540,7 @@ retry_read: goto retry_read; } if (hdr.proc != proc_nr) { - __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, + virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown procedure (received %x, expected %x)"), @@ -4548,7 +4548,7 @@ retry_read: return -1; } if (hdr.direction != REMOTE_REPLY) { - __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, + virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown direction (received %x, expected %x)"), @@ -4556,7 +4556,7 @@ retry_read: return -1; } if (hdr.serial != serial) { - __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown serial (received %x, expected %x)"), hdr.serial, serial); @@ -4599,7 +4599,7 @@ retry_read: return -1; default: - __virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, + virRaiseError (flags & REMOTE_CALL_IN_OPEN ? NULL : conn, NULL, NULL, VIR_FROM_REMOTE, VIR_ERR_RPC, VIR_ERR_ERROR, NULL, NULL, NULL, 0, 0, _("unknown status (received %x)"), hdr.status); @@ -4809,8 +4809,8 @@ error (virConnectPtr conn, virErrorNumber code, const char *info) { const char *errmsg; - errmsg = __virErrorMsg (code, info); - __virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, + errmsg = virErrorMsg (code, info); + virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, code, VIR_ERR_ERROR, errmsg, info, NULL, 0, 0, errmsg, info); } @@ -4832,8 +4832,8 @@ errorf (virConnectPtr conn, virErrorNumber code, const char *fmt, ...) errorMessage[0] = '\0'; } - errmsg = __virErrorMsg (code, errorMessage); - __virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, + errmsg = virErrorMsg (code, errorMessage); + virRaiseError (conn, NULL, NULL, VIR_FROM_REMOTE, code, VIR_ERR_ERROR, errmsg, errorMessage, NULL, -1, -1, errmsg, errorMessage); @@ -4850,7 +4850,7 @@ server_error (virConnectPtr conn, remote_error *err) dom = err->dom ? get_nonnull_domain (conn, *err->dom) : NULL; net = err->net ? get_nonnull_network (conn, *err->net) : NULL; - __virRaiseError (conn, dom, net, + virRaiseError (conn, dom, net, err->domain, err->code, err->level, err->str1 ? *err->str1 : NULL, err->str2 ? *err->str2 : NULL, @@ -4866,7 +4866,7 @@ server_error (virConnectPtr conn, remote_error *err) /* get_nonnull_domain and get_nonnull_network turn an on-wire * (name, uuid) pair into virDomainPtr or virNetworkPtr object. * These can return NULL if underlying memory allocations fail, - * but if they do then virterror has been set. + * but if they do then virterror_internal.has been set. */ static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain) diff --git a/src/sexpr.c b/src/sexpr.c index 355c5a6b49..d97bf77e43 100644 --- a/src/sexpr.c +++ b/src/sexpr.c @@ -18,13 +18,13 @@ #include "c-ctype.h" #include -#include "internal.h" +#include "virterror_internal.h" #include "sexpr.h" #include "util.h" #include "memory.h" #define virSexprError(code, fmt...) \ - __virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \ + virReportErrorHelper(NULL, VIR_FROM_SEXPR, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) /** diff --git a/src/stats_linux.c b/src/stats_linux.c index 3f7dd52a46..63cfaa817f 100644 --- a/src/stats_linux.c +++ b/src/stats_linux.c @@ -24,7 +24,7 @@ #include #endif -#include "internal.h" +#include "virterror_internal.h" #include "util.h" #include "xen_unified.h" #include "stats_linux.h" @@ -48,13 +48,13 @@ statsErrorFunc (virConnectPtr conn, char fullinfo[1000]; const char *errmsg; - errmsg = __virErrorMsg(error, info); + errmsg = virErrorMsg(error, info); if (func != NULL) { snprintf(fullinfo, sizeof (fullinfo) - 1, "%s: %s", func, info); fullinfo[sizeof (fullinfo) - 1] = 0; info = fullinfo; } - __virRaiseError(conn, NULL, NULL, VIR_FROM_STATS_LINUX, error, + virRaiseError(conn, NULL, NULL, VIR_FROM_STATS_LINUX, error, VIR_ERR_ERROR, errmsg, info, NULL, value, 0, errmsg, info, value); diff --git a/src/storage_backend.c b/src/storage_backend.c index b8772ff006..d146cb75fa 100644 --- a/src/storage_backend.c +++ b/src/storage_backend.c @@ -41,7 +41,7 @@ #include #endif -#include "internal.h" +#include "virterror_internal.h" #include "util.h" #include "memory.h" diff --git a/src/storage_backend_disk.c b/src/storage_backend_disk.c index b2768ca31b..2f51f81263 100644 --- a/src/storage_backend_disk.c +++ b/src/storage_backend_disk.c @@ -25,7 +25,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "storage_backend_disk.h" #include "util.h" #include "memory.h" diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c index 65ec5297ae..860044c456 100644 --- a/src/storage_backend_fs.c +++ b/src/storage_backend_fs.c @@ -40,7 +40,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "storage_backend_fs.h" #include "storage_conf.h" #include "util.h" diff --git a/src/storage_backend_iscsi.c b/src/storage_backend_iscsi.c index bc71eb605f..d3d7613bef 100644 --- a/src/storage_backend_iscsi.c +++ b/src/storage_backend_iscsi.c @@ -34,7 +34,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "storage_backend_iscsi.h" #include "util.h" #include "memory.h" diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c index 589a3a418f..53bea67f35 100644 --- a/src/storage_backend_logical.c +++ b/src/storage_backend_logical.c @@ -31,7 +31,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "storage_backend_logical.h" #include "storage_conf.h" #include "util.h" diff --git a/src/storage_conf.c b/src/storage_conf.c index 033d678df7..351052710e 100644 --- a/src/storage_conf.c +++ b/src/storage_conf.c @@ -38,7 +38,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "storage_conf.h" #include "storage_backend.h" #include "xml.h" diff --git a/src/storage_conf.h b/src/storage_conf.h index 7eb04ad454..3535ba3c47 100644 --- a/src/storage_conf.h +++ b/src/storage_conf.h @@ -262,7 +262,7 @@ static inline int virStoragePoolObjIsActive(virStoragePoolObjPtr pool) { } #define virStorageReportError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_STORAGE, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_STORAGE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) int virStoragePoolLoadAllConfigs(virConnectPtr conn, diff --git a/src/storage_driver.c b/src/storage_driver.c index bced52e385..ec6f0256c8 100644 --- a/src/storage_driver.c +++ b/src/storage_driver.c @@ -32,7 +32,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "driver.h" #include "util.h" #include "storage_driver.h" diff --git a/src/test.c b/src/test.c index 187e97c911..d17ffc12dd 100644 --- a/src/test.c +++ b/src/test.c @@ -31,6 +31,8 @@ #include #include + +#include "virterror_internal.h" #include "test.h" #include "buf.h" #include "util.h" @@ -161,7 +163,7 @@ static const virNodeInfo defaultNodeInfo = { } \ #define testError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_TEST, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_TEST, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) static virCapsPtr diff --git a/src/util.c b/src/util.c index 5bcd87ae59..a750100c21 100644 --- a/src/util.c +++ b/src/util.c @@ -47,7 +47,7 @@ #include #endif -#include "internal.h" +#include "virterror_internal.h" #include "event.h" #include "buf.h" #include "util.h" @@ -67,7 +67,7 @@ #ifndef PROXY #define ReportError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) int virFileStripSuffix(char *str, diff --git a/src/virterror.c b/src/virterror.c index be809a0ea9..1f3f337ae8 100644 --- a/src/virterror.c +++ b/src/virterror.c @@ -15,18 +15,17 @@ #include #include -#include "internal.h" -#include "libvirt/virterror.h" +#include "virterror_internal.h" -virError __lastErr = /* the last error */ +virError virLastErr = /* the last error */ { .code = 0, .domain = 0, .message = NULL, .level = VIR_ERR_NONE, .conn = NULL, .dom = NULL, .str1 = NULL, .str2 = NULL, .str3 = NULL, .int1 = 0, .int2 = 0, .net = NULL }; -static virErrorFunc virErrorHandler = NULL; /* global error handler */ -static void *virUserData = NULL; /* associated data */ +virErrorFunc virErrorHandler = NULL; /* global error handler */ +void *virUserData = NULL; /* associated data */ /* - * Macro used to format the message as a string in __virRaiseError + * Macro used to format the message as a string in virRaiseError * and borrowed from libxml2. */ #define VIR_GET_VAR_STR(msg, str) { \ @@ -74,9 +73,9 @@ static void *virUserData = NULL; /* associated data */ virErrorPtr virGetLastError(void) { - if (__lastErr.code == VIR_ERR_OK) + if (virLastErr.code == VIR_ERR_OK) return (NULL); - return (&__lastErr); + return (&virLastErr); } /* @@ -94,10 +93,10 @@ virCopyLastError(virErrorPtr to) { if (to == NULL) return (-1); - if (__lastErr.code == VIR_ERR_OK) + if (virLastErr.code == VIR_ERR_OK) return (0); - memcpy(to, &__lastErr, sizeof(virError)); - return (__lastErr.code); + memcpy(to, &virLastErr, sizeof(virError)); + return (virLastErr.code); } /** @@ -126,7 +125,7 @@ virResetError(virErrorPtr err) void virResetLastError(void) { - virResetError(&__lastErr); + virResetError(&virLastErr); } /** @@ -331,7 +330,7 @@ virDefaultErrorFunc(virErrorPtr err) } /** - * __virRaiseError: + * virRaiseError: * @conn: the connection to the hypervisor if available * @dom: the domain if available * @net: the network if available @@ -350,12 +349,12 @@ virDefaultErrorFunc(virErrorPtr err) * immediately if a callback is found and store it for later handling. */ void -__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, ...) +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, ...) { - virErrorPtr to = &__lastErr; + virErrorPtr to = &virLastErr; void *userData = virUserData; virErrorFunc handler = virErrorHandler; char *str; @@ -414,7 +413,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net, } /** - * __virErrorMsg: + * virErrorMsg: * @error: the virErrorNumber * @info: usually the first parameter string * @@ -424,7 +423,7 @@ __virRaiseError(virConnectPtr conn, virDomainPtr dom, virNetworkPtr net, * Returns the constant string associated to @error */ const char * -__virErrorMsg(virErrorNumber error, const char *info) +virErrorMsg(virErrorNumber error, const char *info) { const char *errmsg = NULL; @@ -724,7 +723,7 @@ __virErrorMsg(virErrorNumber error, const char *info) } /** - * __virReportErrorHelper + * virReportErrorHelper * * @conn: the connection to the hypervisor if available * @dom: the domain if available @@ -740,11 +739,11 @@ __virErrorMsg(virErrorNumber error, const char *info) * Helper function to do most of the grunt work for individual driver * ReportError */ -void __virReportErrorHelper(virConnectPtr conn, int domcode, int errcode, - const char *filename ATTRIBUTE_UNUSED, - const char *funcname ATTRIBUTE_UNUSED, - long long linenr ATTRIBUTE_UNUSED, - const char *fmt, ...) +void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode, + const char *filename ATTRIBUTE_UNUSED, + const char *funcname ATTRIBUTE_UNUSED, + long long linenr ATTRIBUTE_UNUSED, + const char *fmt, ...) { va_list args; char errorMessage[1024]; @@ -758,8 +757,8 @@ void __virReportErrorHelper(virConnectPtr conn, int domcode, int errcode, errorMessage[0] = '\0'; } - virerr = __virErrorMsg(errcode, (errorMessage[0] ? errorMessage : NULL)); - __virRaiseError(conn, NULL, NULL, domcode, errcode, VIR_ERR_ERROR, - virerr, errorMessage, NULL, -1, -1, virerr, errorMessage); + virerr = virErrorMsg(errcode, (errorMessage[0] ? errorMessage : NULL)); + virRaiseError(conn, NULL, NULL, domcode, errcode, VIR_ERR_ERROR, + virerr, errorMessage, NULL, -1, -1, virerr, errorMessage); } diff --git a/src/virterror_internal.h b/src/virterror_internal.h new file mode 100644 index 0000000000..a386f5ef67 --- /dev/null +++ b/src/virterror_internal.h @@ -0,0 +1,56 @@ +/* + * virterror.h: internal error handling + * + * Copyright (C) 2006-2008 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __VIRT_ERROR_H_ +#define __VIRT_ERROR_H_ + +#include "internal.h" + +extern virError virLastErr; +extern virErrorFunc virErrorHandler; +extern void *virUserData; + +/************************************************************************ + * * + * API for error handling * + * * + ************************************************************************/ +void 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, ...) + ATTRIBUTE_FORMAT(printf, 12, 13); +const char *virErrorMsg(virErrorNumber error, const char *info); +void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode, + const char *filename ATTRIBUTE_UNUSED, + const char *funcname ATTRIBUTE_UNUSED, + long long linenr ATTRIBUTE_UNUSED, + const char *fmt, ...) + ATTRIBUTE_FORMAT(printf, 7, 8); + + +#endif diff --git a/src/xen_internal.c b/src/xen_internal.c index 72c61eb98d..b68db5f560 100644 --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -26,11 +26,6 @@ #include #include -#include "xs_internal.h" -#include "stats_linux.h" -#include "xend_internal.h" -#include "util.h" - /* required for dom0_getdomaininfo_t */ #include #include @@ -45,6 +40,14 @@ /* required for shutdown flags */ #include +#include "virterror_internal.h" +#include "driver.h" +#include "util.h" +#include "xen_unified.h" +#include "xen_internal.h" +#include "xs_internal.h" +#include "stats_linux.h" +#include "xend_internal.h" #include "buf.h" #include "capabilities.h" #include "memory.h" @@ -653,10 +656,6 @@ struct xen_op_v2_dom { }; typedef struct xen_op_v2_dom xen_op_v2_dom; -#include "internal.h" -#include "driver.h" -#include "xen_unified.h" -#include "xen_internal.h" #ifdef __linux__ #define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd" @@ -720,7 +719,7 @@ struct xenUnifiedDriver xenHypervisorDriver = { #define virXenError(conn, code, fmt...) \ if (in_init == 0) \ - __virReportErrorHelper(conn, VIR_FROM_XEN, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_XEN, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) #ifndef PROXY @@ -747,15 +746,15 @@ virXenErrorFunc(virConnectPtr conn, return; - errmsg = __virErrorMsg(error, info); + errmsg =virErrorMsg(error, info); if (func != NULL) { snprintf(fullinfo, 999, "%s: %s", func, info); fullinfo[999] = 0; - __virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, + virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo, value); } else { - __virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, + virRaiseError(conn, NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, errmsg, info, NULL, value, 0, errmsg, info, value); } diff --git a/src/xen_unified.c b/src/xen_unified.c index 86fd08cfae..d73778836f 100644 --- a/src/xen_unified.c +++ b/src/xen_unified.c @@ -27,7 +27,7 @@ #include #include -#include "internal.h" +#include "virterror_internal.h" #include "xen_unified.h" @@ -59,7 +59,7 @@ static struct xenUnifiedDriver *drivers[XEN_UNIFIED_NR_DRIVERS] = { }; #define xenUnifiedError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_XEN, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_XEN, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) /* diff --git a/src/xend_internal.c b/src/xend_internal.c index bad9de36db..1329b7093f 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -32,6 +32,7 @@ #include #include +#include "virterror_internal.h" #include "xend_internal.h" #include "driver.h" #include "util.h" @@ -105,7 +106,7 @@ virDomainXMLDevID(virDomainPtr domain, #endif #define virXendError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_XEND, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_XEND, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) #define virXendErrorInt(conn, code, ival) \ diff --git a/src/xm_internal.c b/src/xm_internal.c index 9562c9a23d..ab99ea3d96 100644 --- a/src/xm_internal.c +++ b/src/xm_internal.c @@ -35,6 +35,7 @@ #include #include +#include "virterror_internal.h" #include "xm_internal.h" #include "xen_unified.h" #include "xend_internal.h" @@ -123,7 +124,7 @@ struct xenUnifiedDriver xenXMDriver = { }; #define xenXMError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_XENXM, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_XENXM, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) int diff --git a/src/xml.c b/src/xml.c index 6f2fa8b38d..a7ebe7cf8c 100644 --- a/src/xml.c +++ b/src/xml.c @@ -16,14 +16,15 @@ #include #include #include /* for isnan() */ -#include "internal.h" + +#include "virterror_internal.h" #include "xml.h" #include "buf.h" #include "util.h" #include "memory.h" #define virXMLError(conn, code, fmt...) \ - __virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \ + virReportErrorHelper(conn, VIR_FROM_XML, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) diff --git a/src/xmlrpc.c b/src/xmlrpc.c index cbca38931a..c90d69485e 100644 --- a/src/xmlrpc.c +++ b/src/xmlrpc.c @@ -11,7 +11,7 @@ #include #include "xmlrpc.h" -#include "internal.h" +#include "virterror_internal.h" #include "memory.h" #include @@ -41,8 +41,8 @@ static void xmlRpcError(virErrorNumber error, const char *info, int value) if (error == VIR_ERR_OK) return; - errmsg = __virErrorMsg(error, info); - __virRaiseError(NULL, NULL, NULL, VIR_FROM_RPC, error, VIR_ERR_ERROR, + errmsg = virErrorMsg(error, info); + 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 d9e812334b..fd8b67d853 100644 --- a/src/xs_internal.c +++ b/src/xs_internal.c @@ -26,7 +26,7 @@ #include -#include "internal.h" +#include "virterror_internal.h" #include "driver.h" #include "xen_unified.h" #include "xs_internal.h" @@ -88,7 +88,7 @@ struct xenUnifiedDriver xenStoreDriver = { #endif /* ! PROXY */ #define virXenStoreError(conn, code, fmt...) \ - __virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__, \ + virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__, \ __FUNCTION__, __LINE__, fmt) /************************************************************************