Patches have been submitted by KVM developer Anthony Liguori featuring dynamic ballooning of kvm guest virtual machine memory. Bear in mind though that in order for this feature to work there are two requirements. These requirements are that your linux kvm host must be running at least kernel 2.6.27 in order to use the mmu notifier operations and secondly, you cannot run kvm with the –no-kvm option which essentially means that kvm “acceleration” must be enabled. These are the only requirements. You can probably expect to see this feature released sometime soon so it would be useful to have an idea of what you can expect.
Memory ballooning allows you to have your guest dynamically change it’s memory usage by evicting unused memory during runtime. This is a useful feature because it reduces the impact your guest can have on memory usage of your host by giving up unused memory back to the host.
The patches submitted add two commands to the monitor interface. One command is an informational command showing current memory usage of your virtual machine and the other command is the command to dynamically change your guest memory.
The info command is useful in verifying that your virtual machine has actually changed it’s memory usage. The syntax for this command is as follows which will show memory usage in MB.
(qemu) info balloon
The syntax for the command to actually perform memory ballooning is as follows.
(qemu) balloon 400
This command will request your guest machine to change it’s memory allocation to the specified amount in MB which is 400MB in the example above. You will be able to verify this by using the info balloon command again.
With the current rapid pace of KVM development you will be able to test this feature in the near future, just get your 2.6.27 kernel ready.