Move internal error APIs into virterror_internal.h & drop leading __ prefix

This commit is contained in:
Daniel P. Berrange 2008-11-04 22:30:33 +00:00
parent 78439117bc
commit d714b2afae
45 changed files with 255 additions and 189 deletions

View File

@ -1,3 +1,27 @@
Tue Nov 4 22:20:31 UTC 2008 Daniel P. Berrange <berrange@redhat.com>
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 <berrange@redhat.com>
Support passing UUID and ID to qemu/xenner

View File

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

View File

@ -18,7 +18,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#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);

View File

@ -29,8 +29,7 @@
#include <fcntl.h>
#include <dirent.h>
#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,

View File

@ -23,7 +23,8 @@
#include <string.h>
#include <stdlib.h>
#include <libxml/threads.h>
#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);

View File

@ -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);
/************************************************************************
* *

View File

@ -31,7 +31,7 @@
#include <winsock2.h>
#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"));

View File

@ -27,6 +27,7 @@
#include <sys/utsname.h>
#include "virterror_internal.h"
#include "lxc_conf.h"
/* Functions */

View File

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

View File

@ -41,6 +41,7 @@
/* For MS_MOVE */
#include <linux/fs.h>
#include "virterror_internal.h"
#include "lxc_container.h"
#include "util.h"
#include "memory.h"

View File

@ -34,7 +34,7 @@
#include <signal.h>
#include <getopt.h>
#include "internal.h"
#include "virterror_internal.h"
#include "util.h"
#include "lxc_conf.h"

View File

@ -35,7 +35,7 @@
#include <unistd.h>
#include <wait.h>
#include "internal.h"
#include "virterror_internal.h"
#include "lxc_conf.h"
#include "lxc_container.h"
#include "lxc_driver.h"

View File

@ -33,8 +33,7 @@
#include <string.h>
#include <dirent.h>
#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,

View File

@ -44,6 +44,7 @@
#include <sys/wait.h>
#include <sys/ioctl.h>
#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)

View File

@ -33,7 +33,7 @@
#include <sys/utsname.h>
#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;

View File

@ -43,6 +43,7 @@
#include <sys/utsname.h>
#include <sys/wait.h>
#include "virterror_internal.h"
#include "openvz_conf.h"
#include "uuid.h"
#include "buf.h"

View File

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

View File

@ -47,7 +47,7 @@
#include <stdio.h>
#include <sys/wait.h>
#include "internal.h"
#include "virterror_internal.h"
#include "openvz_driver.h"
#include "event.h"
#include "buf.h"

View File

@ -21,7 +21,8 @@
#include <sys/un.h>
#include <sys/wait.h>
#include <string.h>
#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)
/************************************************************************

View File

@ -40,6 +40,7 @@
#include <numa.h>
#endif
#include "virterror_internal.h"
#include "qemu_conf.h"
#include "uuid.h"
#include "buf.h"

View File

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

View File

@ -52,6 +52,7 @@
#include <sched.h>
#endif
#include "virterror_internal.h"
#include "qemu_driver.h"
#include "qemu_conf.h"
#include "c-ctype.h"

View File

@ -26,12 +26,13 @@
#include <stdlib.h>
#include <stdarg.h>
#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 *

View File

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

View File

@ -18,13 +18,13 @@
#include "c-ctype.h"
#include <errno.h>
#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)
/**

View File

@ -24,7 +24,7 @@
#include <xs.h>
#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);

View File

@ -41,7 +41,7 @@
#include <selinux/selinux.h>
#endif
#include "internal.h"
#include "virterror_internal.h"
#include "util.h"
#include "memory.h"

View File

@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include "internal.h"
#include "virterror_internal.h"
#include "storage_backend_disk.h"
#include "util.h"
#include "memory.h"

View File

@ -40,7 +40,7 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
#include "internal.h"
#include "virterror_internal.h"
#include "storage_backend_fs.h"
#include "storage_conf.h"
#include "util.h"

View File

@ -34,7 +34,7 @@
#include <unistd.h>
#include <dirent.h>
#include "internal.h"
#include "virterror_internal.h"
#include "storage_backend_iscsi.h"
#include "util.h"
#include "memory.h"

View File

@ -31,7 +31,7 @@
#include <unistd.h>
#include <fcntl.h>
#include "internal.h"
#include "virterror_internal.h"
#include "storage_backend_logical.h"
#include "storage_conf.h"
#include "util.h"

View File

@ -38,7 +38,7 @@
#include <fcntl.h>
#include <string.h>
#include "internal.h"
#include "virterror_internal.h"
#include "storage_conf.h"
#include "storage_backend.h"
#include "xml.h"

View File

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

View File

@ -32,7 +32,7 @@
#include <errno.h>
#include <string.h>
#include "internal.h"
#include "virterror_internal.h"
#include "driver.h"
#include "util.h"
#include "storage_driver.h"

View File

@ -31,6 +31,8 @@
#include <sys/stat.h>
#include <libxml/xmlsave.h>
#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

View File

@ -47,7 +47,7 @@
#include <paths.h>
#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,

View File

@ -15,18 +15,17 @@
#include <string.h>
#include <stdarg.h>
#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);
}

56
src/virterror_internal.h Normal file
View File

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

View File

@ -26,11 +26,6 @@
#include <errno.h>
#include <sys/utsname.h>
#include "xs_internal.h"
#include "stats_linux.h"
#include "xend_internal.h"
#include "util.h"
/* required for dom0_getdomaininfo_t */
#include <xen/dom0_ops.h>
#include <xen/version.h>
@ -45,6 +40,14 @@
/* required for shutdown flags */
#include <xen/sched.h>
#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);
}

View File

@ -27,7 +27,7 @@
#include <xen/dom0_ops.h>
#include <libxml/uri.h>
#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)
/*

View File

@ -32,6 +32,7 @@
#include <libxml/uri.h>
#include <errno.h>
#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) \

View File

@ -35,6 +35,7 @@
#include <stdint.h>
#include <xen/dom0_ops.h>
#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

View File

@ -16,14 +16,15 @@
#include <stdarg.h>
#include <limits.h>
#include <math.h> /* 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)

View File

@ -11,7 +11,7 @@
#include <config.h>
#include "xmlrpc.h"
#include "internal.h"
#include "virterror_internal.h"
#include "memory.h"
#include <libxml/nanohttp.h>
@ -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);
}

View File

@ -26,7 +26,7 @@
#include <xs.h>
#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)
/************************************************************************