How KVM modules are automatically loaded at time of boot?

Quite often people ask this question to me, so I thought of mentioning it here in my blog.

There need to be two modules loaded in the system for KVM to operate properly . Those are “kvm” and “kvm-intel/kvm-amd” depend on system hardware. How-ever for lots of people it is still mystery how these modules are getting loaded at time of boot automatically.

It is achieved by “/etc/sysconfig/modules/kvm.modules” file in linux ( ex: Fedora, Red Hat Linux) system.

Lets look at contents of this file.

[root@humbles-lap ~]# cat /etc/sysconfig/modules/kvm.modules
#!/bin/sh

if [ $(grep -c vmx /proc/cpuinfo) -ne 0 ]; then
modprobe -b kvm-intel >/dev/null 2>&1
fi

if [ $(grep -c svm /proc/cpuinfo) -ne 0 ]; then
modprobe -b kvm-amd >/dev/null 2>&1
fi
[root@humbles-lap ~]#

As you can see above, it does have a check for CPU flag ( svm or vmx) in /proc/cpuinfo file.. As I mentioned in other blog “svm” stands for AMD and “vmx” stands for “INTEL” VT support. Afrer checking presence of this flag, it try to load ‘kvm-intel’ or ‘kvm-amd’ accordingly.

Lets meet in next blog..

Leave a Reply

Your email address will not be published. Required fields are marked *