Index: /trunk/src/VBox/Main/src-client/GuestImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/GuestImpl.cpp	(revision 80669)
+++ /trunk/src/VBox/Main/src-client/GuestImpl.cpp	(revision 80670)
@@ -108,6 +108,5 @@
 
     mMagic = GUEST_MAGIC;
-    int vrc = RTTimerLRCreateEx(&mStatTimer, RT_NS_1SEC, 0 /*fFlags*/, &Guest::i_staticUpdateStats, this);
-    AssertMsgRC(vrc, ("Failed to create guest statistics update timer (%Rrc) - ignored\n", vrc));
+    mStatTimer = NIL_RTTIMERLR;
 
     hr = unconst(mEventSource).createObject();
@@ -168,5 +167,5 @@
     int vrc = RTTimerLRDestroy(mStatTimer);
     AssertMsgRC(vrc, ("Failed to create guest statistics update timer(%Rra)\n", vrc));
-    mStatTimer = NULL;
+    mStatTimer = NIL_RTTIMERLR;
     mMagic     = 0;
 
@@ -626,16 +625,34 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    if (mStatUpdateInterval)
-    {
-        if (aStatisticsUpdateInterval == 0)
-            RTTimerLRStop(mStatTimer);
-        else
-            RTTimerLRChangeInterval(mStatTimer, aStatisticsUpdateInterval * RT_NS_1SEC_64);
-    }
-    else if (aStatisticsUpdateInterval != 0)
-    {
-        RTTimerLRChangeInterval(mStatTimer, aStatisticsUpdateInterval * RT_NS_1SEC_64);
-        RTTimerLRStart(mStatTimer, 0);
-    }
+    /* Update the timer, creating it the first time we're called with a non-zero value. */
+    int vrc;
+    HRESULT hrc = S_OK;
+    if (aStatisticsUpdateInterval > 0)
+    {
+        if (mStatTimer == NIL_RTTIMERLR)
+        {
+            vrc = RTTimerLRCreate(&mStatTimer, aStatisticsUpdateInterval * RT_MS_1SEC, &Guest::i_staticUpdateStats, this);
+            AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to create guest statistics update timer (%Rrc)", vrc));
+        }
+        else if (aStatisticsUpdateInterval != mStatUpdateInterval)
+        {
+            vrc = RTTimerLRChangeInterval(mStatTimer, aStatisticsUpdateInterval * RT_NS_1SEC_64);
+            AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to change guest statistics update timer interval from %u to %u failed (%Rrc)",
+                                                mStatUpdateInterval, aStatisticsUpdateInterval, vrc));
+            if (mStatUpdateInterval == 0)
+            {
+                vrc = RTTimerLRStart(mStatTimer, 0);
+                AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to start the guest statistics update timer (%Rrc)", vrc));
+            }
+        }
+    }
+    /* Setting interval to zero - stop the update timer if needed: */
+    else if (mStatUpdateInterval > 0 && mStatTimer != NIL_RTTIMERLR)
+    {
+        vrc = RTTimerLRStop(mStatTimer);
+        AssertRCStmt(vrc, hrc = setErrorVrc(vrc, "Failed to stop the guest statistics update timer (%Rrc)", vrc));
+    }
+
+    /* Update the interval now that the timer is in sync. */
     mStatUpdateInterval = aStatisticsUpdateInterval;
 
@@ -652,5 +669,5 @@
     }
 
-    return S_OK;
+    return hrc;
 }
 
@@ -667,9 +684,9 @@
     *aCpuKernel  = mCurrentGuestStat[GUESTSTATTYPE_CPUKERNEL];
     *aCpuIdle    = mCurrentGuestStat[GUESTSTATTYPE_CPUIDLE];
-    *aMemTotal   = mCurrentGuestStat[GUESTSTATTYPE_MEMTOTAL] * (_4K/_1K);     /* page (4K) -> 1KB units */
-    *aMemFree    = mCurrentGuestStat[GUESTSTATTYPE_MEMFREE] * (_4K/_1K);       /* page (4K) -> 1KB units */
+    *aMemTotal   = mCurrentGuestStat[GUESTSTATTYPE_MEMTOTAL]   * (_4K/_1K); /* page (4K) -> 1KB units */
+    *aMemFree    = mCurrentGuestStat[GUESTSTATTYPE_MEMFREE]    * (_4K/_1K); /* page (4K) -> 1KB units */
     *aMemBalloon = mCurrentGuestStat[GUESTSTATTYPE_MEMBALLOON] * (_4K/_1K); /* page (4K) -> 1KB units */
-    *aMemCache   = mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE] * (_4K/_1K);     /* page (4K) -> 1KB units */
-    *aPageTotal  = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL] * (_4K/_1K);   /* page (4K) -> 1KB units */
+    *aMemCache   = mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE]   * (_4K/_1K); /* page (4K) -> 1KB units */
+    *aPageTotal  = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL]  * (_4K/_1K); /* page (4K) -> 1KB units */
 
     /* Play safe or smth? */
