1 Install

To begin with, I picked core as Cortex-A9 implementing ARMv7-A architecture, and for that I will use vexpress-a9 qemu machine. This must match corresponding debian installer files from armhf build.

mkdir Debian-armhf ; cd Debian-armhf
wget http://ftp.debian.org/debian/dists/wheezy/main/installer-armhf/current/images/vexpress/netboot/vmlinuz-3.2.0-4-vexpress
wget http://ftp.debian.org/debian/dists/wheezy/main/installer-armhf/current/images/vexpress/netboot/initrd.gz

The ARMv7-A architecture as at the moment of writing is popular on many mobile devices and present on popular Rasperry Pi 2 model. Hardware implementing this architecture, includes floating point unit (FPU). To take advantage of FPU, armhf build can be used. The older architectures such as ARMv4 lack FPU, and are required to run armel build which does all floating point operations in software compatibility mode. Code compiled for armel is generally slower, but can run on hardware without FPU.

To hold Debian installation image, I use qcow2 format, which is only specific to qemu. In this format the file takes only as much space as required by installed software on the file systems not supporting spares files.

qemu-img create -f qcow2 debian.img 1G

To boot the system with vexpress-a9 kernel and start installer in qemu I used

qemu-system-arm -m 1024M -sd debian.img \
-M vexpress-a9 -cpu cortex-a9 \
-kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.gz \
-append "root=/dev/ram" -no-reboot

In order to boot Jessie or any newer Debian installer which is most likely using multi-arch kernel and device tree files (dtb), the following can be used with files from netboot and dtb

qemu-system-arm -m 1024M -sd debian.img -M vexpress-a9 -dtb vexpress-v2p-ca9.dtb -cpu cortex-a9 \
-kernel vmlinuz -initrd initrd.gz \
-append "root=/dev/ram console=ttyAMA0 earlycon" -no-reboot -nographic

Initial initrd contanis Debian installer, so the one installed into the image is needed to boot the machine.

modprobe nbd max_part=16
qemu-nbd -c /dev/nbd0 Debian-armhf/debian.img
partprobe /dev/nbd0
mount /dev/nbd0p1 /mnt/
cp /mnt/boot/initrd.img-3.2.0-4-vexpress Debian-armhf/
cp /mnt/boot/vmlinuz-3.2.0-4-vexpress Debian-armhf/
umount /mnt

2 Booting the VM with ssh

Since the VM is installed on mmcblk0p1, I used that to boot the VM with the copied initrd.img-3.2.0-4-vexpress.

qemu-system-arm -m 1024M -sd debian.img -M vexpress-a9 -cpu cortex-a9 \
 -kernel vmlinuz-3.2.0-4-vexpress -initrd initrd.img-3.2.0-4-vexpress \
 -append "root=/dev/mmcblk0p1" -no-reboot -redir tcp:5555::22

Network connection should be handled by qemu automatically, however extra option redir must be used to redirect VM's 22 port to host 5555 port for ssh connection. This also assumes that the ssh server is installed on the VM side.