unikraft / catalog

Unikraft Applications & Examples Catalog
39 stars 35 forks source link

`base`: `appelfloader` does not find binary in `rootfs` #134

Closed tacryt-socryp closed 1 month ago

tacryt-socryp commented 2 months ago

This output is from http-c, but all of the examples provide the same issue:

[+] building rootfs via Dockerfile... done!                                                                                                                                                             x86_64 [30.0s]
en1: Interface is up
en1: Set IPv4 address 10.0.2.15 mask 255.255.255.0 gw 10.0.2.2
Powered by Unikraft Calypso (0.17.0~62132e5)
[    1.112220] ERR:  [appelfloader] http_server: Failed to execute /http_server: No such file or directory
mkroening commented 2 months ago

I can confirm this issue, even with helloworld-c.

This might to be an issue with the rootfs. Changing cmd from ["/helloworld"] to ["/fallback"] successfully runs the fallback app from base/Kraftfile, which should not be there.

This does not seem to be a KraftKit issue, since I can reproduce this all the way back to KraftKit v0.8.0.

It might be an issue with the prebuilt base image, but I don't know if you can test older versions.

mkroening commented 2 months ago

To reproduce:

export KRAFTKIT_LOG_LEVEL=debug
export KRAFTKIT_LOG_TYPE=basic
cd examples/helloworld-c
kraft run --rm --plat qemu --arch x86_64 -p 8080:8080 .

It does not work without -p 8080:8080, which is another issue, I guess.

