unikraft / kraftkit

Build and use highly customized and ultra-lightweight unikernel VMs.
https://unikraft.org/docs/cli
BSD 3-Clause "New" or "Revised" License
233 stars 62 forks source link

Kraft run fails if `--rootfs` path to directory has `/` appended #904

Closed LucaSeri closed 12 months ago

LucaSeri commented 1 year ago

Describe the bug

Passing a rootfs to kraft run with a path to a directory works if the path does not end with a /, but fails otherwise.

Steps to reproduce

Clone the app-nginx repository and build an image for qemu-x86_64. Run kraft run --rootfs ./rootfs/ -p 8080:80

The kraftfile:

specification: '0.5'
name: nginx
unikraft:
  version: stable
  kconfig:
    - CONFIG_LIBUKLIBPARAM=y
    - CONFIG_LIBUKSCHEDCOOP=y
    - CONFIG_LIBPOSIX_LIBDL=y
    - CONFIG_LIBPOSIX_PROCESS=y
    - CONFIG_LIBPOSIX_USER=y
    - CONFIG_UKSYSINFO=y
    - CONFIG_LIBUKSIGNAL=y
    - CONFIG_LIBUKMMAP=y
    - CONFIG_LIBUKTIME=y
targets:
  - name: nginx-qemu-x86_64-9pfs
    architecture: x86_64
    platform: qemu
    kconfig:
      - CONFIG_PLAT_KVM=y
      - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y
      - CONFIG_LIBVFSCORE_ROOTFS_9PFS=y
      - CONFIG_LIBVFSCORE_ROOTFS="9pfs"
      - CONFIG_LIBVFSCORE_ROOTDEV="fs1"
  - name: nginx-qemu-x86_64-initrd
    architecture: x86_64
    platform: qemu
    kconfig:
      - CONFIG_PLAT_KVM=y
      - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y
      - CONFIG_LIBVFSCORE_ROOTFS_INITRD=y
      - CONFIG_LIBVFSCORE_ROOTFS="initrd"
  - name: nginx-qemu-arm64-9pfs
    architecture: arm64
    platform: qemu
    kconfig:
      - CONFIG_PLAT_KVM=y
      - CONFIG_ARCH_ARM_64=y
      - CONFIG_MCPU_ARM64_NONE=y
      - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y
      - CONFIG_LIBVFSCORE_ROOTFS_9PFS=y
      - CONFIG_LIBVFSCORE_ROOTFS="9pfs"
      - CONFIG_LIBVFSCORE_ROOTDEV="fs1"
  - name: nginx-qemu-arm64-initrd
    architecture: arm64
    platform: qemu
    kconfig:
      - CONFIG_PLAT_KVM=y
      - CONFIG_ARCH_ARM_64=y
      - CONFIG_MCPU_ARM64_NONE=y
      - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y
      - CONFIG_LIBVFSCORE_ROOTFS_INITRD=y
      - CONFIG_LIBVFSCORE_ROOTFS="initrd"
  - name: nginx-fc-x86_64-initrd
    architecture: x86_64
    platform: fc
    kconfig:
      - CONFIG_PLAT_KVM=y
      - CONFIG_KVM_BOOT_PROTO_LXBOOT=y
      - CONFIG_KVM_VMM_FIRECRACKER=y
      - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y
      - CONFIG_LIBVFSCORE_ROOTFS_INITRD=y
      - CONFIG_LIBVFSCORE_ROOTFS="initrd"
  - name: nginx-fc-arm64-initrd
    architecture: arm64
    platform: fc
    kconfig:
      - CONFIG_PLAT_KVM=y
      - CONFIG_KVM_BOOT_PROTO_LXBOOT=y
      - CONFIG_KVM_VMM_FIRECRACKER=y
      - CONFIG_ARCH_ARM_64=y
      - CONFIG_MCPU_ARM64_NONE=y
      - CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS=y
      - CONFIG_LIBVFSCORE_ROOTFS_INITRD=y
      - CONFIG_LIBVFSCORE_ROOTFS="initrd"
libraries:
  musl:
    version: stable
  lwip:
    version: stable
    kconfig:
      - CONFIG_LWIP_UKNETDEV=y
      - CONFIG_LWIP_TCP=y
      - CONFIG_LWIP_WND_SCALE=y
      - CONFIG_LWIP_TCP_KEEPALIVE=y
      - CONFIG_LWIP_THREADS=y
      - CONFIG_LWIP_SOCKET=y
      - CONFIG_LWIP_AUTOIFACE=y
      - CONFIG_LWIP_IPV4=y
      - CONFIG_LWIP_DHCP=y
      - CONFIG_LWIP_DNS=y
  nginx:
    version: stable
    kconfig:
      - CONFIG_LIBNGINX_MAIN_FUNCTION=y

Expected behavior

The image runs normally.

Which architectures were you using or does this bug affect?

No response

Which operating system were you using or does this bug affect?

No response

Relevant log output

[    0.000000] ERR:  [libukallocbbuddy] <bbuddy.c @  488> 12000: Failed to add memory region 31a087-31b000: Not enough space after applying page alignments
en1: Added
en1: Interface is up
[    0.104197] ERR:  [libukcpio] <cpio.c @  291> /./rootfs/: Failed to create directory: No such file or directory (2)
[    0.110471] CRIT: [libvfscore] <automount.c @  182> Failed to extract cpio archive to /: -6
[    0.115899] ERR:  [libukboot] <boot.c @  346> Init function at 0x14c730 returned error -1
 E  machine fatally exited
georgettica commented 1 year ago

can I attempt to solve this?

georgettica commented 1 year ago

can't debug locally and it's hard to find the right place the slash is added so I will give up the assignment