A draft implementation supporting persistent and dynamic modification of the KVM instance memory ( ballooning ) was submitted for comment to the ganeti mailing list.
rationale
The -balloon support has been added to KVM instances. But changing the amount of memory available to the instance requires to manually interact with the control file
echo balloon 256 | socat - UNIX-CLIENT:sileht.tetaneutral.net.monitor
which is inconvenient and needs to be done after each reboot.
proposed implementation
The implementation of the gnt-instance balloon command and the memory KVM parameter provide dynamic modification and persistence, respectively.
When the user does gnt-instance balloon –memory XXX INSTANCE it will
- send the balloon XXX command to the monitor of the INSTANCE
- change the “memory” KVM parameter to XXX by calling _ParseArgs
as if gnt-instance modify -H memory=XXX INSTANCE was run and
execute the returned function.
When the KVM instance is run ( at the end of the hv_kvm.py function _ExecuteKVMRuntime ) the balloon XXX command is sent to the monitor of the instance, if XXX > 0 so that the balloon driver uses the required memory as soon as possible.
There is no example of a dynamically modified KVM parameter requiring interaction with the monitor. There is a good chance that this approach is wrong and needs to be fixed.