Re: [PATCH 3/3] Add KVM support to QEMU

Avi Kivity
2008-11-04T13:24:53Z

Anthony Liguori wrote:
> This patch adds very basic KVM support. KVM is a kernel module for Linux that
> allows userspace programs to make use of hardware virtualization support. It
> current supports x86 hardware virtualization using Intel VT-x or AMD-V. It
> also supports IA64 VT-i, PPC 440, and S390.
>
> This patch only implements the bare minimum support to get a guest booting. It
> has very little impact the rest of QEMU and attempts to integrate nicely with
> the rest of QEMU.
>
> Even though this implementation is basic, it is significantly faster than TCG.
> Booting and shutting down a Linux guest:
>
> w/TCG: 1:32.36 elapsed 84% CPU
>
> w/KVM: 0:31.14 elapsed 59% CPU
>
> Right now, KVM is disabled by default and must be explicitly enabled with
> -enable-kvm. We can enable it by default later when we have had better
> testing.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>
> diff --git a/KVM_TODO b/KVM_TODO
> new file mode 100644
> index 0000000..9529049
> --- /dev/null
> +++ b/KVM_TODO
> @@ -0,0 +1,9 @@
> +1) Add hooks for load/save of register state
> + o Fixes gdbstub, save/restore, and vmport
> +2) Add VGA optimization
> +3) Add IO thread
> +4) Add guest SMP support
> +5) Add TPR optimization
> +6) Add support for in-kernel APIC
> +7) Add support for in-kernel PIT
> +8) Merge in additional changes in kvm-userspace tree
>

One of the important changes is running with signal delivery disabled,
since that's particularly slow (requires save/restore of the floating
point state, for example).

> +
> +typedef struct kvm_userspace_memory_region KVMSlot;
>

KVMMemorySlot?

> +
> +static KVMState *kvm_state;
>

Why a pointer?

> + if (ret < 0) {
> + dprintf("kvm_create_vcpu failed\n");
>

showing errno would be nice.

> +
> +static void kvm_getput_reg(__u64 *kvm_reg, target_ulong *qemu_reg, int set)
> +{
> + if (set)
> + *kvm_reg = *qemu_reg;
> + else
> + *qemu_reg = *kvm_reg;
> +}
>

Ugh.

I think live migration is now broken, since kvm accesses will not update
the qemu dirty bitmap.

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