Speed Up Your Kernel Development Cycle With QEMU
Speed Up Your Kernel Development Cycle With QEMU
Write code
Deploy
This
presentation
Network protocols
Networking Netfilter
OpenVSwitch
Resource Cgroups
management & Linux Security Modules
security Namespaces
Web Text
test.ko
R.I.P. browser editor
All My Work
Gone CRASH!
2015/09/01 Development machine
test.ko
Web Text
CRASH!
browser editor
Virtual machine
Development machine
8 KERNEL RECIPES 2015 | STEFAN HAJNOCZI
QEMU emulator and virtualizer
Website: http://qemu-project.org/
Runs on Linux, Mac, BSD, and Windows
Emulates 17 CPU architectures (x86, arm, ppc, ...)
Supports fast hardware virtualization using KVM
Open source GPLv2 license
qemusystemx86_64 m 1024 \
smp 2 \
enablekvm
qemusystemx86_64 enablekvm m 1024 \
kernel /boot/vmlinuz \
initrd /boot/initramfs.img \
append param1=value1
arch/x86_64/boot/bzImage busybox
qemusystemx86_64 … \
kernel vmlinuz \
initrd initramfs.img \
append param1=value1
16 KERNEL RECIPES 2015 | STEFAN HAJNOCZI
Building initramfs with gen_init_cpio
Two options:
1)Share directory with host using virtfs or NFS
Pro: Easy to manipulate and inspect on host
2)Use disk image file with partition table and file
systems
Pro: Easy to install full Linux distro
GDB stub
GDB
(client)
QEMU
24 KERNEL RECIPES 2015 | STEFAN HAJNOCZI
QEMU gdbstub example
qemusystemx86_64 s enablekvm m 1024 \
drive if=virtio,file=test.img
(gdb) set architecture i386:x8664
(gdb) file vmlinux
(gdb) target remote 127.0.0.1:1234
(gdb) backtrace
#0 native_safe_halt () at
./arch/x86/include/asm/irqflags.h:50
#1 0xffffffff8101efae in arch_safe_halt ()
...
pci-device
e1000-base
e1000-82540em
memory_region_init_io(&s>io, OBJECT(s),
&vmport_ops, s, "vmport", 1);
isa_register_ioport(isadev, &s>io, 0x5658);
30 KERNEL RECIPES 2015 | STEFAN HAJNOCZI
Interrupts
Simple scenarios:
● Test hot unplug while device is in use
(qemu) device_del e1000.0
Email: [email protected]
IRC: stefanha on #qemu irc.oftc.net
Blog: http://blog.vmsplice.net/
QEMU: http://qemu-project.org/