Index: trunk/src/VBox/Main/src-server/Performance.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/Performance.cpp	(revision 44029)
+++ trunk/src/VBox/Main/src-server/Performance.cpp	(revision 44031)
@@ -705,6 +705,13 @@
 void HostNetworkLoadRaw::collect()
 {
-    uint64_t rx, tx;
-
+    uint64_t rx = mRxPrev;
+    uint64_t tx = mTxPrev;
+
+    if (RT_UNLIKELY(mSpeed * getPeriod() == 0))
+    {
+        LogFlowThisFunc(("Check cable for %s! speed=%llu period=%d.\n", mShortName.c_str(), mSpeed, getPeriod()));
+        /* We do not collect host network metrics for unplugged interfaces! */
+        return;
+    }
     mRc = mHAL->getRawHostNetworkLoad(mShortName.c_str(), &rx, &tx);
     if (RT_SUCCESS(mRc))
@@ -713,17 +720,6 @@
         uint64_t txDiff = tx - mTxPrev;
 
-        if (RT_UNLIKELY(mSpeed * getPeriod() == 0))
-        {
-            LogFlowThisFunc(("Check cable for %s! speed=%llu period=%d.\n", mShortName.c_str(), mSpeed, getPeriod()));
-            /* We do not collect host network metrics for unplugged interfaces!
-            mRx->put(0);
-            mTx->put(0);
-            */
-        }
-        else
-        {
-            mRx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * rxDiff / (mSpeed * getPeriod())));
-            mTx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * txDiff / (mSpeed * getPeriod())));
-        }
+        mRx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * rxDiff / (mSpeed * getPeriod())));
+        mTx->put((ULONG)(PM_NETWORK_LOAD_MULTIPLIER * txDiff / (mSpeed * getPeriod())));
 
         mRxPrev = rx;
Index: trunk/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp	(revision 44029)
+++ trunk/src/VBox/Main/src-server/solaris/PerformanceSolaris.cpp	(revision 44031)
@@ -36,5 +36,5 @@
 #include <iprt/param.h>
 #include <iprt/path.h>
-#include <VBox/log.h>
+#include "Logging.h"
 #include "Performance.h"
 
@@ -81,4 +81,6 @@
     RTCString physToInstName(const char *pcszPhysName);
     RTCString pathToInstName(const char *pcszDevPathName);
+    uint64_t wrapCorrection(uint32_t cur, uint64_t prev, const char *name);
+    uint64_t wrapDetection(uint64_t cur, uint64_t prev, const char *name);
 
     kstat_ctl_t *mKC;
@@ -356,6 +358,37 @@
 }
 
+uint64_t CollectorSolaris::wrapCorrection(uint32_t cur, uint64_t prev, const char *name)
+{
+    uint64_t corrected = (prev & 0xffffffff00000000) + cur;
+    if (cur < (prev & 0xffffffff))
+    {
+        /* wrap has occurred */
+        corrected += 0x100000000;
+        LogFlowThisFunc(("Corrected wrap on %s (%u < %u), returned %llu.\n",
+                         name, cur, (uint32_t)prev, corrected));
+    }
+    return corrected;
+}
+
+uint64_t CollectorSolaris::wrapDetection(uint64_t cur, uint64_t prev, const char *name)
+{
+    static bool fNotSeen = true;
+
+    if (fNotSeen && cur < prev)
+    {
+        fNotSeen = false;
+        LogRel(("Detected wrap on %s (%llu < %llu).\n", name, cur, prev));
+    }
+    return cur;
+}
+
+/*
+ * WARNING! This function expects the previous values of rx and tx counter to
+ * be passed in as well as returnes new values in the same parameters. This is
+ * needed to provide a workaround for 32-bit counter wrapping.
+ */
 int CollectorSolaris::getRawHostNetworkLoad(const char *name, uint64_t *rx, uint64_t *tx)
 {
+    static bool g_fNotReported = true;
     AssertReturn(strlen(name) < KSTAT_STRLEN, VERR_INVALID_PARAMETER);
     LogFlowThisFunc(("m=%s i=%d n=%s\n", "link", -1, name));
@@ -384,16 +417,36 @@
     }
     kstat_named_t *kn;
