QEMU/KVM architecture overview¶
it’s a note of “KVM Arch” slide in 2015 KVM forum
[2015] KVM Architecture Overview
old version, QEMU Code Overview
with some source code hint
Qemu process model (Qemu and Guest OS)¶
linux userspace process: process memory = qemu memory + guest OS physical memory
each KVM vCPU is a thread.
Host kernel scheduler decides when vCPUs run
Event-driven multi-threaded¶
event loop used for timer, fd, monitoring … etc
non-blocking IO
callback or coroutines
multi-thread architecture but with big lock
vcpu threads execute in parallel
specific task runs in other threads: RAM live migration, remote displaying encoding, virtio-blk dataplane
global mutex
see QEMU thread and event model for detail
host/guest device emulation split¶
guest device: device model visible to guest
host device: performs IO on behalf of guest
use QEMU CLI option as example.
There are 2 parts to networking in QEMU
virtual network device:
-device <device>,netdev=<id>
network backend:
-netdev <backend>,id=<id>
2 examples
# guest device=e1000 & host device=user (user network/slirp) -netdev user,id=net0 \ -device e1000,netdev=net0 # guest device=virtio-net & host device=user -netdev user,id=net0 \ -device virtio-net-pci,netdev=net0
virtio devices¶
KVM implements virtio device models
Red Hat contributes to Linux and Windows guestdrivers
see Virtio for detail
vhost in-kernel devices¶
vhost drivers emulate virtio devices in host kernel for better performance
vhost_net.ko: high-performance virtio-net emulation, kernel-only zero-copy and interrupt handling features.
Qemu