Index: /trunk/include/VBox/gmm.h
===================================================================
--- /trunk/include/VBox/gmm.h	(revision 28011)
+++ /trunk/include/VBox/gmm.h	(revision 28012)
@@ -399,18 +399,18 @@
 
 /**
- * Request buffer for GMMR0QueryTotalBalloonSizeReq / VMMR0_DO_GMM_BALLOONED_PAGES.
- * @see GMMR0QueryTotalBalloonSize.
- */
-typedef struct GMMBALLOONQUERY
+ * Request buffer for GMMR0QueryTotalFreePagesReq / VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES.
+ * @see GMMR0QueryTotalFreePagesReq.
+ */
+typedef struct GMMFREEQUERYREQ
 {
     /** The header. */
     SUPVMMR0REQHDR      Hdr;
-    /** The number of ballooned pages (out). */
-    uint64_t            cBalloonedPages;
-} GMMBALLOONQUERYREQ;
-/** Pointer to a GMMR0QueryTotalBalloonSizeReq / VMMR0_DO_GMM_QUERY_TOTAL_BALLOON_SIZE request buffer. */
-typedef GMMBALLOONQUERYREQ *PGMMBALLOONQUERYREQ;
-
-GMMR0DECL(int)  GMMR0QueryTotalBalloonSizeReq(PVM pVM, PGMMBALLOONQUERYREQ pReq);
+    /** The number of free pages (out). */
+    uint64_t            cFreePages;
+} GMMFREEQUERYREQ;
+/** Pointer to a GMMR0QueryTotalFreePagesReq / VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES request buffer. */
+typedef GMMFREEQUERYREQ *PGMMFREEQUERYREQ;
+
+GMMR0DECL(int)  GMMR0QueryTotalFreePagesReq(PVM pVM, PGMMFREEQUERYREQ pReq);
 
 /**
@@ -473,5 +473,5 @@
 GMMR3DECL(int)  GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3);
 GMMR3DECL(int)  GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
-GMMR3DECL(int)  GMMR3QueryTotalBalloonSize(PVM pVM, uint64_t *pcTotalBalloonedPages);
+GMMR3DECL(int)  GMMR3QueryTotalFreePages(PVM pVM, uint64_t *pcTotalFreePages);
 /** @} */
 #endif /* IN_RING3 */
Index: /trunk/include/VBox/pgm.h
===================================================================
--- /trunk/include/VBox/pgm.h	(revision 28011)
+++ /trunk/include/VBox/pgm.h	(revision 28012)
@@ -467,5 +467,5 @@
 VMMR3DECL(int)      PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
 VMMR3DECL(int)      PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
-VMMR3DECL(int)      PGMR3QueryBalloonSize(PVM pVM, unsigned *puVMBalloonSize, unsigned *puTotalBalloonSize);
+VMMR3DECL(int)      PGMR3QueryFreeMemory(PVM pVM, unsigned *puTotalFreeSize);
 VMMR3DECL(int)      PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb,
                                           R3PTRTYPE(PFNPGMR3PHYSHANDLER) pfnHandlerR3, RTR3PTR pvUserR3,
Index: /trunk/include/VBox/vmm.h
===================================================================
--- /trunk/include/VBox/vmm.h	(revision 28011)
+++ /trunk/include/VBox/vmm.h	(revision 28012)
@@ -300,8 +300,8 @@
     /** Call GMMR0FreeLargePage(). */
     VMMR0_DO_GMM_FREE_LARGE_PAGE,
+    /** Call GMMR0QueryTotalFreePagesReq */
+    VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES,
     /** Call GMMR0BalloonedPages(). */
     VMMR0_DO_GMM_BALLOONED_PAGES,
-    /** Call GMMR0QueryTotalBalloonSize*/
-    VMMR0_DO_GMM_QUERY_TOTAL_BALLOON_SIZE,
     /** Call GMMR0MapUnmapChunk(). */
     VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
