From 72d277c56b9e4ef5b487b5f4d0632c35a9708164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Mon, 31 Mar 2014 03:41:33 +0200 Subject: [PATCH] core: add QubesVm.get_prefmem (#788) Expose 'prefmem' property used by qmemman. --- core-modules/000QubesVm.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core-modules/000QubesVm.py b/core-modules/000QubesVm.py index 72ea01b6..fc6217df 100644 --- a/core-modules/000QubesVm.py +++ b/core-modules/000QubesVm.py @@ -34,6 +34,8 @@ import time import uuid import xml.parsers.expat import xen.lowlevel.xc +from qubes import qmemman +from qubes import qmemman_algo from qubes.qubes import xs,dry_run,xc,xl_ctx from qubes.qubes import register_qubes_vm_class @@ -651,6 +653,16 @@ class QubesVm(object): else: return 0 + def get_prefmem(self): + untrusted_meminfo_key = xs.read('', '/local/domain/%s/memory/meminfo' + % self.xid) + if untrusted_meminfo_key is None or untrusted_meminfo_key == '': + return 0 + domain = qmemman.DomainState(self.xid) + qmemman_algo.refresh_meminfo_for_domain(domain, untrusted_meminfo_key) + domain.memory_maximum = self.get_mem_static_max()*1024 + return qmemman_algo.prefmem(domain)/1024 + def get_per_cpu_time(self): if dry_run: import random