mcpField
Q
qemu-for-kernel-development

qemu-for-kernel-development

github.com/mohitmishra786Development269331 installsUpdated 18w ago
Repository

About qemu-for-kernel-development

A skill for agents using QEMU to build, boot, and test custom kernels and drivers. It covers virtio devices, Buildroot or initramfs root filesystems, module test cycles, and kernel debugging, with workflows suited to kernel development.

Key features

  1. 01Booting custom kernels on QEMU
  2. 02Configuring virtio block and network
  3. 03Building root filesystems with Buildroot
  4. 04Testing out-of-tree kernel modules
  5. 05Kernel debugging with GDB

Use cases

  1. 01Testing kernel patches without bare metal
  2. 02Developing drivers for virtio or emulated platforms
  3. 03Running kernel boot smoke tests in CI
  4. 04Sharing host source trees with 9p

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mohitmishra786/low-level-dev-skills --skill qemu-for-kernel-development

After installing, type/qemu-for-kernel-developmentin Claude Code to confirm it loaded.

Details

From the project README

QEMU for Kernel Development

Purpose

Guide agents through QEMU-based kernel and driver development workflows: building/booting custom kernels, attaching virtio block/network, using Buildroot or minimal initramfs, and rapid module test cycles — focused on kernel dev vs general skills/virtualization/qemu-kvm.

When to Use

  • Test kernel patch without bare metal
  • Develop driver against virtio or emulated DT platform
  • CI kernel boot smoke test
  • NFS or 9p root for fast edit-compile-test

Workflow

1. Minimal direct kernel boot (arm64 virt)
qemu-system-aarch64 \
  -machine virt -cpu cortex-a57 -smp 4 -m 2G \
  -kernel arch/arm64/boot/Image \
  -append "console=ttyAMA0 root=/dev/vda rw" \
  -drive if=virtio,file=rootfs.ext4,format=raw \
  -netdev user,id=net0 -device virtio-net-device,netdev=net0 \
  -nographic

x86_64:

qemu-system-x86_64 -enable-kvm -m 4G -smp 4 \
  -kernel arch/x86/boot/bzImage \
  -append "console=ttyS0 root=/dev/vda rw" \
  -drive file=rootfs.img,format=raw,if=virtio \
  -nographic
2. Buildroot rootfs loop
cd buildroot
make qemu_aarch64_virt_defconfig
make
# output/images/Image, rootfs.ext4

Integrate custom kernel: set BR2_LINUX_KERNEL_CUSTOM_VERSION or external tree.

3. Out-of-tree module test
# on host — cross build
make -C $KERNEL_SRC M=$PWD modules
# in guest or via initramfs
insmod mydriver.ko
dmesg | tail

Share tree with 9p:

-fsdev local,id=dev,path=$PWD,security_model=none \
-device virtio-9p-pci,fsdev=dev,mount_tag=hostshare
# guest: mount -t 9p -o trans=virtio hostshare /mnt
4. GDB stub for kernel
qemu-system-aarch64 ... -s -S
gdb vmlinux
(gdb) target remote :1234
(gdb) break start_kernel

Use CONFIG_KGDB for live kernel debugging after boot.

5. Device tree overrides
qemu-system-aarch64 -machine virt -dtb myboard.dtb ...

virt machine provides virtio devices; platform drivers can target QEMU -device models.

6. Agent usage
/qemu-for-kernel-development Boot arm64 virt with custom Image and virtio rootfs for driver CI

Common Problems

SymptomCauseFix
Kernel panic no rootWrong root=root=/dev/vda for virtio blk
No console outputMissing console= on cmdlineconsole=ttyAMA0 / ttyS0
Module vermagic errorBuilt against wrong treeSame KERNEL_SRC as booted image
Slow without KVMTCG emulation-enable-kvm on x86 host
DTB mismatchWrong machineUse virt DTB from kernel make dtbs

Related Skills

  • skills/virtualization/qemu-kvm — KVM, VFIO, libvirt
  • skills/qemu/qemu-embedded-simulation — bare-metal MCU QEMU
  • skills/kernel/kernel-testing — KUnit, kselftest
  • skills/kernel-dev/device-tree — DT for virt/platform
  • skills/debuggers/gdb — remote GDB basics

Comments

Markdown supported