[libvirt] [PATCH 0/5] qemu: Detect KVM usability correctly

Jiri Denemark jdenemar at redhat.com
Fri Sep 14 14:35:08 UTC 2018


On Fri, Sep 14, 2018 at 15:36:42 +0200, Andrea Bolognani wrote:
> On Fri, 2018-09-14 at 15:01 +0200, Jiri Denemark wrote:
> > On Fri, Sep 14, 2018 at 10:35:58 +0200, Andrea Bolognani wrote:
> > > There are a few cases in which we're not reporting the correct
> > > information through 'virsh capabilities', leading to applications
> > > such as libguestfs attempting to launch KVM guests on a host that
> > > doesn't actually support them.
> > > 
> > > Our code is also more complicated than it needs to be due to
> > > backwards compatibilty reasons that we no longer care about these
> > > days, so we can perform some cleanup there; there are further
> > > cleanup opportunities in the same area, but some of them are a
> > > bit tricky so I'll leave them for a follow-up series.
> > > 
> > > We also get some extra test coverage pretty much for free. Yay!
> > 
> > So this makes things cleaner and fixes KVM reporting in capabilities.
> > 
> > But we also check /dev/kvm in virQEMUCapsIsValid. Which means we may
> > reprobe QEMU everytime in case the kvm module is not loaded (but
> > /dev/kvm exists)
> 
> We can try poking harder at /dev/kvm, eg. open() it, run some
> ioctl()s on it or whatever is necessary to figure out whether the
> device is actually functional rather than just showing up.
> 
> However, that would mean duplicating some work that QEMU can
> already do for us, so I'm not too fond of it. It also feels a bit
> too ad-hoc.

I don't know. I think we can keep the code as is for now since this
series does not make it any worse :-)

> How ridiculous would it be to invalidate capabilities whenever
> the daemon is restarted? That might strike a somewhat reasonable
> balance between requiring the admin to delete a bunch of internal
> files after configuring the system to load the KVM module and
> re-probing QEMU all the time.

This would effectively revert the addition of on-disk cache, which was
introduced with a very good reason. Starting libvirtd with a lot of QEMU
binaries would take a very long time without the persistent cache. Also
libguestfs running libvirt in session mode would get crazy about it. In
other words, invalidating capabilities cache whenever libvirtd is
started is not acceptable.

> > and we will never catch the case when kvm module was
> > loaded originally, but the admin unloads it while libvirtd is running.
> > Although this series doesn't make it any worse.
> 
> Is there a concrete use case for that? It doesn't look like a
> situation that we should really concern ourselves with.
> 
> > >   qemu: Drop QEMU_CAPS_ENABLE_KVM
> > 
> > After removing this capability it looks like virQEMUCapsIsValid will
> > always invalidate every single non-native QEMU binary since kvm could
> > not clearly be used when probing and /dev/kvm is present. Shouldn't we
> > add a check which makes sure we don't go this far for non-native
> > binaries?
> 
> We can use virQEMUCapsGuestIsNative() and skip all KVM-related
> checks for non-native binaries. Does that sound okay?

Yeah, I think that should work.

Jirka




More information about the libvir-list mailing list