rumpkernel / rumprun

The Rumprun unikernel and toolchain for various platforms
Other
1.14k stars 128 forks source link

Unable to run the example kernel in qemu on FreeBSD #134

Open ctsrc opened 4 years ago

ctsrc commented 4 years ago

Hi, I followed the tutorial at https://github.com/rumpkernel/wiki/wiki/Tutorial%3A-Building-Rumprun-Unikernels and ran into a couple of problems.

My host system is running FreeBSD 12.1 on amd64, and I have qemu 4.2.1 installed on the system.

Thanks to the comments in #133 I was able to build all of the tools.

I proceeded to compile the example program from the tutorial and to bake it.

x86_64-rumprun-netbsd-gcc -o helloer-rumprun helloer.c

rumprun-bake hw_generic helloer-rumprun.bin helloer-rumprun

ls -al helloer-rumprun.bin

-rwxr-xr-x  1 user  user  29619640 Oct 10 18:19 helloer-rumprun.bin

But when I try to run it in qemu...

rumprun qemu -i helloer-rumprun.bin

...it loops at "Booting from ROM"

qemu

And initially I thought it might be a problem with just qemu. But I am able to run for example FreeBSD 12.1 inside of qemu, booting it from a qcow2 image.

fetch https://download.freebsd.org/ftp/releases/VM-IMAGES/12.1-RELEASE/amd64/Latest/FreeBSD-12.1-RELEASE-amd64.qcow2.xz

unxz FreeBSD-12.1-RELEASE-amd64.qcow2.xz

qemu-system-x86_64 -drive file=FreeBSD-12.1-RELEASE-amd64.qcow2,format=qcow2

What do I need to do in order to boot the rumprun kernel example from the tutorial in qemu?

For reference, here is the output of rumprun -D qemu -i helloer-rumprun.bin:


!!!
!!! NOTE: rumprun is experimental. syntax may change in the future
!!!

qemu-system-x86_64 -net none -no-kvm -m 64 -kernel helloer-rumprun.bin -append   {,,
    "cmdline": "helloer-rumprun.bin",,
            },,
ctsrc commented 4 years ago

Meanwhile, following the same guide on KDE Neon Linux I am able to build and run it in qemu

rumprun qemu -i helloer-rumprun.bin

Screenshot_20201011_053119

So naturally this made me curious to see what would happen if I took the kernel file that I had built on Linux and ran it in qemu on FreeBSD.

The next screenshot, which is from FreeBSD will look very similar to the one on Linux because I run KDE on both systems and use the same theme on both of the systems. But this screenshot shows qemu running on FreeBSD with the kernel image that was built on Linux:

Screenshot_20201011_053944

Interesting!

Thinking that perhaps the rumprun tools I built on FreeBSD were broken during compilation I decided to rebuild them again, because on FreeBSD I applied the patch from #133 after it had initially failed to build and then reran the build script in the directory and so maybe there were parts of the tools that ended up not being built properly.

Unfortunately however even after a clean rebuild of the tools they produce an image that qemu does not boot.

ctsrc commented 4 years ago

In case anyone is able to take a look at this, I have attached the images here.

First, the image that I built on Linux and which does boot in qemu:

helloer-rumprun-from-linux.bin.gz

Second, the image that I built on FreeBSD and which does not boot in qemu:

helloer-rumprun-from-freebsd.bin.gz

Note that the attached files are gzipped, because GitHub only accepts a select few different kinds of data formats, of which one of the accepted data formats is gzipped data.