Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Running NEMU

Rob Bradford edited this page Jan 15, 2019 · 4 revisions

Compiling NEMU

The scripts tools/build_x86_64.sh and tools/build_x86_64_virt.sh provide a method for compiling NEMU with supported configure options. The former works builds a binary that has PC, Q35 and virt machine types. The latter builds a binary that only has the virt machine included.

Ubuntu Cloud (xenial & bionic)

Works with NEMU and virt machine type. However boot hangs unless "console=hvc0" appended to kernel command line:

 sudo guestmount -i -a ~/workloads/xenial-server-cloudimg-amd64-uefi1.img /mnt
 sudo sed -i "s/console=tty1 console=ttyS0/console=tty1 console=ttyS0 console=hvc0/" /mnt/boot/grub/grub.cfg
 sudo umount /mnt

No default credentials available for login so use cloud-init, sample files are provided in the repo:

dd if=/dev/zero of=/tmp/seed.img count=16 bs=1M
mkfs.vfat /tmp/seed.img  -n cidata
mcopy -oi /tmp/seed.img tools/CI/cloud-init/ubuntu/user-data ::
mcopy -oi /tmp/seed.img tools/CI/cloud-init/ubuntu/meta-data ::

Debian Cloud

The Debian cloud (openstack) images have not been tested with NEMU. But it should be possible to follow the instructions below for Red Hat distributions (using Seabios)

Fedora "Cloud-Base"/CentOS "GenericCloud"/RHEL "guest"

Tested with CentOS-7-x86_64-GenericCloud-1809.qcow2

Use our Seabios port to the virt machine type:

git clone https://github.com/rbradford/seabios
cd seabios
git checkout virt-x86
cp virt-x86.config .config
make
cp out/bios.bin $HOME/workloads/seabios.bin

And use the same cloud-init as Ubuntu:

dd if=/dev/zero of=/tmp/seed.img count=16 bs=1M
mkfs.vfat /tmp/seed.img  -n cidata
mcopy -oi /tmp/seed.img tools/CI/cloud-init/ubuntu/user-data ::
mcopy -oi /tmp/seed.img tools/CI/cloud-init/ubuntu/meta-data ::

Clear Linux Cloud

Works unmodified with NEMU and virt machine type. Need to use a cloud-init configuration in order to log in:

dd if=/dev/zero of=/tmp/seed.img count=16 bs=1M
mkfs.vfat /tmp/seed.img  -n config-2
mcopy -oi /tmp/seed.img -s tools/CI/cloud-init/clear/openstack ::

Launching NEMU

Helpful command line:

x86_64-softmmu/qemu-system-x86_64 -bios ~/workloads/OVMF.fd \
            -nographic -nodefaults -L . -net none \
            -machine virt,accel=kvm,kernel_irqchip \
            -cpu host -m 512,slots=4,maxmem=16950M \
            -smp 2 \
            -device sysbus-debugcon,iobase=0x402,chardev=debugcon \
            -chardev file,path=/tmp/debug-log,id=debugcon \
            -device sysbus-debugcon,iobase=0x3f8,chardev=serialcon \
            -chardev file,path=/tmp/serial-log,id=serialcon \
            -device virtio-blk-pci,drive=image \
            -drive if=none,id=image,file=/tmp/disk.img \
            -device virtio-blk-pci,drive=seed \
            -drive if=none,id=seed,file=/tmp/seed.img,format=raw \
            -device virtio-serial-pci,id=virtio-serial0 \
            -device virtconsole,chardev=charconsole0,id=console0 \
            -chardev stdio,id=charconsole0 \
            -netdev user,id=mynet0,hostfwd=tcp::2222-:22,hostname=nemuvm \
            -device virtio-net-pci,netdev=mynet0

Serial output to /tmp/serial-log, OVMF debug output to /tmp/debug-log. Can SSH in via 127.0.0.1:2222 and local login on stdio

cloud-init created credential is nemu/nemu123 with passwordless sudo.