LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   Load kvm module on boot in RHEL6 not working (https://www.linuxquestions.org/questions/linux-enterprise-47/load-kvm-module-on-boot-in-rhel6-not-working-4175548476/)

JockVSJock 07-20-2015 05:36 PM

Load kvm module on boot in RHEL6 not working
 
Trying to load kvm module under RHEL6 from the following:

Code:


/etc/sysconfig/modules/kvm2.modules

Here is the code for kvm2.modules

Code:

#!/bin/sh

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

kvm module fails to load after a reboot. Also I'm basically copying what I see from other files in this directory. I'm not even sure what -ne 0 does, is that part o grep?

berndbausch 07-20-2015 10:58 PM

Quote:

Originally Posted by JockVSJock (Post 5394038)
Trying to load kvm module under RHEL6 from the following:

Code:


/etc/sysconfig/modules/kvm2.modules

Here is the code for kvm2.modules

Code:

#!/bin/sh

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

kvm module fails to load after a reboot. Also I'm basically copying what I see from other files in this directory. I'm not even sure what -ne 0 does, is that part o grep?

grep -c produces a count of matching lines. If that is not zero, grep found something.

Now, I don't know of a CPU flag named kvm, and your kvm2.modules file looks wrong. On my Centos 6.6, I have a kvm.modules file that looks like this:
Code:

#!/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
modprobe -b vhost_net >/dev/null 2>&1
exit 0

That is, if the CPU has the vmx flag, it's an Intel CPU with virtualization extentions, therefore kvm-intel will be loaded. If it has the svm flag, it's an AMD CPU.

EDIT: Of course, the grep doesn't necessarily look for a CPU flag. However, that is obviously the intention in the correct kvm.modules.

JockVSJock 07-21-2015 06:11 AM

I have a kvm file under /etc/sysconfig/modules, however its not loading the basic kvm module.

Code:


[root@ApacheFTP modules]# cat 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

modprobe -b vhost_net >/dev/null 2>&1

exit 0

That is why I created a new .module file under this directory, to try and load this module.

Side note, I can't even load kvm_intel without error popping up as well.

Code:


[root@ApacheFTP modules]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                2
On-line CPU(s) list:  0,1
Thread(s) per core:    1
Core(s) per socket:    2
Socket(s):            1
NUMA node(s):          1
Vendor ID:            GenuineIntel
CPU family:            6
Model:                58
Stepping:              9
CPU MHz:              2394.560
BogoMIPS:              4789.12
Hypervisor vendor:    KVM
Virtualization type:  full
L1d cache:            32K
L1i cache:            32K
L2 cache:              256K
L3 cache:              6144K
NUMA node0 CPU(s):    0,1
[root@ApacheFTP modules]# modprobe kvm_intel
FATAL: Error inserting kvm_intel (/lib/modules/2.6.32-431.el6.x86_64/kernel/arch/x86/kvm/kvm-intel.ko): Operation not supported
[root@ApacheFTP modules]#


berndbausch 07-21-2015 07:18 AM

Code:

Hypervisor vendor:    KVM
Virtualization type:  full

This probably means that your system is a virtual machine. The CPU is a virtual CPU and has no virtualization extensions. That's why kvm.modules doesn't load kvm-intel or kvm-amd, and that's also why you get an error trying to insert the kvm-intel module.

You can't run KVM on a CPU without virtualization extensions. It follows that you can't run KVM in a virtual machine.

JockVSJock 07-21-2015 09:25 AM

I'll have to read up on this, however I will mark this thread as Solved.


All times are GMT -5. The time now is 08:59 AM.