Output ```console D kraftkit 0.9.2-48-gc71f600b D using platform=qemu D determining how to proceed given provided input and context D using compatible context candidate=kraftfile-runtime i searching for base:latest D querying catalog local=true name=base remote=false version=latest i found unikraft.org/base:latest (fc/x86_64) (f4d81b1, 4a41565, fc/x86_64, 1.6 MB) i found unikraft.org/base:latest (qemu/x86_64) (61ea484, 4a41565, qemu/x86_64, 1.7 MB) D found 2/54 matching packages in oci catalog D querying manifest catalog local=true name=base remote=false version=latest D found 0/104 matching packages in manifest catalog i using arch=x86_64 plat=qemu i building rootfs via Dockerfile (x86_64) i creating ephemeral buildkit container D using buildkit addr=tcp://localhost:39553 version=v0.14.1 i #1 [internal] load build definition from Dockerfile i #1 transferring dockerfile: 396B done i #1 DONE 0.0s i i #2 [internal] load metadata for docker.io/library/gcc:13.2.0-bookworm i #2 DONE 1.6s i i #3 [internal] load .dockerignore i #3 transferring context: 2B done i #3 DONE 0.0s i i #4 [internal] load build context i #4 transferring context: 112B done i #4 DONE 0.0s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 resolve docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 0.0s done i #5 DONE 0.1s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 sha256:b4cb371000b5a7cdbb9e1344c17b3fdd72ffd76c56937bcebb6ca6f2d1243a92 0B / 1.78kB 0.2s i #5 sha256:b4cb371000b5a7cdbb9e1344c17b3fdd72ffd76c56937bcebb6ca6f2d1243a92 1.78kB / 1.78kB 0.2s done i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 0B / 145.04MB 0.3s i #5 sha256:727351ba33d5f1e02163243b11670925391797387d8a29b833b700c6539d6adc 0B / 9.62kB 0.2s i #5 sha256:960e038fa1a53c597f212ead212163ffaa012a9627040424fbf8328797cf07fa 0B / 2.81MB 0.2s i #5 sha256:727351ba33d5f1e02163243b11670925391797387d8a29b833b700c6539d6adc 9.62kB / 9.62kB 0.4s done i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 0B / 211.21MB 0.2s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 10.38MB / 145.04MB 0.5s i #5 sha256:960e038fa1a53c597f212ead212163ffaa012a9627040424fbf8328797cf07fa 2.81MB / 2.81MB 0.5s done i #5 sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 0B / 64.14MB 0.2s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 34.60MB / 145.04MB 0.6s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 29.36MB / 211.21MB 0.5s i #5 sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 20.97MB / 64.14MB 0.3s i #5 sha256:891494355808bdd3db5552f0d3723fd0fa826675f774853796fafa221d850d42 0B / 24.05MB 0.2s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 57.67MB / 145.04MB 0.8s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 45.09MB / 211.21MB 0.6s i #5 sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 30.41MB / 64.14MB 0.5s i #5 sha256:891494355808bdd3db5552f0d3723fd0fa826675f774853796fafa221d850d42 17.61MB / 24.05MB 0.3s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 78.64MB / 145.04MB 0.9s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 56.62MB / 211.21MB 0.8s i #5 sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 43.44MB / 64.14MB 0.6s i #5 sha256:891494355808bdd3db5552f0d3723fd0fa826675f774853796fafa221d850d42 24.05MB / 24.05MB 0.4s done i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 95.42MB / 145.04MB 1.1s i #5 sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 64.14MB / 64.14MB 0.8s i #5 sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 1.05MB / 49.58MB 0.2s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 102.76MB / 145.04MB 1.2s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 77.59MB / 211.21MB 1.1s i #5 sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 64.14MB / 64.14MB 0.9s done i #5 sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 15.73MB / 49.58MB 0.3s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 116.39MB / 145.04MB 1.4s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 99.61MB / 211.21MB 1.2s i #5 sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 32.51MB / 49.58MB 0.5s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 126.88MB / 145.04MB 1.5s i #5 sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 41.94MB / 49.58MB 0.6s i #5 sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 49.58MB / 49.58MB 0.8s i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 145.04MB / 145.04MB 1.8s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 125.83MB / 211.21MB 1.5s i #5 sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 49.58MB / 49.58MB 0.8s done i #5 extracting sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 i #5 sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 145.04MB / 145.04MB 2.0s done i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 174.06MB / 211.21MB 2.0s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 192.94MB / 211.21MB 2.1s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 211.21MB / 211.21MB 2.3s i #5 sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 211.21MB / 211.21MB 2.7s done i #5 extracting sha256:c6cf28de8a067787ee0d08f8b01d7f1566a508b56f6e549687b41dfd375f12c7 1.4s done i #5 DONE 3.2s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 extracting sha256:891494355808bdd3db5552f0d3723fd0fa826675f774853796fafa221d850d42 i #5 extracting sha256:891494355808bdd3db5552f0d3723fd0fa826675f774853796fafa221d850d42 0.5s done i #5 DONE 3.7s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 extracting sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 i #5 extracting sha256:6582c62583ef22717db8d306b1d6a0c288089ff607d9c0d2d81c4f8973cbfee3 1.7s done i #5 DONE 5.4s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 extracting sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 i #5 extracting sha256:bf2c3e352f3d2eed4eda4feeed44a1022a881058df20ac0584db70c138b041e2 4.5s done i #5 DONE 9.9s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 extracting sha256:960e038fa1a53c597f212ead212163ffaa012a9627040424fbf8328797cf07fa 0.1s done i #5 extracting sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f i #5 extracting sha256:34a8cf19f318b25e5c88a175b6b0d93f8ec3fbfefef3075c780a26ca8f08c50f 2.6s done i #5 DONE 12.6s i i #5 [build 1/4] FROM docker.io/library/gcc:13.2.0-bookworm@sha256:15c73bc59ae88b3fd563ef2ec4a8743a8848a9f74362b6d116c4543c4844b6e0 i #5 extracting sha256:727351ba33d5f1e02163243b11670925391797387d8a29b833b700c6539d6adc 0.0s done i #5 extracting sha256:b4cb371000b5a7cdbb9e1344c17b3fdd72ffd76c56937bcebb6ca6f2d1243a92 0.0s done i #5 DONE 12.6s i i #6 [build 2/4] WORKDIR /src i #6 DONE 3.6s i i #7 [build 3/4] COPY ./helloworld.c /src/helloworld.c i #7 DONE 0.0s i i #8 [build 4/4] RUN set -xe; gcc -Wall -Wextra -fPIC -pie -o /helloworld helloworld.c i #8 0.086 + gcc -Wall -Wextra -fPIC -pie -o /helloworld helloworld.c i #8 DONE 0.2s i i #9 [stage-1 1/3] COPY --from=build /helloworld /helloworld i #9 DONE 0.0s i i #10 [stage-1 2/3] COPY --from=build /lib/x86_64-linux-gnu/libc.so.6 /lib/x86_64-linux-gnu/ i #10 DONE 0.0s i i #11 [stage-1 3/3] COPY --from=build /lib64/ld-linux-x86-64.so.2 /lib64/ i #11 DONE 0.0s i i #12 exporting to client tarball i #12 sending tarball i #12 sending tarball 0.0s done i #12 DONE 0.1s i i #13 exporting to oci image format i #13 exporting layers 0.2s done i #13 exporting manifest sha256:c0b280897297bb66f52d640489a7d1f160d9c0e79b1729ebd98db98c1d071958 done i #13 exporting config sha256:5574a904f99e83ac28c34ad1748bb281594d63ffb87b50fd578e8a978f053168 done i #13 sending tarball 0.0s done i #13 DONE 0.2s i i #14 exporting cache to client directory i #14 preparing build cache for export 0.1s done i #14 writing layer sha256:49249addf81864731e5d23a3a380c8d07a2dfb644d2a5aa13e05af5f071c67ff 0.0s done i #14 writing layer sha256:d6930d471cb5ee8ae96d84b0546d0798919dbffe8e323f8b931e2d9e21cdc2eb 0.0s done i #14 writing layer sha256:ea17a09f54398a22a2319c65aaa76763f40ec2ff7042e0dfb9e7f67972ff5029 done i #14 writing config sha256:93c9f7fe525615adc1270420e083a45b1141a501b9c906054cbd92f628d59b77 done i #14 writing cache manifest sha256:40164138f459bb771cb4cf69dca9c585ab022a83b953f6f41e67c305da813c76 done i #14 DONE 0.1s D terminating buildkit container error=Delete "http://%2Fvar%2Frun%2Fdocker.sock/v1.46/containers/b412605001ad515ed4a7d24f4dde0a2367be8c2c585c6845a28ec554bfdc3a28?force=1&v=1": context canceled D qemu-system-x86_64 -version D qemu-system-x86_64 -accel help D qemu-system-x86_64 -append vfs.fstab=[ "initrd0:/:extract:::" ] env.vars=[ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" ] -- /helloworld -cpu host,+x2apic,-pmu -daemonize -device virtio-net-pci,mac=02:b0:b0:94:1c:01,netdev=hostnet0 -device pvpanic -device sga -display none -enable-kvm -initrd .unikraft/build/initramfs-x86_64.cpio -kernel /tmp/kraft-run-1882652735/unikraft/bin/kernel -machine pc,accel=kvm -m size=64M -monitor unix:/home/debian/.local/share/kraftkit/runtime/7ea4a27f-b270-4aae-94aa-e6fafde4092e/qemu_mon.sock,server,nowait -name 7ea4a27f-b270-4aae-94aa-e6fafde4092e -netdev user,id=hostnet0,hostfwd=tcp::8080-:8080 -nographic -no-reboot -S -parallel none -pidfile /home/debian/.local/share/kraftkit/runtime/7ea4a27f-b270-4aae-94aa-e6fafde4092e/machine.pid -qmp unix:/home/debian/.local/share/kraftkit/runtime/7ea4a27f-b270-4aae-94aa-e6fafde4092e/qemu_control.sock,server,nowait -qmp unix:/home/debian/.local/share/kraftkit/runtime/7ea4a27f-b270-4aae-94aa-e6fafde4092e/qemu_events.sock,server,nowait -rtc base=utc -serial file:/home/debian/.local/share/kraftkit/runtime/7ea4a27f-b270-4aae-94aa-e6fafde4092e/machine.log -smp cpus=1,threads=1,sockets=1 -vga none en1: Added en1: Interface is up en1: Set IPv4 address 10.0.2.15 mask 255.255.255.0 gw 10.0.2.2 Powered by Unikraft Calypso (0.17.0~62132e5) [ 1.124890] ERR: [appelfloader] helloworld: Failed to execute /helloworld: No such file or directory ```
mkroening commented 2 months ago

