unikraft / lib-nginx

Unikraft port of NGINX
Other
1 stars 5 forks source link

Failure to mount filesystem #7

Closed Red-Panda64 closed 2 years ago

Red-Panda64 commented 3 years ago

I have tried to set up an app with lib-nginx on Unikraft, but I am failing to mount the filesystem. I have checked out the Unikraft 0.5.0, also for the library dependencies pthread-embedded, newlib, lwip and nginx. I have followed the steps in the documentation (https://github.com/unikraft/lib-nginx/blob/staging/README.md) up to the section "Using the filesystem". Here it states "You should also use vfs.rootdev=test to specify the 9pfs mounting tag to Unikraft." I am unclear, where that option should be supplied. I called qemu like so:

qemu-system-x86_64 -s -cpu host -enable-kvm -m 1024 -nodefaults -no-acpi -display none -serial stdio -device isa-debug-exit -kernel build/newapp_kvm-x86_64 \
-fsdev local,id=myid,path=./nginx-rootfs-example/nginx/,security_model=none \
-device virtio-9p-pci,fsdev=myid,mount_tag=test,disable-modern=on,disable-legacy=off -append vfs.rootdev=test

This results in a runtime error (with debug & info prints enabled): nginx_mount_fail_debug_output

nginx_mount_fail_config

FredrikBakken commented 2 years ago

Hello @Red-Panda64!

I was also struggling a little with getting the nginx application up and running - suspecting some issues with my .config setup, but found a working application in the Summer of Code 2021 repository: https://github.com/unikraft/summer-of-code-2021/tree/main/content/en/docs/sessions/03-debugging/sol/06-app-nginx

Make sure to copy the contents into the $UK_WORKDIR/apps/app-nginx directory, download all the dependencies into the $UK_WORKDIR/libs directory, and check out the staging branch for unikraft and library dependencies by using git checkout staging.

The first session from Summer of Code 2021 also gives information about some missing pieces, such as setting up a network bridge: https://usoc21.unikraft.org/docs/sessions/01-baby-steps/#connecting-to-the-http-server-1

sudo brctl addbr virbr0
sudo ip a a  172.44.0.1/24 dev virbr0
sudo ip l set dev virbr0 up

After all of these steps are completed, you can build and run the application as follows:

make
sudo qemu-system-x86_64 \
    -netdev bridge,id=en0,br=virbr0\
    -fsdev local,id=myid,path=$(pwd)/fs0,security_model=none\
    -device virtio-net-pci,netdev=en0\
    -device virtio-9p-pci,fsdev=myid,mount_tag=rootfs,disable-modern=on,disable-legacy=off\
    -kernel build/app-nginx_kvm-x86_64\
    -append "netdev.ipv4_addr=172.44.0.2 netdev.ipv4_gw_addr=172.44.0.1 netdev.ipv4_subnet_mask=255.255.255.0 --"\
    -enable-kvm\
    -nographic

In another terminal, you can now test the connection with: curl 172.44.0.2.

Let me know if you have any further questions and/or problems!

Red-Panda64 commented 2 years ago

Thanks a lot for your time and effort! Unfortunately, I wanted to use this for university work that I have recently had to hand in. I should have closed this issue then, but I forgot about it until now. But thanks again, I hope your answer will help others with the same problem.