]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Remove conn parameter from Linux stats functions
authorMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 4 Feb 2010 23:02:10 +0000 (00:02 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 9 Feb 2010 00:04:55 +0000 (01:04 +0100)
It was used for error reporting only.

po/POTFILES.in
src/lxc/lxc_driver.c
src/qemu/qemu_driver.c
src/util/stats_linux.c
src/util/stats_linux.h
src/xen/xen_hypervisor.c

index 18f52432724c78451bf142b92d6cab14c8d77984..3e6440e61e80a49ee3b863e4666058dde7685c12 100644 (file)
@@ -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
index 1e728488bc15dca9c3a701b782754c6a867d0d8f..335a6dbd9fa57d2b23d21f14b3f1a5081dda83a1 100644 (file)
@@ -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);
index e1ee25a18d080c9b4108c0aa56fe6564a14edf76..7fba4376316ed8808cd9b6abee5ab409f1be1212 100644 (file)
@@ -6845,7 +6845,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);
index 7d8a5f9e0ade7e7fa65e48f6de87196e30151443..25f8d085c077eb0c5fc817dfeb9c2864814bf072 100644 (file)
 
 #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;
 }
 
index 033a50b64399c55f23519169d00639423b2ae894..3b006204ed5e0c72fa49eb8cf62e3f2288ed0106 100644 (file)
@@ -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__ */
 
index 8e4f64832f40f3a91952e0263eae3e19678b9e54..ab8fbc38b3d2b67e82d6501f65d0c59c3127a0d7 100644 (file)
@@ -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);