Use half of host memory as maxmem by default. Allow to configure it per VM.

This commit is contained in:
Marek Marczykowski 2011-04-29 01:38:43 +02:00
parent ac84bbe621
commit aa7df98b7e
2 changed files with 26 additions and 3 deletions

View File

@ -179,6 +179,7 @@ class QubesVm(object):
root_img = None,
private_img = None,
memory = default_memory,
maxmem = None,
template_vm = None,
firewall_conf = None,
volatile_img = None,
@ -246,6 +247,12 @@ class QubesVm(object):
self.memory = memory
if maxmem is None:
total_mem_mb = self.get_total_xen_memory()/1024/1024
self.maxmem = total_mem_mb/2
else:
self.maxmem = maxmem
self.template_vm = template_vm
if template_vm is not None:
if updateable:
@ -882,8 +889,7 @@ class QubesVm(object):
print "--> Loading the VM (type = {0})...".format(self.type)
if not self.is_netvm():
total_mem_mb = self.get_total_xen_memory()/1024/1024
xend_session.xend_server.xend.domain.maxmem_set(self.name, total_mem_mb)
xend_session.xend_server.xend.domain.maxmem_set(self.name, self.maxmem)
mem_required = self.get_mem_dynamic_max()
qmemman_client = QMemmanClient()
@ -993,6 +999,7 @@ class QubesVm(object):
attrs["updateable"] = str(self.updateable)
attrs["label"] = self.label.name
attrs["memory"] = str(self.memory)
attrs["maxmem"] = str(self.maxmem)
attrs["pcidevs"] = str(self.pcidevs)
attrs["vcpus"] = str(self.vcpus)
attrs["internal"] = str(self.internal)
@ -2004,7 +2011,8 @@ class QubesVmCollection(dict):
common_attr_list = ("qid", "name", "dir_path", "conf_file",
"private_img", "root_img", "template_qid",
"installed_by_rpm", "updateable", "internal",
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs")
"uses_default_netvm", "label", "memory", "vcpus", "pcidevs",
"maxmem" )
for attribute in common_attr_list:
kwargs[attribute] = element.get(attribute)

View File

@ -49,6 +49,8 @@ def do_list(vm):
print fmt.format ("root volatile img", vm.volatile_img)
print fmt.format ("private img", vm.private_img)
print fmt.format ("memory", vm.memory)
print fmt.format ("maxmem", vm.maxmem)
def set_label(vms, vm, args):
@ -65,6 +67,17 @@ def set_label(vms, vm, args):
vm.label = QubesVmLabels[label]
subprocess.check_call (["ln", "-sf", vm.label.icon_path, vm.icon_path])
def set_memory(vms, vm, args):
if len (args) != 1:
print "Missing memory argument!"
vm.memory = int(args[0])
def set_maxmem(vms, vm, args):
if len (args) != 1:
print "Missing maxmem argument!"
vm.maxmem = int(args[0])
def set_netvm(vms, vm, args):
if len (args) != 1:
@ -153,6 +166,8 @@ properties = {
"nonupdateable": set_nonupdateable,
"label" : set_label,
"netvm" : set_netvm,
"maxmem" : set_maxmem,
"memory" : set_memory,
}