-    if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"rbytes")) == 0)
-    {
-        LogRel(("kstat_data_lookup(rbytes) -> %d, name=%s\n", errno, name));
-        return VERR_INTERNAL_ERROR;
-    }
-    *rx = kn->value.ul;
-    if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"obytes")) == 0)
-    {
-        LogRel(("kstat_data_lookup(obytes) -> %d\n", errno));
-        return VERR_INTERNAL_ERROR;
-    }
-    *tx = kn->value.ul;
+    if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"rbytes64")) == 0)
+    {
+        if (g_fNotReported)
+        {
+            g_fNotReported = false;
+            LogRel(("Failed to locate rbytes64, falling back to 32-bit counters...\n"));
+        }
+        if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"rbytes")) == 0)
+        {
+            LogRel(("kstat_data_lookup(rbytes) -> %d, name=%s\n", errno, name));
+            return VERR_INTERNAL_ERROR;
+        }
+        *rx = wrapCorrection(kn->value.ul, *rx, "rbytes");
+    }
+    else
+        *rx = wrapDetection(kn->value.ull, *rx, "rbytes64");
+    if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"obytes64")) == 0)
+    {
+        if (g_fNotReported)
+        {
+            g_fNotReported = false;
+            LogRel(("Failed to locate obytes64, falling back to 32-bit counters...\n"));
+        }
+        if ((kn = (kstat_named_t *)kstat_data_lookup(ksAdapter, (char *)"obytes")) == 0)
+        {
+            LogRel(("kstat_data_lookup(obytes) -> %d\n", errno));
+            return VERR_INTERNAL_ERROR;
+        }
+        *tx = wrapCorrection(kn->value.ul, *tx, "obytes");
+    }
+    else
+        *tx = wrapDetection(kn->value.ull, *tx, "obytes64");
     return VINF_SUCCESS;
 }
@@ -490,5 +543,5 @@
     uint64_t cbBlock = stats.f_frsize ? stats.f_frsize : stats.f_bsize;
     *total = (ULONG)(getZfsTotal(cbBlock * stats.f_blocks, stats.f_basetype, path) / _MB);
-    LogRel(("f_blocks=%llu.\n", stats.f_blocks));
+    LogFlowThisFunc(("f_blocks=%llu.\n", stats.f_blocks));
     *used  = (ULONG)(cbBlock * (stats.f_blocks - stats.f_bfree) / _MB);
     *available = (ULONG)(cbBlock * stats.f_bavail / _MB);
@@ -505,5 +558,5 @@
     strcpy(szName, name);
     strcat(szName, ",err");
-    kstat_t *ksDisk = kstat_lookup(mKC, "sderr", -1, szName);
+    kstat_t *ksDisk = kstat_lookup(mKC, NULL, -1, szName);
     if (ksDisk != 0)
     {
@@ -524,4 +577,10 @@
         }
     }
+    else
+    {
+        LogRel(("kstat_lookup(%s) -> %d\n", szName, errno));
+        rc = VERR_INTERNAL_ERROR;
+    }
+
 
     return rc;
Index: trunk/src/VBox/Main/testcase/tstCollector.cpp
===================================================================
--- trunk/src/VBox/Main/testcase/tstCollector.cpp	(revision 44029)
+++ trunk/src/VBox/Main/testcase/tstCollector.cpp	(revision 44031)
@@ -155,4 +155,5 @@
     RTPrintf("tstCollector: TESTING - Network load, sleeping for 5 sec...\n");
 
+    hostRxStart = hostTxStart = 0;
     int rc = collector->preCollect(hints, 0);
     if (RT_FAILURE(rc))
@@ -176,4 +177,6 @@
         return 1;
     }
+    hostRxStop = hostRxStart;
+    hostTxStop = hostTxStart;
     rc = collector->getRawHostNetworkLoad(NETIFNAME, &hostRxStop, &hostTxStop);
     if (RT_FAILURE(rc))
