Currently memory_dom0 collected value is used for Xen and Kvm. In case
of Kvm collection is broken because the amount of memory used by
hypervisor includes the amount of memory used by instances as well.
Replace memory_dom0 with memory_node from hv_state parameter.

Signed-off-by: Oleg Ponomarev <[email protected]>
---
 lib/masterd/iallocator.py           | 1 +
 src/Ganeti/HTools/Backend/IAlloc.hs | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/masterd/iallocator.py b/lib/masterd/iallocator.py
index 547c939..d8b36ea 100644
--- a/lib/masterd/iallocator.py
+++ b/lib/masterd/iallocator.py
@@ -572,6 +572,7 @@ class IAllocator(object):
       "master_capable": ninfo.master_capable,
       "vm_capable": ninfo.vm_capable,
       "ndparams": cfg.GetNdParams(ninfo),
+      "hv_state": cfg.GetFilledHvStateParams(ninfo)
       })
       for ninfo in node_cfg.values())
 
diff --git a/src/Ganeti/HTools/Backend/IAlloc.hs 
b/src/Ganeti/HTools/Backend/IAlloc.hs
index d704950..5946efe 100644
--- a/src/Ganeti/HTools/Backend/IAlloc.hs
+++ b/src/Ganeti/HTools/Backend/IAlloc.hs
@@ -147,9 +147,11 @@ parseNode :: NameAssoc   -- ^ The group association
 parseNode ktg n a = do
   let desc = "invalid data for node '" ++ n ++ "'"
       extract x = tryFromObj desc a x
+      extractDef def key = fromObjWithDefault a key def
   offline <- extract "offline"
   drained <- extract "drained"
   guuid   <- extract "group"
+  hvstate   <- extractDef emptyContainer "hv_state"
   vm_capable  <- annotateResult desc $ maybeFromObj a "vm_capable"
   let vm_capable' = fromMaybe True vm_capable
   gidx <- lookupGroup ktg n guuid
@@ -168,7 +170,8 @@ parseNode ktg n a = do
   dfree  <- lvextract 0 "free_disk"
   ctotal <- lvextract 0.0 "total_cpus"
   cnos <- lvextract 0 "reserved_cpus"
-  let node = Node.create n mtotal mnode mfree dtotal dfree ctotal cnos
+  let node_mem = obtainNodeMemory hvstate mnode
+      node = Node.create n mtotal node_mem mfree dtotal dfree ctotal cnos
              (not live || drained) sptotal spfree gidx excl_stor
   return (n, node)
 
-- 
2.6.0.rc2.230.g3dd15c0

Reply via email to