Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KVM-QEMU and Virtualbox - concurrent use of svm not possible
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
ipic
Apprentice
Apprentice


Joined: 29 Dec 2003
Posts: 238
Location: UK

PostPosted: Wed Feb 12, 2020 5:30 pm    Post subject: KVM-QEMU and Virtualbox - concurrent use of svm not possible Reply with quote

I have been using Virtualbox for several years now. I would like to move to KVM/QEMU. I am new to this, so apologies if this is a dumb topic or has been covered before.

There is a very old internet article about KVM and Virtualbox not co-existing due to kernel module clashes. However, in articles that talk about migrating Virtualbox to KVM there are also articles that say that the two can co-exist. Ideally I would like to convert one of my VMs at a time (I have four on the same machine), so this would be useful.

I followed the Gentoo wiki article https://wiki.gentoo.org/wiki/QEMU

I installed app-emulation/virt-manager, added my user to groups kvm, quem and libvirt, edited /etc/libvirt/libvirtd.conf as suggested, and started up /etc/init.d/libvirtd

In dmesg I then saw:
Code:
[26598.924684] kvm: enabling virtualization on CPU0 failed
[26598.924689] kvm: enabling virtualization on CPU1 failed
[26598.924697] kvm: enabling virtualization on CPU2 failed
[26598.924707] kvm: enabling virtualization on CPU3 failed
.. repeated several times.

When I entered the "new VM" dialogue in virt-manager, it informed me that KVM was not active (and thus the new VM performance would be impacted).

From what I little I know to look for, I can see the following:
Code:

ian2 ~ # ls -lh /dev/kvm
crw-rw-rw-+ 1 root kvm 10, 232 Feb 12 09:04 /dev/kvm
ian2 ~ # lsmod | grep kvm
kvm_amd               102400  0
ccp                    77824  1 kvm_amd
ian2 ~ #


The kernel (gentoo-sources-5.5.3) is configured thus:
Code:
ian2 ~ # zcat /proc/config.gz | grep KVM
CONFIG_KVM_GUEST=y
# CONFIG_KVM_DEBUG_FS is not set
CONFIG_HAVE_KVM=y
CONFIG_HAVE_KVM_IRQCHIP=y
CONFIG_HAVE_KVM_IRQFD=y
CONFIG_HAVE_KVM_IRQ_ROUTING=y
CONFIG_HAVE_KVM_EVENTFD=y
CONFIG_KVM_MMIO=y
CONFIG_KVM_ASYNC_PF=y
CONFIG_HAVE_KVM_MSI=y
CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT=y
CONFIG_KVM_VFIO=y
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y
CONFIG_KVM_COMPAT=y
CONFIG_HAVE_KVM_IRQ_BYPASS=y
CONFIG_HAVE_KVM_NO_POLL=y
CONFIG_KVM=y
CONFIG_KVM_INTEL=m
CONFIG_KVM_AMD=m
CONFIG_KVM_AMD_SEV=y
CONFIG_PTP_1588_CLOCK_KVM=m
ian2 ~ #


For the running Virtualbox VMs the following modules are loaded:
Code:
ian2 ~ # lsmod | grep vbox
vboxnetadp             28672  0
vboxnetflt             32768  2
vboxdrv               430080  6 vboxnetadp,vboxnetflt
ian2 ~ #


My question is whether it is possible to run the two (KVM-QEMU and Virtualbox) together, and have both using the AMD svm capabilities?

If so, can someone give some hints for what to look for that I have done wrong?
Many thanks.


Last edited by ipic on Wed Feb 12, 2020 9:11 pm; edited 1 time in total
Back to top
View user's profile Send private message
dimko
Tux's lil' helper
Tux's lil' helper


Joined: 12 Feb 2006
Posts: 144

PostPosted: Wed Feb 12, 2020 7:25 pm    Post subject: nested, probably Reply with quote

I have been ironic, but i did run ESXI inside of KVM.