Index: /trunk/src/VBox/Main/GuestImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/GuestImpl.cpp	(revision 28011)
+++ /trunk/src/VBox/Main/GuestImpl.cpp	(revision 28012)
@@ -254,6 +254,6 @@
 
 STDMETHODIMP Guest::InternalGetStatistics(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
-                                          ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemBalloonTotal,
-                                          ULONG *aMemCache, ULONG *aPageTotal)
+                                          ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, 
+                                          ULONG *aMemCache, ULONG *aPageTotal, ULONG *aMemFreeTotal)
 {
     CheckComArgOutPointerValid(aCpuUser);
@@ -276,5 +276,5 @@
     *aMemTotal = mCurrentGuestStat[GUESTSTATTYPE_MEMTOTAL];
     *aMemFree = mCurrentGuestStat[GUESTSTATTYPE_MEMFREE];
-
+    *aMemBalloon = mCurrentGuestStat[GUESTSTATTYPE_MEMBALLOON];
     *aMemCache = mCurrentGuestStat[GUESTSTATTYPE_MEMCACHE];
     *aPageTotal = mCurrentGuestStat[GUESTSTATTYPE_PAGETOTAL];
@@ -283,20 +283,13 @@
     if (pVM.isOk())
     {
-        unsigned uBalloon, uBalloonTotal;
-        *aMemBalloon      = 0;
-        *aMemBalloonTotal = 0;
-        int rc = PGMR3QueryBalloonSize(pVM.raw(), &uBalloon, &uBalloonTotal);
+        unsigned uFreeTotal;
+        *aMemFreeTotal = 0;
+        int rc = PGMR3QueryFreeMemory(pVM.raw(), &uFreeTotal);
         AssertRC(rc);
         if (rc == VINF_SUCCESS)
-        {
-            *aMemBalloon      = uBalloon;
-            *aMemBalloonTotal = uBalloonTotal;
-        }
+            *aMemFreeTotal = uFreeTotal;
     }
     else
-    {
-        *aMemBalloon      = 0;
-        *aMemBalloonTotal = 0;
-    }
+        *aMemFreeTotal = 0;
 
     return S_OK;
Index: /trunk/src/VBox/Main/HostImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/HostImpl.cpp	(revision 28011)
+++ /trunk/src/VBox/Main/HostImpl.cpp	(revision 28012)
@@ -2411,6 +2411,5 @@
     pm::SubMetric *ramUsageFree  = new pm::SubMetric("RAM/Usage/Free",
         "Physical memory currently available to applications.");
-    pm::SubMetric *ramUsageBalloon = new pm::SubMetric("RAM/Usage/Ballooned",
-        "Physical memory currently available from guest balloons.");
+
     /* Create and register base metrics */
     IUnknown *objptr;
@@ -2423,5 +2422,5 @@
     aCollector->registerBaseMetric (cpuMhz);
     pm::BaseMetric *ramUsage = new pm::HostRamUsage(hal, objptr, ramUsageTotal, ramUsageUsed,
-                                           ramUsageFree, ramUsageBalloon);
+                                           ramUsageFree);
     aCollector->registerBaseMetric (ramUsage);
 
@@ -2481,12 +2480,4 @@
     aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageFree,
                                               new pm::AggregateMax()));
-
-    aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageBalloon, 0));
-    aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageBalloon,
-                                              new pm::AggregateAvg()));
-    aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageBalloon,
-                                              new pm::AggregateMin()));
-    aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageBalloon,
-                                              new pm::AggregateMax()));
 };
 
Index: /trunk/src/VBox/Main/Performance.cpp
===================================================================
--- /trunk/src/VBox/Main/Performance.cpp	(revision 28011)
+++ /trunk/src/VBox/Main/Performance.cpp	(revision 28012)
@@ -168,12 +168,12 @@
         &&  iTick != mLastTick)
     {
-        ULONG ulMemBalloonTotal;
+        ULONG ulMemFreeTotal;
 
         mGuest->InternalGetStatistics(&mCpuUser, &mCpuKernel, &mCpuIdle,
-                                      &mMemTotal, &mMemFree, &mMemBalloon, &ulMemBalloonTotal, &mMemCache,
-                                      &mPageTotal);
+                                      &mMemTotal, &mMemFree, &mMemBalloon, &mMemCache,
+                                      &mPageTotal, &ulMemFreeTotal);
 
         if (mHostHAL)
-            mHostHAL->setBalloonSize(ulMemBalloonTotal);
+            mHostHAL->setMemFreeTotal(ulMemFreeTotal);
 
         mLastTick = iTick;
@@ -303,7 +303,6 @@
         mTotal->put(total);
         mUsed->put(used);
-        mAvailable->put(available);
-    }
-    mBallooned->put(mHAL->getBalloonSize());
+        mAvailable->put(available + mHAL->getMemFreeTotal());
+    }
 }
 
Index: /trunk/src/VBox/Main/PerformanceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/PerformanceImpl.cpp	(revision 28011)
+++ /trunk/src/VBox/Main/PerformanceImpl.cpp	(revision 28012)
@@ -68,8 +68,4 @@
     "RAM/Usage/Free:min",
     "RAM/Usage/Free:max",
-    "RAM/Usage/Ballooned",
-    "RAM/Usage/Ballooned:avg",
-    "RAM/Usage/Ballooned:min",
-    "RAM/Usage/Ballooned:max",
     "Guest/CPU/Load/User",
     "Guest/CPU/Load/User:avg",
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 28011)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 28012)
@@ -8444,7 +8444,4 @@
          <desc>Amount of ballooned physical guest RAM</desc> 
       </param> 
