[libvirt] PATCH: 2/11: Move internal error APIs into virterror_internal.h

Daniel P. Berrange berrange at redhat.com
Thu Oct 30 13:36:10 UTC 2008


After Daniel's feedback that adding src/virterror.h is confusing, I've
re-done the patch to instead add virterror_internal.h, making it clear
that these function prototypes are related to virterror.c, but internal
use only. That patch is basically moving them out of src/internal.h
In addition it removes the leading __ prefix from virRaiseError since
this symbol was never exported fromthe library.

The diff is mis-leading - most of this is just the s/__// change.

 b/src/virterror_internal.h    |   56 ++++++++++++++++++++++++++++++++
 src/Makefile.am               |    4 +-
 src/conf.c                    |    8 ++--
 src/domain_conf.c             |    5 +-
 src/hash.c                    |   17 +++++----
 src/internal.h                |   24 --------------
 src/libvirt.c                 |   44 ++++++++++++-------------
 src/lxc_conf.c                |    1 
 src/lxc_conf.h                |    2 -
 src/lxc_container.c           |    1 
 src/lxc_controller.c          |    2 -
 src/lxc_driver.c              |    2 -
 src/network_conf.c            |    5 +-
 src/network_driver.c          |    3 +
 src/nodeinfo.c                |   16 ++++-----
 src/openvz_conf.c             |    1 
 src/openvz_conf.h             |    2 -
 src/openvz_driver.c           |    2 -
 src/proxy_internal.c          |    5 +-
 src/qemu_conf.c               |    1 
 src/qemu_conf.h               |    2 -
 src/qemu_driver.c             |    1 
 src/qparams.c                 |    3 +
 src/remote_internal.c         |   72 +++++++++++++++++++++---------------------
 src/sexpr.c                   |    4 +-
 src/stats_linux.c             |    6 +--
 src/storage_backend.c         |    2 -
 src/storage_backend_disk.c    |    2 -
 src/storage_backend_fs.c      |    2 -
 src/storage_backend_iscsi.c   |    2 -
 src/storage_backend_logical.c |    2 -
 src/storage_conf.c            |    2 -
 src/storage_conf.h            |    2 -
 src/storage_driver.c          |    2 -
 src/test.c                    |    4 +-
 src/util.c                    |    4 +-
 src/virterror.c               |   57 ++++++++++++++++-----------------
 src/xen_internal.c            |   25 +++++++-------
 src/xen_unified.c             |    4 +-
 src/xend_internal.c           |    3 +
 src/xm_internal.c             |    3 +
 src/xml.c                     |    5 +-
 src/xmlrpc.c                  |    6 +--
 src/xs_internal.c             |    4 +-
 44 files changed, 231 insertions(+), 189 deletions(-)

Daniel

diff -r 786626684900 src/Makefile.am
--- a/src/Makefile.am	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/Makefile.am	Wed Oct 29 20:09:48 2008 +0000
@@ -50,7 +50,7 @@
 		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 @@
 		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 -r 786626684900 src/conf.c
--- a/src/conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 
     /* 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 -r 786626684900 src/domain_conf.c
--- a/src/domain_conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/domain_conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
               "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 -r 786626684900 src/hash.c
--- a/src/hash.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/hash.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
         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 @@
 
     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 @@
 
     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 -r 786626684900 src/internal.h
--- a/src/internal.h	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/internal.h	Wed Oct 29 20:09:48 2008 +0000
@@ -295,30 +295,6 @@
 };
 
 
-/************************************************************************
- *									*
- *		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 -r 786626684900 src/libvirt.c
--- a/src/libvirt.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/libvirt.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
 
     /* 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 -r 786626684900 src/lxc_conf.c
--- a/src/lxc_conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/lxc_conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -27,6 +27,7 @@
 
 #include <sys/utsname.h>
 
+#include "virterror_internal.h"
 #include "lxc_conf.h"
 
 /* Functions */
diff -r 786626684900 src/lxc_conf.h
--- a/src/lxc_conf.h	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/lxc_conf.h	Wed Oct 29 20:09:48 2008 +0000
@@ -50,7 +50,7 @@
 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 -r 786626684900 src/lxc_container.c
