Skip to content

Instantly share code, notes, and snippets.

@rbradford
Last active September 25, 2018 06:33
Show Gist options
  • Save rbradford/b816fb153174fa2feff1edb3f92de2b7 to your computer and use it in GitHub Desktop.
Save rbradford/b816fb153174fa2feff1edb3f92de2b7 to your computer and use it in GitHub Desktop.

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 do not use EFI so are not able to boot against NEMU as it only supports EFI booting.

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

These images do not use EFI so are not able to boot against NEMU as it only supports EFI booting.

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.

@adofirst2018
Copy link

adofirst2018 commented Sep 25, 2018

I follow your guidance, but NEMU hang,not run Ubuntu cloud.
my OVMF.fd download from https://excellmedia.dl.sourceforge.net/project/toysbox/bios-efi_GrubRescue/OVMF.fd.
this is my command:
/home/duhy/workSpace/nemu/nemu/x86_64-softmmu/qemu-system-x86_64 -bios /home/duhy/workSpace/nemu/OVMF.fd
-nodefaults -L . -net none
-machine virt,accel=kvm,kernel_irqchip
-cpu host -m 512,slots=4,maxmem=4096M
-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=/home/duhy/workSpace/nemu/xenial-server-cloudimg-amd64-uefi1.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

nemu-vm

@adofirst2018
Copy link

this issue is solved, because my OVMF.fd is error.
Besides . what ubuntu cloud user and password, I try to login ubuntu cloud with user nemu password nemu123,but login incorrect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment