Virt-manager: Partioning the available memory

memoryvirt-managervirtualization

I have a hypervisor which uses kvm and virt-manager to handle the virtual machines.

The hypervisor has 6GByte of memory.

If I add a new virtual machine I don't know how much memory is still free.

At least the virt-manager dialog does not show it:

enter image description here

Is there a tool which helps me to find a matching maximum value?

Example:

  • 6 GB total host memory
  • 2 GB given to host "host-one"
  • ? GB for host "host-two".

Above is only a simple example. On our real servers we have much more virtual-hosts.

I am afraid to give too much memory to the virtual-hosts. This results in heavy performance impact if the hypervisor has too few. If I would give "host-two" 4GB, then the hypervisor would be "on fire", since it has "no air to breath".

Is there a tool which can help me to decide how much memory is available?

Best Answer

As the Redhat documentation you linked about overcommitting memory says,

"Guest virtual machines running on a KVM hypervisor do not have dedicated blocks of physical RAM assigned to them. Instead, each guest virtual machine functions as a Linux process where the host physical machine's Linux kernel allocates memory only when requested."

This makes the whole situation of determining how much RAM you can/should allocate to each host a little fuzzy, unfortunately. One tool you can use to view allocated memory among VMs is virsh and its freecell command.

The man page for virsh states that freecell, "Prints the available amount of memory on the machine or within a NUMA cell. The freecell command can provide one of three different displays of available memory on the machine, depending on the options specified...."

For KVM-based hypervisors, you can use the virtual machine shell command (virsh) in a terminal to enter the virtual shell -- your prompt should change from its default to virsh #. Then, you can use the list command to display a list of virtual machines on the hypervisor.

To display the amount of memory per VM (by its number shown by the list command), use:

virsh # freecell <cell_number> 

You can also pass the --all flag instead of a cell number to show the amount of memory allocated for each of the VMs and for the entire machine.

This should give you a good idea of the total memory you're working with and how much is allocated to each VM. If you decide that you'd like to change the amount of memory allocated, virsh also provides the setmem command to change the memory allocation for a guest domain. It's similar to the interface provided by virt-manager, but provides more options and flexibility. You can find all of the command options and descriptions with man virsh.