I have been testing KVM extensively this week. Today I learned that KVM and Oracle VirtualBox doesn't work at the same time. Up until today, I haven't had a chance to use two virtualization applications at a time, so I am completely unaware of that KVM and virtualbox doesn't run simultaneously in Linux. When one of a KVM instance is running, I started a VM from VirtualBox, and it didn't start but showed a error box titled - Virtualbox Guru Meditation.
Please note that KVM and VirtualBox does work side by side without actually uninstalling anyone. However, I can't use them concurrently. This error is new to me, so I figured that posting this guide here will help someone.
KVM and VirtualBox doesn't work at the same time
Here is the full error message when I tried to start VM from oracle virtualbox when a KVM guest machine is already running:
Virtualbox Guru Meditation A critical error has occurred while running the virtual machine and the machine execution has been stopped. For help, please see the Community section on https://www.virtualbox.org or your support contract. Please provide the contents of the log file VBox.log and the image file VBox.png, which you can find in the /home/sk/VirtualBox VMs/Ubuntu 20.04 Server/Logs directory, as well as a description of what you were doing when this error happened. Note that you can also access the above files by selecting Show Log from the Machine menu of the main VirtualBox window. Press OK if you want to power off the machine or press Ignore if you want to leave it as is for debugging. Please note that debugging requires special knowledge and tools, so it is recommended to press OK now.
Then I stopped the KVM guest, closed the KVM application and started VM from virtualbox, it worked!
I also tried it in reverse. I started a VM from virtualbox and then started a KVM guest, but the KVM guest doesn't start.
Error starting domain: internal error: process exited while connecting to monitor: ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy 2020-07-08T11:28:43.524617Z qemu-system-x86_64: failed to initialize KVM: Device or resource busy Traceback (most recent call last): File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper callback(asyncjob, *args, **kwargs) File "/usr/share/virt-manager/virtManager/asyncjob.py", line 111, in tmpcb callback(*args, **kwargs) File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn ret = fn(self, *args, **kwargs) File "/usr/share/virt-manager/virtManager/object/domain.py", line 1279, in startup self._backend.create() File "/usr/lib/python3/dist-packages/libvirt.py", line 1234, in create if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self) libvirt.libvirtError: internal error: process exited while connecting to monitor: ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy 2020-07-08T11:28:43.524617Z qemu-system-x86_64: failed to initialize KVM: Device or resource busy
Then I stopped the VM and closed the Virtualbox application and started a KVM instance, it worked!
I even checked if kvm and vbox modules are running using "lsmod" command.
Find KVM modules with lsmod command:
$ sudo lsmod | grep kvm
Sample output:
kvm_intel 282624 0 kvm 663552 1 kvm_intel
Find virtualbox modules:
$ sudo lsmod | grep vbox
Sample output:
vboxnetadp 28672 0 vboxnetflt 28672 0 vboxdrv 487424 2 vboxnetadp,vboxnetflt
All modules are loaded.
After looking into the Virtualbox forum, I realized that this error occurs if we concurrently run multiple hypervisors at the same time on the same host.
So how to fix Virtualbox Guru Meditation error in Linux?
Actually, there is no FIX. You must use any one hypervisor at a time. Intel VT-x/AMD-V hardware virtualization extensions cannot be used from multiple different hypervisors running simultaneously on the same host. You should run only hypervisor on a single host. If you want to use another, close the currently running hypervisor and start the other one.
Another reason for virtualbox guru meditation is VT-x might be disabled in the BIOS. Make sure you have enabled it in your bios. Refer your system's manufacturer manual to enable VT in BIOS.
I can't use KVM and VirtualBox side by side
I don't have any issues with KVM and Virtualbox on my Ubuntu 20.04 system. I can be able to run both alongside each other.
Some of you might encounter with this error when running KVM and Virtualbox on the same host:
VERR_VMX_IN_VMX_ROOT_MODE
If you can't use Virtualbox alongside KVM, you can temporally disable kvm modules and then enable them when you want.
Unload the running KVM modules using command:
$ sudo rmmod kvm-intel
If it is AMD system, use this command instead:
$ sudo rmmod kvm-amd
Alternatively, you can use the following commands:
$ sudo modprobe -r kvm_intel
$ sudo modprobe -r kvm
On AMD:
$ sudo modprobe -r kvm_amd
$ sudo modprobe -r kvm
Now try to start Virtualbox VMs. It should should work now.
Enable KVM modules
To enable the KVM modules, you need to first find them where are they located in your disk. To do so, run:
$ sudo updatedb
$ sudo locate kvm
You should see an output like below.
/lib/modules/5.4.0-39-generic/kernel/arch/x86/kvm /lib/modules/5.4.0-39-generic/kernel/arch/x86/kvm/kvm-amd.ko /lib/modules/5.4.0-39-generic/kernel/arch/x86/kvm/kvm-intel.ko /lib/modules/5.4.0-39-generic/kernel/arch/x86/kvm/kvm.ko /lib/modules/5.4.0-39-generic/kernel/drivers/gpu/drm/i915/gvt/kvmgt.ko /lib/modules/5.4.0-39-generic/kernel/drivers/ptp/ptp_kvm.ko /lib/modules/5.4.0-40-generic/kernel/arch/x86/kvm /lib/modules/5.4.0-40-generic/kernel/arch/x86/kvm/kvm-amd.ko /lib/modules/5.4.0-40-generic/kernel/arch/x86/kvm/kvm-intel.ko [...]
Look for "kvm-intel.ko
" and "kvm.ko
" entries. Enable these two modules using commands:
$ sudo insmod /lib/modules/`uname -r`/kernel/arch/x86/kvm/kvm.ko
$ sudo insmod /lib/modules/`uname -r`/kernel/arch/x86/kvm/kvm-intel.ko
On AMD systems, replace "kvm-intel.ko
" with "kvm-amd.ko
".
You can now run KVM instances. Please remember virtualbox VMs will not start until you turn off all KVM instances.
Reference:
Related read:
1 comment
Thank you very much for sharing this!