17

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.

2
  • 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.
    – ssice
    Jan 27, 2013 at 0:08
  • 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).
    – Cashew
    Aug 27, 2014 at 16:19

2 Answers 2

29

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.

4
  • Thank you! On my ThinkPad, I enabled specifically "Intel Virtualization Technology" under Security.
    – Rasmus
    Aug 25, 2021 at 18:49
  • 2
    To verify, you can check dmesg | grep kvm. It will say kvm: disabled by bios if the setting is disabled.
    – SaeX
    Jan 9 at 20:57
  • Thanks for the idea. I need to enable the "Intel Virtualization Technology" Under CPU section. After enabled, one should see vcpu0.
    – g5thomas
    Feb 6 at 2:52
  • 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.
    – MikeKulls
    Sep 10 at 23:21
13

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.

5
  • 4
    I've already tried that, then it just says the same thing except operation not supported. Jan 26, 2013 at 23:46
  • 3
    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.
    – ssice
    Jan 26, 2013 at 23:50
  • 1
    There isn't any output so I guess I won't be able to use kvm, thanks for your help though. Jan 27, 2013 at 0:02
  • 1
    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!
    – ssice
    Jan 27, 2013 at 0:07
  • Can anyone help me do this on a machine with an AMD CPU? I'm running Linux Mint 17.1.
    – PrinceTyke
    Sep 11, 2015 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.