qemu KVM kernel module no such file or directory
Asked Answered
S

2

18

I am currently taking an operating systems class and I need to use qemu to run a small operating system that my professor provided. I am trying to use qemu within an ubuntu 12.04 virtual machine on virtualbox on my macbook air 5.2. I know the problems I am having probably have to do with nested virtualization but the specific error I get when I try to run qemu is:

Could not access the KVM kernel module: No such file or directory

failed to initialize KVM: no such file or directory Back to tcg accelerator.

qemu does start up the os but the window flickers quite a lot and I would like to fix the KVM problem if possible. I've done research but I can't find a solution I can understand or that works so any help would be greatly appreciated.

Also for the ubuntu virtual machine in virtualbox I have both Enable VT-x/AMD-V and Enable Nested Paging checked under Hardware Virtualization. I've also tried using

modprobe kvm-intel

and I get this error:

FATAL: Error inserting kvm_intel (/lib/modules.3.5.0-22-generic/kernel/arch/x86/kvm/kvm-intel.ko): Operation not permitted.

Sukey answered 26/1, 2013 at 23:40 Comment(2)
This question would be more generic if it read 'Can I nest virtualization in a way that it supports qemu KVM?' or something like that, and not regarding your specific case. Remember, StackOverflow is more of a place for questions that may happen to anyone, not to you specifically.Fabio
just for reference, the errors Could not access the KVM kernel module: No such file or directory failed to initialize KVM: no such file or directory Back to tcg accelerator. are not unique to nested virtualization issues. I ran qemu on Ubuntu Precise (without virtualization) and it returned the same error (but then it continued and worked).Towline
F
14

Try with sudo modprobe kvm-intel.

In order to have the module automatically loaded at the startup of the virtual machine, you can edit the file with any editor that allows you to edit files as root. You can use sudoedit, vscode, sudo -e or any other editor.

To keep the instructions straightforward, the following will work:

  1. Edit the corresponding file from the shell with sudo vi /etc/modules.conf
  2. Possibly enter your username password.
  3. Press the key G to go to the end of the document and then o to begin inserting.
  4. Write kvm-intel and press Enter, producing a new line.
  5. Press Esc to return to the Normal mode of vim. "--INSERT--" will disappear from the bottom.
  6. Save the file and exit vim by writing :wq.

You are done. Try to reboot and load the nested virtual machine.

Fabio answered 26/1, 2013 at 23:43 Comment(5)
I've already tried that, then it just says the same thing except operation not supported.Sukey
Operation not supported may mean that you can't actually do virtualization. Make sure your environment supports kvm by trying this command: egrep '^flags.*(vmx|svm)' /proc/cpuinfo. If there's no output, your virtual machine can't use KVM. Most probably nested virtualization isn't supported in KVM.Fabio
There isn't any output so I guess I won't be able to use kvm, thanks for your help though.Sukey
No problem. It seems that you can't actually use processor's Ring-0 even with VT-X. So, you'll need to go to your host OS to virtualize your professor's machine if you want it to have native performance. Or use an Ubuntu LiveCD instead of Ubuntu inside a VM. Or install it in a pendrive. There are lots of alternatives!Fabio
Can anyone help me do this on a machine with an AMD CPU? I'm running Linux Mint 17.1.Blankbook
W
30

In my case, the virtualization was disabled.

So sudo modprobe kvm-intel kept giving me the following error

could not insert 'kvm_intel': Operation not supported

I just had to go in the BIOS and enable Virtualization.

Warrigal answered 20/4, 2018 at 8:52 Comment(4)
Thank you! On my ThinkPad, I enabled specifically "Intel Virtualization Technology" under Security.Ssr
To verify, you can check dmesg | grep kvm. It will say kvm: disabled by bios if the setting is disabled.Instrumental
Thanks for the idea. I need to enable the "Intel Virtualization Technology" Under CPU section. After enabled, one should see vcpu0.Blob
In my case I had nested KVMs and it was turned off in the VM definition. Maybe this part <model fallback='forbid'>qemu64</model>. It can be changed by running virsh edit <vmname> and deleting that line. The VM needs to be restarted after making the change.Polymerization
F
14

Try with sudo modprobe kvm-intel.

In order to have the module automatically loaded at the startup of the virtual machine, you can edit the file with any editor that allows you to edit files as root. You can use sudoedit, vscode, sudo -e or any other editor.

To keep the instructions straightforward, the following will work:

  1. Edit the corresponding file from the shell with sudo vi /etc/modules.conf
  2. Possibly enter your username password.
  3. Press the key G to go to the end of the document and then o to begin inserting.
  4. Write kvm-intel and press Enter, producing a new line.
  5. Press Esc to return to the Normal mode of vim. "--INSERT--" will disappear from the bottom.
  6. Save the file and exit vim by writing :wq.

You are done. Try to reboot and load the nested virtual machine.

Fabio answered 26/1, 2013 at 23:43 Comment(5)
I've already tried that, then it just says the same thing except operation not supported.Sukey
Operation not supported may mean that you can't actually do virtualization. Make sure your environment supports kvm by trying this command: egrep '^flags.*(vmx|svm)' /proc/cpuinfo. If there's no output, your virtual machine can't use KVM. Most probably nested virtualization isn't supported in KVM.Fabio
There isn't any output so I guess I won't be able to use kvm, thanks for your help though.Sukey
No problem. It seems that you can't actually use processor's Ring-0 even with VT-X. So, you'll need to go to your host OS to virtualize your professor's machine if you want it to have native performance. Or use an Ubuntu LiveCD instead of Ubuntu inside a VM. Or install it in a pendrive. There are lots of alternatives!Fabio
Can anyone help me do this on a machine with an AMD CPU? I'm running Linux Mint 17.1.Blankbook

© 2022 - 2024 — McMap. All rights reserved.