Skip to content

Instantly share code, notes, and snippets.

./build-x86-64/x86_64-softmmu/qemu-system-x86_64 -nographic -nodefaults -L . -net none -machine virt,accel=kvm,kernel_irqchip,nofw -cpu host -m 512 -smp 2 -kernel /home/samuel/devlp/kernels/nfc/arch/x86/boot/compressed/vmlinux.bin -append 'data=ordered rcupdate.rcu_expedited=1 pci=lastbus=0 tsc=reliable no_timer_check reboot=t noapictimer console=ttyS0' -device sysbus-debugcon,iobase=0x3f8,chardev=debugcon -chardev stdio,id=debugcon -monitor telnet:127.0.0.1:55555,server,nowait
[ 0.000000] Linux version 4.9.34-75.container+ (samuel@caravaggio) (gcc version 8.1.1 20180502 (Red Hat 8.1.1-1) (GCC) ) #162 SMP Mon Jul 9 17:47:57 CEST 2018
[ 0.000000] Command line: data=ordered rcupdate.rcu_expedited=1 pci=lastbus=0 tsc=reliable no_timer_check reboot=t noapictimer console=ttyS0
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x008: 'MPX bounds registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x010: 'MPX CSR'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
@sameo
sameo / qboot.md
Last active October 15, 2021 00:59

Description

qboot is a simple x86 firmware that can boot Linux.

It is Paolo Bonzini's answer to the Clear Containers claim that QEMU takes too long to boot a Linux kernel.

qboot only works as a QEMU firmware as it's bound to QEMU's fw_cfg NVRAM firmware configuration device emulation mode.

Code flow

In vl.c:main():

    if (qemu_opts_foreach(qemu_find_opts("device"),
                          device_init_func, NULL, NULL)) {
        exit(1);
    }

crosvm device model

crosvm boots with PCI and ACPI off. It uses MMIO as a virtio registering method for a few devices and emulates a few more PIO devices:

MMIO configured devices

At boot time, crosvm unconditionally registers 2 virtio MMIO devices:

  • VIRTIO_ID_RNG
~/devlp/crosvm/target/debug/crosvm stop /run/user/1000/crosvm.sock
rm -f /run/user/1000/crosvm.sock && cargo build && ./target/debug/crosvm run --disable-sandbox -s /run/user/1000/crosvm.sock  ~/devlp/kernels/nfc/arch/x86/boot/compressed/vmlinux.bin

Q: vhost and kernel driver/device binding? Q: vhost virtqueue

Containerd runtimes

A runtime in containerd does not stand at the runc level, but at the platform one. There are separate Linux and Windows runtimes, and they register as plugins:

const (
	runtimeName    = "linux"
	configFilename = "config.json"

virtio is a kernel virtual bus. From drivers/virtio/virtio.c:

static struct bus_type virtio_bus = {
	.name  = "virtio",
	.match = virtio_dev_match,
	.dev_groups = virtio_dev_groups,
	.uevent = virtio_uevent,
	.probe = virtio_dev_probe,
	.remove = virtio_dev_remove,