And to be less ironic, unload drivers from virtual box, try kvm again. If works - then incompatible. If not, you have not dug deep enough. You have not made your kvm workable.

try "qemu-system-x86_64 -enable-kvm", if window pops up under Xorg, and fails to load - you are on right path. Probably your install is viable and CPU assisted virtualisation works.
_________________
Just a user.


Last edited by dimko on Wed Feb 12, 2020 7:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 44945
Location: 56N 3W

PostPosted: Wed Feb 12, 2020 7:29 pm    Post subject: Reply with quote

ipic,

Works for me with both installed.
I have not run them both concurrently but I have both installed.

I use KVM/QEMU for something I want to keep around and Virtualbox for VMs that I intend to throw away, except they are mostly still around too. :)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
ipic
Apprentice
Apprentice


Joined: 29 Dec 2003
Posts: 238
Location: UK

PostPosted: Wed Feb 12, 2020 9:09 pm    Post subject: Re: nested, probably Reply with quote

dimko wrote:

try "qemu-system-x86_64 -enable-kvm", if window pops up under Xorg, and fails to load - you are on right path. Probably your install is viable and CPU assisted virtualisation works.


Thanks for that pointer. When I ran it with the vbox modules loaded I got this:
Code:
ipic@ian2 ~ $ qemu-system-x86_64 -enable-kvm
ioctl(KVM_CREATE_VM) failed: 16 Device or resource busy
qemu-system-x86_64: failed to initialize KVM: Device or resource busy


Which gives a pretty big hint what is going on :-)

So stopped all the vbox VMs, unloaded the modules, and tried again.
This time "qemu-system-x86_64 -enable-kvm" popped up a VM window, which tried its best to find something to load and stopped with "no boot media".

I thus think on my system it's conclusive, the two cannot use KVM at the same time.

I did run qemu while the vbox VMs were running, and it works, but it is so, so slow. Not really usable.

Thanks for the help guys - this is a steep learning curve :-)
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1710
Location: KUUSANKOSKI, Finland

PostPosted: Wed Feb 12, 2020 9:20 pm    Post subject: Reply with quote

This would explain why I cannot setup a vbox VM via virt-manager when I alrady have qemu/kvm VMs running...
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14971

PostPosted: Thu Feb 13, 2020 1:49 am    Post subject: Reply with quote

If I recall correctly, when kvm was much younger, the incompatibility was more severe. I seem to recall claims that the hardware tracking of virtualization state had no inherent locking, and trying to run both kvm and virtualbox at the same time would cause a fatal exception on the host. That has long since been improved, to produce the situation shown here. You can't use them in parallel, but you can't break your system by trying to use them in parallel.
Back to top
View user's profile Send private message
Zucca
Veteran
Veteran


Joined: 14 Jun 2007
Posts: 1710
Location: KUUSANKOSKI, Finland

PostPosted: Thu Feb 13, 2020 11:34 am    Post subject: Reply with quote

A quick chat on IRC with a guy who's managing remote vms by using virt-manager confirmed that it's technically impossible to run the two simultaneously.

I guess it would need a kernel level modification/patch to be able to share the resource with more than two kvm hypervisors.

Someone else with more such low level knowledge can correct me if I'm wrong. :?:
_________________
..: Zucca :..

Code:
ERROR: '--failure' is not an option. Aborting...
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14971

PostPosted: Fri Feb 14, 2020 1:50 am    Post subject: Reply with quote

That sounds right. The hardware cannot handle being shared, so you need the two software components that want to use the hardware to cooperatively share the hardware, such as by having one ask the other to relinquish it. I could also see an argument that this is solving the wrong problem, and that the right solution is to get all the userspace frontends to standardize on a single kernel module that operates the virtualization hardware, so that no hand-off is needed because the hardware is always managed by KVM, regardless of whether you use Qemu or VirtualBox for the user process portion.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum