How to increase/decrease kvm guest memory dynamically?

It is possible !!! RHEL includes balloon driver ( from 5.5 onwards) for kvm guests. The virtio_balloon driver is loaded automatically with RHEL kernels. If a user attempts to balloon a KVM guest the balloon command ( #virsh setmem) will successfully allow a user to change the memory assignment of the guest. # virsh setmem …

Read more

Physical Volume label contains UUID, LABELONE string..etc in it..

LVM tools scans first 2048 bytes of physical volume to get physical volume label. Physical volume label starts with a string called “LABELONE” , also it contains physical volume UUID ..etc information in this region.. I took copy of this area and read it : 0000000000  |…………….| 0000000016  |…………….| 0000000032  |…………….| 0000000048  |…………….| 0000000432  |…………….| …

Read more

Why we fear when we hear about LVM metadata ?

It is very common that, people get scared as soon as they hear about LVM metadata.. I really dont know the reason, but I believe it is mainly because they think ‘metadata’ is not in human readable form ? , could be.. Any way, first of all let me tell you that, LVM metadata is …

Read more

Memory ballooning and virtio_balloon driver in qemu-kvm

Lots of people have heard the word “ballooning” and had a thought about it. In the computer world, this word is mostly aligned with ‘virtualization’. I will try to explain ‘memory ballooning’ in this blog.

In simple terms a virtual environment composed of 2 things.

1) HOST and 2) GUEST. Let me explain these 2 terms in a layman language. Virtualization is used to run another operating system inside your computer. The operating system running in your hardware can be called ‘HOST’ and the other operating system running in your HOST is called GUEST.

I have to answer that, guest memory is derived from Host memory. That is obvious. I am not explaining more about it, only because I just dont want to invite more confusion here..

coming into the word ‘balloon’, we all know there can be two actions inflate/deflate wrt to balloon. Inflate means ‘you are filling something in it”, deflate do opposite action.. Now, how these all terms fit into virtualization.

The guest system will include a balloon ( a balloon driver ex: virtio_balloon) which can be inflated or deflated. Why we need that? as I mentioned above, guest memory is part of the host memory. There will be different applications running in your host system. Sometimes a host system which hosting these different applications can run out of memory or in need of memory… At that time, using this balloon device, the host system can request memory from the guest. which will cause an inflate operation of the balloon device inside the guest. Once the balloon is filled ( memory /pages ) by guests, it can give that to the host system. The vice versa operation is also going in this way.

Now you know, host<-> guest co-operation is required for smooth operation of ‘memory ballooning’. At the time of ‘inflate’ operation, think about ‘unused’ memory in the guest system. This memory is given back to the host. How-ever inflate operation can increase memory pressure in the guest..or you may see high ‘swapping’ in your guest.

The operation chain can look like this:

  • Request ( from host ) to reclaim memory =====> “inflate” operation inside the guest ::
  • Then guest send this memory back to host/hypervisor..

In qemu-kvm setup , virtio_balloon is the balloon driver which will be loaded in the guest system for the balloon device..

Inflate and Deflate operation ( In my bad art skills ? 🙂 ) :

1) Inflate operation of virtio balloon driver:

2) Deflate operation of virtio balloon driver

Now, there can be some questions like, Is it the hot memory add feature? I cannot agree with this.

What commands can be used to give/take memory from guests? in libvirt, qemu-kvm setup you can use ‘virsh setmem’ command for the same purpose.

Demo:

[root@humbles-lap misc]# virsh dumpxml 1
524288 ========== This is the maximuim memory set for this guest
524288 ========== current allocated memory

memballoon model='virtio' ========== virtio driver is used as balloon driver. If you want to disable ballooning use 'none'.


Now, check the memory inside the guest.

You will be seeing something near to ‘524288’..

Once you confirmed above, try to set memory as shown in below example:

#virsh setmem 24161

Now check the memory inside your guest..

This is how virtio_ballon or balloon drivers work!

I hope you enjoyed this article. Please feel free to ask your questions here or leave a comment.

KVM "cpu0 unimplemented perfctr wrmsr: 0x186 data 0x130079" messages are seen in logs

Usally I look into /var/log/messages file for troubleshooting issues and I have noticed below messages in my fedora 14 system logs. I was discarding it as I know it is harmless, but today I thought of blogging it because so many are worried about it. These messages can be ignored. These messages are spit to …

Read more

What are jiffies/jiffies_64

First of all, jiffies are supposed to be the counter of ticks happened from system boot. In kernel space,  jiffies are designed as a global variable. The “64” bit version of “jiffies” can be called as jiffies_64. jiffies are designed to be a 32 bit value where jiffies_64 is a 64 bit variant of the …

Read more