Re: KVM & VMX root mode

Daniel P. Berrange
2007-09-03T03:14:03Z

On Sat, Sep 01, 2007 at 09:42:31PM +0300, Avi Kivity wrote:
> Sander van Leeuwen wrote:
> > Avi,
> >
> > I'd like to make clear that we are talking about the situation where
> > kvm is *not* being used by any application.
> >
> > It's my understanding that in some (many?) distributions kvm is
> > actually active on a permanent basis. I can't say whether this was done
> > by default or explicitly by the user. There is however no need to
> > activate vmx root mode when there is no client program that is using
> > the kvm extension.
> >
> > From your comments I understand that you enable vmx root mode when the
> > kvm module is loaded. Regardless of whether an application
> > actually wishes to use the kvm extension.
>
> Yes. The assumption is that if kvm is loaded, then there is an intent
> to use it. This is similar to an ethernet device being claimed by the
> driver that supports it, even if no application actually uses that
> network interface.
>
> We could change kvm to only claim vmx on first use, but that would
> reduce reliability.
>
> My position is that:
> - if you with to run something that conflicts with kvm enabling vmx, you
> should unload kvm, or not load it in the first place. This is not a
> difficult operation.
> - if you have an issue with distributions enabling kvm by default, then
> talk to these distributions. kvm itself does not enable vmx by default.

So with my distributor / maintainer hat on...

In Fedora we enable KVM kernel modules by default because upstream LKML has
decided that KVM is the standard for exposing hardware virt capabilities from
the kernel to userspace. Asking the user to choose which kernel modules they
load for virt is not really at all pratical because most users do not have
the neccessary knowledge to be able to make an informed decision on this
question. For this reason, in Fedora our general policy is to evaluate the
options provided in the /upstream/ kernel, identify the best driver for any
particular hardware capability & enable it by default. Thus KVM kernel mods
are enabled by default if you install the KVM userspace.

While one could in theory change KVM to only activate VMX when a guest is
started this wouldn't give a significant improvement to the user experiance.
Instead of being able to rely on KVM working, it now may or may not work
depending on whether you happen to have a VirtualBox guest running or not &
vica-verca. You still would not be able to run guests from both concurrently
which should surely be the real goal. The only way I see the latter being
achieved is if VirtualBox were to leverage the existing KVM kernel APIs to
access the underlying hardware virt capabilities.

Regards,
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|