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 libsdl2-dev -y
1
sudo apt-get install git libfdt-dev libpixman-1-dev libssl-dev vim socat libsdl1.2-dev libspice-server-dev xtightvncviewer tightvncserver x11vnc uuid-runtime uuid uml-utilities bridge-utils python-dev liblzma-dev libc6-dev libegl1-mesa-dev libepoxy-dev libdrm-dev libgbm-dev libaio-dev libusb-1.0.0-dev libgtk-3-dev gettext -y

ubuntu2004.docker

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