One workaround is building base manually and working directly on base:

export KRAFTKIT_LOG_LEVEL=debug
export KRAFTKIT_LOG_TYPE=basic
cd library/base
kraft build --plat qemu --arch x86_64
kraft run --rm --plat qemu --arch x86_64 -p 8080:8080 .

So this may be a KraftKit issue after all (combining different rootfs'), but I am not sure. This workaround will suffice for me for now.

mkroening commented 2 months ago

Another workaround is setting base's Unikraft version to 0.17.0:

--- a/library/base/Kraftfile
+++ b/library/base/Kraftfile
@@ -9,7 +9,7 @@ rootfs: ./Dockerfile
 cmd: ["/fallback"]

 unikraft:
-  version: staging
+  version: 0.17.0
   kconfig:
     # Configurations options for app-elfloader
     # (they can't be part of the template atm)

You can then build your custom base (library/base):

kraft build --plat qemu --arch x86_64
kraft pkg --as oci --name my-base:latest

Using this custom base should work, then (examples/helloworld-c):

--- a/examples/helloworld-c/Kraftfile
+++ b/examples/helloworld-c/Kraftfile
@@ -1,6 +1,6 @@
 spec: v0.6

-runtime: base:latest
+runtime: my-base:latest

 rootfs: ./Dockerfile
kraft run --rm --plat qemu --arch x86_64 -p 8080:8080 .
razvand commented 1 month ago

The root cause of this is detailed on the unikraft core repository issue tracker. It is caused by an issue with enabling dead code elimination on a recent update to the uklibparam library.

razvand commented 1 month ago

This was solved by unikraft PR 1499.