--- a/src/lxc_container.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/lxc_container.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/lxc_controller.c
--- a/src/lxc_controller.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/lxc_controller.c	Wed Oct 29 20:09:48 2008 +0000
@@ -34,7 +34,7 @@
 #include <signal.h>
 #include <getopt.h>
 
-#include "internal.h"
+#include "virterror_internal.h"
 #include "util.h"
 
 #include "lxc_conf.h"
diff -r 786626684900 src/lxc_driver.c
--- a/src/lxc_driver.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/lxc_driver.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/network_conf.c
--- a/src/network_conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/network_conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
               "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 -r 786626684900 src/network_driver.c
--- a/src/network_driver.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/network_driver.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 #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 -r 786626684900 src/nodeinfo.c
--- a/src/nodeinfo.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/nodeinfo.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
             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 @@
             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 @@
             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 @@
     }
 
     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 @@
     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 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 @@
     }
 #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 -r 786626684900 src/openvz_conf.c
--- a/src/openvz_conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/openvz_conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/openvz_conf.h
--- a/src/openvz_conf.h	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/openvz_conf.h	Wed Oct 29 20:09:48 2008 +0000
@@ -42,7 +42,7 @@
                                 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 -r 786626684900 src/openvz_driver.c
--- a/src/openvz_driver.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/openvz_driver.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/proxy_internal.c
--- a/src/proxy_internal.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/proxy_internal.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
  ************************************************************************/
 
 #define virProxyError(conn, code, fmt...)                                    \
