Begginner's Guide to Setting up QEMU Devel Env

Example: test io_uring.c in QEMU

Environment: Fedora 35

It requires a host[1] os having a new kernel, QEMU and liburing.git(one specific version).

build the kernel from source:

various mistakes can arrive when installing new kernel from source. However, there are certain steps requiring more attention.

When I found a seemly good tutorial and tried it: Read error message to know which type of error and google it.

  1. security check in config file(this part is literally killing me :): you can disable security check by modifying config file.

    If you meet a SSL error when make modules_install like me after disabling the security check above and discover that sign file missing, you may check CONFIG_SYSTEM_TRUSTED_KEYS='certs/signing_key.pem' and remake again.

  2. Orders of make commands:

    1
    2
    3
    4
    5
    6
    7
    make menuconfig
    make -j 8
    make modules
    make bzImage
    sudo make modules_install
    sudo make install
    sudo kernel-install add <version> /boot/vmlinuz-<version> # Fedora linux

build QEMU from source: Follow the documentation

build liburing from source: After this step, liburing support can be found in config with version 2.2 and QEMU should run correctly.

  1. check a few things before make install:

    • right kernel version: uname -ra -> 5.17-rc7

    • No liburing package(liburing and liburing-devel) installed

  2. Orders of commands: configure it first

    after fetching liburing.git:

    1
    2
    ./configure --libdir=/usr/lib64 --libdevdir=/usr/lib64  # /usr/lib for Ubuntu Linux
    make && sudo make install

It should work by now.

Qemu:

it is better to know common commands to trace, debug, test.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# default setting:
x86_64-softmmu/qemu-system-x86_64 -m 512 --enable-kvm

# create img:
./qemu-img create -f qcow2 test.qcow2 16G
./qemu-img create test.img 2G

# add test
path/to/qemu-system-x86_64 -m 1024 -enable-kvm -drive if=virtio,file=path/to/test.img,format=raw,aio=io_uring,cache=none

# trace
# want to trace: ioq_*, luring_*, qemu_luring_* and write into txt files.
./configure --target-list=x86_64-softmmu --enable-kvm --enable-debug --enable-trace-backends=simple
# in qemu dir:
path/to/qemu-system-x86_64 -m 1024 -enable-kvm -drive if=virtio,file=path/to/test.img,format=raw,aio=io_uring,cache=none --trace events=reach.txt
# gdb
gdb -q --args path/to/qemu-system-x86_64 -drive file=test.img,if=virtio,aio=io_uring --enable-kvm -smp 2 -m 1G

Err log:

I have met a lot of issues[2] when setting up the enviroument. Luckily, mentors of QEMU are very good and patient to go through this with me.


  1. it should be noticed that the host and guest in QEMU stand for. QEMU host is where QEMU runs and guest is to run on QEMU. In QEMU’s term, “–enable-kvm” ensures QEMU is running on the host and “-kernel” implies a guest os running. ↩︎

  2. Attach a log here. I will reorganize it when outreachy application term finishes. ↩︎