1:下载最新的QEMU源码
git clone https://github.com/qemu/qemu.git
2:对qemu进行编译
./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --interp-prefix=/usr/qemu-%M --libexecdir=/usr/libexec --with-confsuffix=/qemu-kvm --localstatedir=/var '--extra-ldflags=-Wl,--build-id -pie -Wl,-z,relro -Wl,-z,now' '--extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIE -DPIE' --target-list=x86_64-softmmu --enable-rdma --enable-kvm --enable-numa --disable-sdl --disable-spice --disable-smartcard --enable-linux-aio --enable-debug --enable-debug-info
make install
3: 下载一个精简的image镜像
wget http://wiki.qemu.org/download/linux-0.2.img.bz2
4:写一个脚本开始调试qemu (写一个脚本:方便调试,将脚本放到qemu源码目录)
gdb -tui --args /opt/qemu/bin/qemu-system-x86_64 --enable-kvm -m 256 -L /usr/share/qemu-kvm/ -hda linux-0.2.img -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -vnc 0.0.0.0:0
5:处理信号异常
handle SIGUSR1 SIGUSR2 noprint nostop