1. qemu的history

QEMU was originally written by Fabrice Bellard as a very general emulator based on binary-translation. In 2008, Avi Kivity introduced the kvm module in Linux and forked the project into qemu-kvm to use the new API. The KVM support was later backported into the original QEMU, where we can find it today.

2. qemu的作用

对于内核开发人员来说,qemu有两个用处:

  1. qemu+gdb调试linux kernel
  2. 由于qemu模拟了大量的设备与架构,因此,阅读qemu源码过程中,可以加深对设备与架构的理解

3. qemu的编译

编译之前,请安装好如下软件:

1
sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev -y
1
2
3
4
5
6
7
git clone -b stable-4.0 https://github.com/qemu/qemu.git

mkdir build
cd build
../configure --enable-kvm
make
make install

根据需要,可以disable kvm支持。

1
./configure --disable-kvm

4. qemu启动选项

qemu启动选项可以查询QEMU version 4.1.0 User Documentation或者qemu-system-x86_64 --help


参考资料:

  1. Passthrough in QEMU/KVM on Linux
  2. QEMU version 4.1.0 User Documentation