Building Qemu

To develop the virtual device we will need to modify the Qemu virtual machine monitor, so a first step is to download its sources and make sure we can compile it.

Downloading and Extracting Qemu Sources

We will download Qemu from its official download page. Place yourself in the exercise base directory, and download the sources of Qemu version 8.2.0-rc2:

cd ~/virt-101-exercise
wget https://download.qemu.org/qemu-8.2.0-rc2.tar.xz

Extract the archive as follows:

tar xf qemu-8.2.0-rc2.tar.xz

Qemu's sources are now in the folder qemu-8.2.0-rc2.

Compiling Qemu

Place yourself into Qemu's source folder and prepare the build by calling the configure script:

cd qemu-8.2.0-rc2
./configure --prefix=$PWD/prefix --target-list=x86_64-softmmu

Launch the build and trigger the installation once done:

make -j4 install

This can take a bit of time depending on the processing power of your host.

Trying Out Qemu

Once the installation is done you can check that all went well by launching an empty virtual machine:

./prefix/bin/qemu-system-x86_64 -nographic

The -nographic option indicates that the VM will have serial console output only (and no graphical output), which simplifies a lot this exercise. You should see something like that:

# ...
Booting from Hard Disk...
Boot failed: could not read the boot disk

Booting from Floppy...
Boot failed: could not read the boot disk

Booting from DVD/CD...
Boot failed: Could not read from CDROM (code 0003)
# ...

What you see here is Qemu's virtual bootloader attempting to boot on a few virtual devices (hard disk, CD, etc.). Because there is nothing in there it fails to do so, this is normal.

To exit Qemu, press ctrl+a followed by x. Remember this shortcut, you will need to use it extensively in the rest of the exercise.

Qemu when exiting sometimes also interferes with the console which will lead to a messed up display when you type a command longer than a console line. If this happens simply runs this command to reset the console:

reset