Commit 2c7a0373 authored by Guido Trotter's avatar Guido Trotter
Browse files

Implement memory ballooning in xen


Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent b990eedd
...@@ -302,6 +302,29 @@ class XenHypervisor(hv_base.BaseHypervisor): ...@@ -302,6 +302,29 @@ class XenHypervisor(hv_base.BaseHypervisor):
" did not reboot in the expected interval" % " did not reboot in the expected interval" %
(instance.name, )) (instance.name, ))
def BalloonInstanceMemory(self, instance, mem):
"""Balloon an instance memory to a certain value.
@type instance: L{objects.Instance}
@param instance: instance to be accepted
@type mem: int
@param mem: actual memory size to use for instance runtime
"""
cmd = [constants.XEN_CMD, "mem-set", instance.name, mem]
result = utils.RunCmd(cmd)
if result.failed:
raise errors.HypervisorError("Failed to balloon instance %s: %s (%s)" %
(instance.name, result.fail_reason,
result.output))
cmd = ["sed", "-ie", "s/^memory.*$/memory = %s/" % mem]
cmd.append(XenHypervisor._ConfigFileName(instance.name))
result = utils.RunCmd(cmd)
if result.failed:
raise errors.HypervisorError("Failed to update memory for %s: %s (%s)" %
(instance.name, result.fail_reason,
result.output))
def GetNodeInfo(self): def GetNodeInfo(self):
"""Return information about the node. """Return information about the node.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment