I really think it should be here. If you "just" balloon an instance
when it reboots it must come back with the same value, until you
balloon it again.
Otherwise it risks not having enough memory to come up at all, for
example. So the config update must happen here. Of course if you do a
"full" reboot or stop/start it the new memory will be recalculated,
but this will happen on the master side.
There is really no reason why the file on disk should have a different
value than the hypervisor, as much as we can avoid it.

Thanks,

Guido


On Fri, Dec 16, 2011 at 1:26 PM, René Nussbaumer <[email protected]> wrote:
> On Fri, Dec 16, 2011 at 12:13, Guido Trotter <[email protected]> wrote:
>> Signed-off-by: Guido Trotter <[email protected]>
>> ---
>>  lib/hypervisor/hv_xen.py |   23 +++++++++++++++++++++++
>>  1 files changed, 23 insertions(+), 0 deletions(-)
>>
>> diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py
>> index 506de0a..44a761c 100644
>> --- a/lib/hypervisor/hv_xen.py
>> +++ b/lib/hypervisor/hv_xen.py
>> @@ -302,6 +302,29 @@ class XenHypervisor(hv_base.BaseHypervisor):
>>                                    " did not reboot in the expected 
>> interval" %
>>                                    (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))
>> +
>
> Can you please split the config update to a separate method? It seems
> to be in the wrong place. What if you don't want to update the config
> and just set the new memory value temporary?
>
> René



-- 
Guido Trotter
Google - Corporate Computing Services SRE

Google Ireland Ltd. : Registered in Ireland with company number 368047.
Gordon House, Barrow Street, Dublin 4, Ireland.

Reply via email to