Tuesday, April 8, 2008

Host vs Guest Memory in VMware esx server

After watching a video for high level concepts of memory management for guests, this is a summary of what I understood:

Host memory shows the total memory assigned to that guest by the host.

Guest memory means what host sees as active memory usage on the guest, this might differ from what you see from guest’s point of view. And that’s OK.

Now why do they differ and is it okay if Host memory is much higher than guest memory?

In a traditional model where there is no virtualization, Operating system get the memory directly from underlying hardware and manages the used and free memory by itself.

In a Virtualized model, OS assumes that traditional model for memory and thus doesn’t(or should I say can’t) inform the Virtualization layer about the free memory. For example, if you assign 1G to a guest and at some point guest uses, say, 800M of the memory and after some time frees say 600M of the memory. So guest is using 200M but virtualization layer is not aware of this memory being free on the guest.

Now how does host know how to free memory? This is achieved by memory balooning. Baloon driver is part of the vmware tools and it keeps marking or pinning the free memory on the guest OS and informs the host about it.

There are other ways for host to find out about free memory and it can do swapping for guest too. But host is not very eager all the time to get the exact free memory stats from the guest to free up that memory. Only when the free memory on guest OS falls below a certain threshold, ballooning or swapping is done and host frees up that memory. This is the reason lots of time host memory is higher than guest memory. And its normal if you see that.

Virtual Center 2.5 shows incorrect power state for a guest

If Virtual center is showing incorrect power state for a guest and Host(ESX 3.0.2) shows it correct, management service on the host(on which guest resides) needs to be restarted. Following command is all that is needed:

service mgmt-vmware restart

After this, close out the virtual center session and re-login. Now you should see the correct state.