-      <param name="memBalloonTotal" type="unsigned long" dir="out"> 
-         <desc>Amount of ballooned physical guest RAM for all running VMs</desc> 
-      </param> 
       <param name="memCache" type="unsigned long" dir="out"> 
          <desc>Total amount of guest (disk) cache memory</desc> 
@@ -8452,4 +8449,7 @@
       <param name="pagedTotal" type="unsigned long" dir="out"> 
          <desc>Total amount of space in the page file</desc> 
+      </param> 
+      <param name="memFreeTotal" type="unsigned long" dir="out"> 
+         <desc>Total amount of free memory available in VMMR0</desc> 
       </param> 
     </method> 
Index: /trunk/src/VBox/Main/include/GuestImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/GuestImpl.h	(revision 28011)
+++ /trunk/src/VBox/Main/include/GuestImpl.h	(revision 28012)
@@ -89,6 +89,6 @@
                               ULONG aTimeoutMS, ULONG* aPID, IProgress **aProgress);
     STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
-                                     ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemBalloonTotal, ULONG *aMemCache,
-                                     ULONG *aPageTotal);
+                                     ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemCache,
+                                     ULONG *aPageTotal, ULONG *aMemFreeTotal);
 
     // public methods that are not in IDL
Index: /trunk/src/VBox/Main/include/Performance.h
===================================================================
--- /trunk/src/VBox/Main/include/Performance.h	(revision 28011)
+++ /trunk/src/VBox/Main/include/Performance.h	(revision 28012)
@@ -139,5 +139,5 @@
     {
     public:
-                 CollectorHAL() : mMemBalloonTotal(0) {};
+                 CollectorHAL() : mMemFreeTotal(0) {};
         virtual ~CollectorHAL() { };
         virtual int preCollect(const CollectorHints& /* hints */, uint64_t /* iTick */) { return VINF_SUCCESS; }
@@ -163,17 +163,17 @@
         virtual int disable();
 
-        virtual int setBalloonSize(ULONG balloonsize)
-        {
-            mMemBalloonTotal = balloonsize;
+        virtual int setMemFreeTotal(ULONG memfree)
+        {
+            mMemFreeTotal = memfree;
             return S_OK;
         }
 
-        virtual ULONG getBalloonSize()
-        {
-            return mMemBalloonTotal;
-        }
-
-    private:
-        ULONG       mMemBalloonTotal;
+        virtual ULONG getMemFreeTotal()
+        {
+            return mMemFreeTotal;
+        }
+
+    private:
+        ULONG       mMemFreeTotal;
     };
 
@@ -335,7 +335,7 @@
     {
     public:
-        HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available, SubMetric *ballooned)
-        : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available), mBallooned(ballooned) {};
-        ~HostRamUsage() { delete mTotal; delete mUsed; delete mAvailable; delete mBallooned; };
+        HostRamUsage(CollectorHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *used, SubMetric *available)
+        : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mUsed(used), mAvailable(available) {};
+        ~HostRamUsage() { delete mTotal; delete mUsed; delete mAvailable; };
 
         void init(ULONG period, ULONG length);
@@ -350,5 +350,4 @@
         SubMetric *mUsed;
         SubMetric *mAvailable;
-        SubMetric *mBallooned;
     };
 
Index: /trunk/src/VBox/VMM/GMM.cpp
===================================================================
--- /trunk/src/VBox/VMM/GMM.cpp	(revision 28011)
+++ /trunk/src/VBox/VMM/GMM.cpp	(revision 28012)
@@ -291,17 +291,17 @@
 
 /**
- * @see GMMR0QueryTotalBalloonSizeReq
- */
-GMMR3DECL(int)  GMMR3QueryTotalBalloonSize(PVM pVM, uint64_t *pcTotalBalloonedPages)
-{
-    GMMBALLOONQUERYREQ Req;
-    Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
-    Req.Hdr.cbReq = sizeof(Req);
-    Req.cBalloonedPages = 0;
-
-    *pcTotalBalloonedPages = 0;
-    int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_QUERY_TOTAL_BALLOON_SIZE, 0, &Req.Hdr);
+ * @see GMMR0QueryTotalFreePagesReq
+ */
+GMMR3DECL(int)  GMMR3QueryTotalFreePages(PVM pVM, uint64_t *pcTotalFreePages)
+{
+    GMMFREEQUERYREQ Req;
+    Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
+    Req.Hdr.cbReq = sizeof(Req);
+    Req.cFreePages = 0;
+
+    *pcTotalFreePages = 0;
+    int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES, 0, &Req.Hdr);
     if (rc == VINF_SUCCESS)
-        *pcTotalBalloonedPages = Req.cBalloonedPages;
+        *pcTotalFreePages = Req.cFreePages;
 
     return rc;
