Re: [RFC] Unify KVM kernel-space and user-space code into a single project

Avi Kivity
2010-03-18T14:38:21Z

On 03/18/2010 04:09 PM, Ingo Molnar wrote:
> * Avi Kivity<avi@redhat.com> wrote:
>
>
>>> That is not what i said. I said they are closely related, and where
>>> technologies are closely related, project proximity turns into project
>>> unification at a certain stage.
>>>
>> I really don't see how. So what if both qemu and kvm implement an i8254?
>> They can't share any code since the internal APIs are so different. [...]
>>
> I wouldnt jump to assumptions there. perf shares some facilities with the
> kernel on the source code level - they can be built both in the kernel and in
> user-space.
>
> But my main thought wasnt even to actually share the implementation - but to
> actually synchronize when a piece of device emulation moves into the kernel.
> It is arguably bad for performance in most cases when Qemu handles a given
> device - so all the common devices should be kernel accelerated.
>
> The version and testing matrix would be simplified significantly as well: as
> kernel and qemu goes hand in hand, they are always on the same version.
>

So, you propose to allow running tools/kvm/ only on the kernel it was
shipped with?

Otherwise the testing matrix isn't simplified.

>> [...] Even worse for the x86 emulator as qemu and kvm are fundamentally
>> different.
>>
> So is it your argument that the difference and the duplication in x86
> instruction emulation is a good thing?

Of course it isn't a good thing, but it is unavoidable. Qemu compiles
code just-in-time to avoid interpretation overhead, while kvm emulates
one instruction at a time. No caching is possible, especially with
ept/npt, since the guest is free to manipulate memory with no
notification to the host. Qemu also supports the full instruction set
while kvm only implements what is necessary. Qemu is a
multi-source/multi-target translator while kvm's emulator is x86 specific.

> You said it some time ago that
> the kvm x86 emulator was very messy and you wish it was cleaner.
>

It's still messy but is being cleaned up.

> While qemu's is indeed rather different (it's partly a translator/JIT), i'm
> sure the decoder logic could be shared - and qemu has a slow-path
> full-emulation fallback in any case, which is similar to what in-kernel
> emulator does (IIRC ...).
>
> That might have changed meanwhile.
>

IIUC it only ever translates.

--
error compiling committee.c: too many arguments to function