Configure script: configure.sh
git clone https://github.com/intel/nemu
cd nemu
git checkout -b topic/virt-x86 origin/topic/virt-x86
mkdir build-x86-64
cd build-x86-64
./configure.sh
make -j `nproc`
We can test the NEMU virt machine type through either direct kernel boot (a.k.a. nofw
) or through a regular cloud or server image as long as it supports EFI boot.
I use the v4.9.34-75 branch from the Clear Containers kernel with a custom .config
See the busybox initramfs build instructions, and then configure the above kernel build to point to your local rootfs.
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
sudo /home/samuel/devlp/hypervisor/nemu/build-x86-64/x86_64-softmmu/qemu-system-x86_64 \
-nographic \
-nodefaults \
-L . \
-net none \
-machine virt,accel=kvm,kernel_irqchip,nofw \
-smp sockets=1,cpus=4,cores=2,maxcpus=8 -cpu host \
-m 1G,slots=3,maxmem=4G \
-kernel /home/samuel/devlp/kernels/nfc/arch/x86/boot/compressed/vmlinux.bin -append 'console=hvc0 single iommu=false root=/dev/ram0' \
-device virtio-serial-pci,id=virtio-serial0 -device virtconsole,chardev=charconsole0,id=console0 -chardev stdio,id=charconsole0 \
-monitor telnet:127.0.0.1:55555,server,nowait
Warning Most cloud or server images kernels do not have HW reduced ACPI enabled so they won't support CPU and memory hotplug with our HW reduced ACPI virt machine type.
We have tested the latest Clear Linux cloud image with our custom OVMF binary.
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
VMN=${VMN:=1}
sudo /home/samuel/devlp/hypervisor/nemu/build-x86-64/x86_64-softmmu/qemu-system-x86_64 \
-bios $HOME/devlp/hypervisor/nemu/clear-cloud/OVMF.fd \
-nographic \
-nodefaults \
-L . \
-machine virt,accel=kvm,kernel_irqchip \
-smp sockets=1,cpus=4,cores=2,maxcpus=8 -cpu host \
-m 512 \
-device sysbus-debugcon,iobase=0x402,chardev=debugcon -chardev file,path=/tmp/debug-log,id=debugcon \
-device virtio-blk-pci,drive=image -drive if=none,id=image,file=$HOME/devlp/hypervisor/nemu/clear-cloud/clear-cloud.img \
-device virtio-serial-pci,id=virtio-serial0 -device virtconsole,chardev=charconsole0,id=console0 -chardev stdio,id=charconsole0 \
-netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22,hostfwd=tcp::${VMN}2375-:2375 -device virtio-net-pci,netdev=mynet0 \
-monitor telnet:127.0.0.1:55555,server,nowait
Hotplug is done through the QEMU monitoring socket (-monitor telnet:127.0.0.1:55555,server,nowait
from the above command lines).
The socket is reachable through port 23 (telnet):
# telnet 127.0.0.1 55555
Plug
(qemu) device_add host-x86_64-cpu,id=core4,socket-id=1,core-id=1,thread-id=0
Unplug
(qemu) device_del core4
Plug
(qemu) object_add memory-backend-ram,id=mem1,size=1G
(qemu) device_add pc-dimm,id=dimm1,memdev=mem1
Unplug
(qemu) device_del dimm1