-        __virReportErrorHelper(conn, VIR_FROM_PROXY, code, __FILE__,         \
+        virReportErrorHelper(conn, VIR_FROM_PROXY, code, __FILE__,         \
                                __FUNCTION__, __LINE__, fmt)
 
 /************************************************************************
diff -r 786626684900 src/qemu_conf.c
--- a/src/qemu_conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/qemu_conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -40,6 +40,7 @@
 #include <numa.h>
 #endif
 
+#include "virterror_internal.h"
 #include "qemu_conf.h"
 #include "uuid.h"
 #include "buf.h"
diff -r 786626684900 src/qemu_conf.h
--- a/src/qemu_conf.h	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/qemu_conf.h	Wed Oct 29 20:09:48 2008 +0000
@@ -70,7 +70,7 @@
 
 
 #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 -r 786626684900 src/qemu_driver.c
--- a/src/qemu_driver.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/qemu_driver.c	Wed Oct 29 20:09:48 2008 +0000
@@ -52,6 +52,7 @@
 #include <sched.h>
 #endif
 
+#include "virterror_internal.h"
 #include "qemu_driver.h"
 #include "qemu_conf.h"
 #include "c-ctype.h"
diff -r 786626684900 src/qparams.c
--- a/src/qparams.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/qparams.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 *
diff -r 786626684900 src/remote_internal.c
--- a/src/remote_internal.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/remote_internal.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
         } 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 @@
                 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 @@
         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 @@
                            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 @@
     }
 
     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 @@
     /* 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 @@
     /* 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 @@
     /* 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 @@
                           &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 @@
 
         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 @@
         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 @@
 
     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 @@
     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 @@
                             &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 @@
         }
         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 @@
         } 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 @@
     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 @@
                                &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 @@
                 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 @@
             } 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 @@
     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 @@
         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 @@
         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 @@
 
     /* 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 @@
         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 @@
         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 @@
         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 @@
         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 @@
         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 @@
 {
     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 @@
         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 @@
     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 @@
 /* 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 -r 786626684900 src/sexpr.c
--- a/src/sexpr.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/sexpr.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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)
 
 /**
diff -r 786626684900 src/stats_linux.c
--- a/src/stats_linux.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/stats_linux.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
     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 -r 786626684900 src/storage_backend.c
--- a/src/storage_backend.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_backend.c	Wed Oct 29 20:09:48 2008 +0000
@@ -41,7 +41,7 @@
 #include <selinux/selinux.h>
 #endif
 
-#include "internal.h"
+#include "virterror_internal.h"
 #include "util.h"
 #include "memory.h"
 
diff -r 786626684900 src/storage_backend_disk.c
--- a/src/storage_backend_disk.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_backend_disk.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/storage_backend_fs.c
--- a/src/storage_backend_fs.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_backend_fs.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/storage_backend_iscsi.c
--- a/src/storage_backend_iscsi.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_backend_iscsi.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/storage_backend_logical.c
--- a/src/storage_backend_logical.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_backend_logical.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/storage_conf.c
--- a/src/storage_conf.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_conf.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/storage_conf.h
--- a/src/storage_conf.h	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_conf.h	Wed Oct 29 20:09:48 2008 +0000
@@ -262,7 +262,7 @@
 }
 
 #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 -r 786626684900 src/storage_driver.c
--- a/src/storage_driver.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/storage_driver.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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"
diff -r 786626684900 src/test.c
--- a/src/test.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/test.c	Wed Oct 29 20:09:48 2008 +0000
@@ -30,6 +30,8 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
+
+#include "virterror_internal.h"
 #include "test.h"
 #include "buf.h"
 #include "util.h"
@@ -113,7 +115,7 @@
 
 
 #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 -r 786626684900 src/util.c
--- a/src/util.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/util.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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,
diff -r 786626684900 src/virterror.c
--- a/src/virterror.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/virterror.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 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 @@
 {
     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 @@
 void
 virResetLastError(void)
 {
-    virResetError(&__lastErr);
+    virResetError(&virLastErr);
 }
 
 /**
@@ -331,7 +330,7 @@
 }
 
 /**
- * __virRaiseError:
+ * virRaiseError:
  * @conn: the connection to the hypervisor if available
  * @dom: the domain if available
  * @net: the network if available
@@ -350,12 +349,12 @@
  * 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 @@
 }
 
 /**
- * __virErrorMsg:
+ * virErrorMsg:
  * @error: the virErrorNumber
  * @info: usually the first parameter string
  *
@@ -424,7 +423,7 @@
  * 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 @@
 }
 
 /**
- * __virReportErrorHelper
+ * virReportErrorHelper
  *
  * @conn: the connection to the hypervisor if available
  * @dom: the domain if available
@@ -740,11 +739,11 @@
  * 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 @@
         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 -r 786626684900 src/virterror_internal.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/virterror_internal.h	Wed Oct 29 20:09:48 2008 +0000
@@ -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 -r 786626684900 src/xen_internal.c
--- a/src/xen_internal.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xen_internal.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 };
 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 @@
 
 #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 @@
         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 -r 786626684900 src/xen_unified.c
--- a/src/xen_unified.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xen_unified.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 };
 
 #define xenUnifiedError(conn, code, fmt...)                                  \
-        __virReportErrorHelper(conn, VIR_FROM_XEN, code, __FILE__,           \
+        virReportErrorHelper(conn, VIR_FROM_XEN, code, __FILE__,           \
                                __FUNCTION__, __LINE__, fmt)
 
 /*
diff -r 786626684900 src/xend_internal.c
--- a/src/xend_internal.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xend_internal.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 #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 -r 786626684900 src/xm_internal.c
--- a/src/xm_internal.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xm_internal.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 };
 
 #define xenXMError(conn, code, fmt...)                                       \
-        __virReportErrorHelper(conn, VIR_FROM_XENXM, code, __FILE__,         \
+        virReportErrorHelper(conn, VIR_FROM_XENXM, code, __FILE__,         \
                                __FUNCTION__, __LINE__, fmt)
 
 int
diff -r 786626684900 src/xml.c
--- a/src/xml.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xml.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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)
 
 
diff -r 786626684900 src/xmlrpc.c
--- a/src/xmlrpc.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xmlrpc.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
     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 -r 786626684900 src/xs_internal.c
--- a/src/xs_internal.c	Wed Oct 29 15:23:00 2008 +0000
+++ b/src/xs_internal.c	Wed Oct 29 20:09:48 2008 +0000
@@ -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 @@
 #endif /* ! PROXY */
 
 #define virXenStoreError(conn, code, fmt...)                                 \
-        __virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__,      \
+        virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__,      \
                                __FUNCTION__, __LINE__, fmt)
 
 /************************************************************************

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list