I have been observing strange OpenWrt behaviors on QEMU q35
machine. The command to boot is nothing unusual except from virtio devices plugged into PCI Express ports to improve performance, and serial output (no GPU emulation). The images I use:
- openwrt-21.02.2-x86-64-generic-ext4-combined.img
- openwrt-21.02.2-x86-64-generic-ext4-combined-efi.img
First problem: the minimum memory required to boot is 132MiB (qemu-system-x86_64 -m 132M
) on UEFI, and 39MiB on legacy. If I boot it with 131MiB (or 38MiB on legacy), once I get past the GRUB boot menu, I get error: out of memory
and the system reboots.
Second problem: the memory reported by OpenWrt is always lower than what QEMU assigns to it.
- I assigned 132MiB on UEFI, and
free
reported 103MiB (104,988KiB) total memory. Everything ran fine even after I used a balloon device to steal 55MiB from OpenWrt to return to the host. The balloon device complained if I tried to steal 60MiB, which I thought should be fine to leave OpenWrt with ~43MiB of RAM. - I assigned 39MiB on legacy, which was the minimum to boot. Kernel panic happened a lot during boot due to low memory. Once booted into BusyBox, it ran very slowly and
free
reported 17MiB (17,704KiB) total memory.
Can someone explain these strange behaviors?
P.S: Why UEFI and legacy have different memory requirements and why is 131MiB not enough to boot OpenWrt?