It was used for error reporting only.
---
po/POTFILES.in | 1 +
src/lxc/lxc_driver.c | 2 +-
src/qemu/qemu_driver.c | 2 +-
src/util/stats_linux.c | 44 +++++++++-----------------------------------
src/util/stats_linux.h | 4 ++--
src/xen/xen_hypervisor.c | 2 +-
6 files changed, 15 insertions(+), 40 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 18f5243..3e6440e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -61,6 +61,7 @@ src/util/json.c
src/util/logging.c
src/util/pci.c
src/util/processinfo.c
+src/util/stats_linux.c
src/util/storage_file.c
src/util/util.c
src/util/uuid.c
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 80a4935..42e411f 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2048,7 +2048,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
}
if (ret == 0)
- ret = linuxDomainInterfaceStats(dom->conn, path, stats);
+ ret = linuxDomainInterfaceStats(path, stats);
else
lxcError(dom->conn, dom, VIR_ERR_INVALID_ARG,
_("Invalid path, '%s' is not a known interface"),
path);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8d121a7..3a80603 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6821,7 +6821,7 @@ qemudDomainInterfaceStats (virDomainPtr dom,
}
if (ret == 0)
- ret = linuxDomainInterfaceStats (dom->conn, path, stats);
+ ret = linuxDomainInterfaceStats(path, stats);
else
qemudReportError (dom->conn, dom, NULL, VIR_ERR_INVALID_ARG,
_("invalid path, '%s' is not a known
interface"), path);
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index 7d8a5f9..25f8d08 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -28,35 +28,9 @@
#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
-/**
- * statsErrorFunc:
- * @conn: the connection
- * @error: the error number
- * @func: the function failing
- * @info: extra information string
- * @value: extra information number
- *
- * Handle a stats error.
- */
-static void
-statsErrorFunc (virConnectPtr conn,
- virErrorNumber error, const char *func, const char *info,
- int value)
-{
- char fullinfo[1000];
- const char *errmsg;
-
- 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,
- VIR_ERR_ERROR,
- errmsg, info, NULL, value, 0, errmsg, info,
- value);
-}
+#define virStatsError(code, fmt...) \
+ virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, fmt)
/*-------------------- interface stats --------------------*/
@@ -66,8 +40,8 @@ statsErrorFunc (virConnectPtr conn,
*/
int
-linuxDomainInterfaceStats (virConnectPtr conn, const char *path,
- struct _virDomainInterfaceStats *stats)
+linuxDomainInterfaceStats(const char *path,
+ struct _virDomainInterfaceStats *stats)
{
int path_len;
FILE *fp;
@@ -75,8 +49,8 @@ linuxDomainInterfaceStats (virConnectPtr conn, const char *path,
fp = fopen ("/proc/net/dev", "r");
if (!fp) {
- statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "/proc/net/dev", errno);
+ virReportSystemError(errno, "%s",
+ _("Could not open /proc/net/dev"));
return -1;
}
@@ -131,8 +105,8 @@ linuxDomainInterfaceStats (virConnectPtr conn, const char *path,
}
fclose (fp);
- statsErrorFunc (conn, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
- "/proc/net/dev: Interface not found", 0);
+ virStatsError(VIR_ERR_INTERNAL_ERROR,
+ "/proc/net/dev: Interface not found");
return -1;
}
diff --git a/src/util/stats_linux.h b/src/util/stats_linux.h
index 033a50b..3b00620 100644
--- a/src/util/stats_linux.h
+++ b/src/util/stats_linux.h
@@ -15,8 +15,8 @@
#include "internal.h"
-extern int linuxDomainInterfaceStats (virConnectPtr conn, const char *path,
- struct _virDomainInterfaceStats *stats);
+extern int linuxDomainInterfaceStats(const char *path,
+ struct _virDomainInterfaceStats *stats);
#endif /* __linux__ */
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index bdb0c3c..aabe546 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -1477,7 +1477,7 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
return -1;
}
- return linuxDomainInterfaceStats (dom->conn, path, stats);
+ return linuxDomainInterfaceStats(path, stats);
#else
virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"/proc/net/dev: Interface not found", 0);
--
1.6.3.3