Index: /trunk/src/VBox/VMM/PGMPhys.cpp
===================================================================
--- /trunk/src/VBox/VMM/PGMPhys.cpp	(revision 28011)
+++ /trunk/src/VBox/VMM/PGMPhys.cpp	(revision 28012)
@@ -954,24 +954,20 @@
 
 /**
- * Query the VM and host balloon sizes
+ * Query the amount of free memory inside VMMR0
  *
  * @returns VBox status code.
  * @param   pVM                 The VM handle.
- * @param   puVMBalloonSize     Pointer to VM balloon size (in megabytes)
- * @param   puTotalBalloonSize  Pointer to total balloon size of all VMs (in megabytes)
- */
-VMMR3DECL(int) PGMR3QueryBalloonSize(PVM pVM, unsigned *puVMBalloonSize, unsigned *puTotalBalloonSize)
+ * @param   puTotalFreeSize     Pointer to total free (allocated but not used yet) memory inside VMMR0 (in megabytes)
+ */
+VMMR3DECL(int) PGMR3QueryFreeMemory(PVM pVM, unsigned *puTotalFreeSize)
 {
     int rc = VINF_SUCCESS;
 
-    if (puVMBalloonSize)
-        *puVMBalloonSize = pVM->pgm.s.cBalloonedPages * _4K / _1M;
-
-    if (puTotalBalloonSize)
+    if (puTotalFreeSize)
     {
         uint64_t cPages = 0;
-        rc = GMMR3QueryTotalBalloonSize(pVM, &cPages);
+        rc = GMMR3QueryTotalFreePages(pVM, &cPages);
         AssertRC(rc);
-        *puTotalBalloonSize = (unsigned) (cPages * _4K / _1M);
+        *puTotalFreeSize = (unsigned) (cPages * _4K / _1M);
     }
 
Index: /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp	(revision 28011)
+++ /trunk/src/VBox/VMM/VMMR0/GMMR0.cpp	(revision 28012)
@@ -2992,5 +2992,5 @@
 
 /**
- * Return the total amount of ballooned pages for all VMs
+ * Return the total amount of free pages
  *
  * @returns VBox status code:
@@ -2998,5 +2998,5 @@
  * @param   pReq            The request packet.
  */
-GMMR0DECL(int) GMMR0QueryTotalBalloonSizeReq(PVM pVM, PGMMBALLOONQUERYREQ pReq)
+GMMR0DECL(int) GMMR0QueryTotalFreePagesReq(PVM pVM, PGMMFREEQUERYREQ pReq)
 {
     /*
@@ -3005,6 +3005,6 @@
     AssertPtrReturn(pVM, VERR_INVALID_POINTER);
     AssertPtrReturn(pReq, VERR_INVALID_POINTER);
-    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMBALLOONQUERYREQ),
-                    ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMMBALLOONQUERYREQ)),
+    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMFREEQUERYREQ),
+                    ("%#x < %#x\n", pReq->Hdr.cbReq, sizeof(GMMFREEQUERYREQ)),
                     VERR_INVALID_PARAMETER);
 
@@ -3014,5 +3014,5 @@
     PGMM pGMM;
     GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
-    pReq->cBalloonedPages = pGMM->cBalloonedPages;
+    pReq->cFreePages = (pGMM->cChunks << GMM_CHUNK_SHIFT) - pGMM->cAllocatedPages; 
     GMM_CHECK_SANITY_UPON_LEAVING(pGMM);
 
Index: /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 28011)
+++ /trunk/src/VBox/VMM/VMMR0/VMMR0.cpp	(revision 28012)
@@ -910,13 +910,13 @@
             return GMMR0FreeLargePageReq(pVM, idCpu, (PGMMFREELARGEPAGEREQ)pReqHdr);
 
+        case VMMR0_DO_GMM_QUERY_TOTAL_FREE_PAGES:
+            if (u64Arg)
+                return VERR_INVALID_PARAMETER;
+            return GMMR0QueryTotalFreePagesReq(pVM, (PGMMFREEQUERYREQ)pReqHdr);
+
         case VMMR0_DO_GMM_BALLOONED_PAGES:
             if (u64Arg)
                 return VERR_INVALID_PARAMETER;
             return GMMR0BalloonedPagesReq(pVM, idCpu, (PGMMBALLOONEDPAGESREQ)pReqHdr);
-
-        case VMMR0_DO_GMM_QUERY_TOTAL_BALLOON_SIZE:
-            if (u64Arg)
-                return VERR_INVALID_PARAMETER;
-            return GMMR0QueryTotalBalloonSizeReq(pVM, (PGMMBALLOONQUERYREQ)pReqHdr);
 
         case VMMR0_DO_GMM_MAP_UNMAP_CHUNK:
