GaloisInc / BESSPIN-CloudGFE

The AWS cloud deployment of the BESSPIN GFE platform.
Apache License 2.0
2 stars 2 forks source link

investigate building Debian image inside GFE docker #90

Closed podhrmic closed 4 years ago

podhrmic commented 4 years ago

How to reproduce?

From gfe root directory:

cd bootmem; make clean; make debian

This will produce a working Debian binary on host,but fails to build so in docker (even with priviledged mode).

Tested with:

docker run --privileged=true -v $PWD:/gfe -it  galoisinc/besspin:gfe

This is the error message:

[    0.650000] Run /init as init process
chainloader: booting from virtfs
created directory: '/chain/'
created directory: '/chain/dev'
created directory: '/chain/new'
created directory: '/chain/mnt'
chainloader: unpacking initramfs.cpio.gz
chainloader: switching root
switch_root: can't execute '/init': No such file or directory
[    1.290000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[    1.290000] CPU: 1 PID: 1 Comm: switch_root Not tainted 4.20.0-00038-g01cd5605f124 #1
[    1.290000] Call Trace:
[    1.290000] [<ffffffe00011ee60>] walk_stackframe+0x0/0xa6
[    1.290000] [<ffffffe00011f060>] show_stack+0x2a/0x34
[    1.290000] [<ffffffe000465c26>] dump_stack+0x66/0x82
[    1.290000] [<ffffffe0001227a8>] panic+0xdc/0x1f4
[    1.290000] [<ffffffe000124ef0>] do_exit+0x6ac/0x712
[    1.290000] [<ffffffe000124fb0>] do_group_exit+0x2a/0x82
[    1.300000] [<ffffffe000125020>] __wake_up_parent+0x0/0x22
[    1.300000] [<ffffffe00011ddd2>] ret_from_syscall+0x0/0xe

And this is the corresponding line in the Debian Makefile where the error occurs

dragansts commented 4 years ago

@podhrmic can you please point me ( url ) for the project and I will give try.

podhrmic commented 4 years ago

https://gitlab-ext.galois.com/ssith/gfe

dragansts commented 4 years ago

@podhrmic there is a bug in description setup-os-debian-buster. Instead of

sudo tar -C /opt -xf install/riscv-gnu-toolchains.tar.gz

should be

sudo tar -C / -xf install/riscv-gnu-toolchains.tar.gz

reason : the destination folder is not /opt/riscv. Actually is /opt/opt/riscv. So we have already discussed about that. Should I open a ticket ?

podhrmic commented 4 years ago

@dragansts this should be a ticket in gfe repo. The error in the path of the script has nothing to do with docker image not working, but it should be fixed nonetheless. Thanks for finding it out!

dragansts commented 4 years ago

@podhrmic 231 Opened.

dragansts commented 4 years ago

@podhrmic Perhaps this one is docker related . the debotstrap does not work from command line but it works with manually added symbolic link:

sudo ln -s /usr/sbin/debotstrap /usr/bin/debootstrap

I will add in the 231 issue this comment .

jrtc27 commented 4 years ago

Don't mess with /usr/bin in Debian, it's under the control of the package manager. debootstrap generally needs to be run as root and is thus in /usr/sbin, which will be in your PATH if you use sudo or su -; if you really intend to run it as non-root, mess with your own PATH.

dragansts commented 4 years ago

@podhrmic @jrtc27 yes , in order to speed-up I have added my user to the root group and in sudoers I granted privileges to ALL. Yes u are right. Please then ignore my comment above. I fixed it now. Thanks .

dragansts commented 4 years ago

missing in docker file :

RUN apt-get install dialog apt-utils  git -y

building image is in progress

dragansts commented 4 years ago

status:

riscv64-unknown-elf-objcopy -S -O binary --change-addresses -0x80000000 bbl bbl.bin
make[1]: Leaving directory '/gfe/bootmem/build-qemu-bbl'
build-qemu-bbl/bbl done
debian.cpio
qemu-system-riscv64 \
      -nographic -machine virt -m 2G -smp 1 \
      -kernel build-qemu-bbl/bbl \
      -append "console=ttyS0 besspin.set_clock=$(date --iso-8601=sec) besspin.debian_repo=http://deb.debian.org/debian-ports/ besspin.dhcp_addr=1" \
      -fsdev local,id=virtfs,path=/gfe/bootmem/virtfs,security_model=mapped-file \
      -device virtio-9p-device,fsdev=virtfs,mount_tag=virtfs \
  -device virtio-net-device,netdev=usernet \
     -netdev user,id=usernet,hostfwd=tcp::10001-:22
qemu-system-riscv64: Could not set up host forwarding rule 'tcp::10001-:22'
make: *** [Makefile:221: debian.cpio] Error 1
podhrmic commented 4 years ago

Looks like running qemu inside docker is rather complicated. I suggest closing this as "known limitations" and moving on to other issues. Debian can be build directly on a host machine, given the dependencies are installed, or an image is provided from the nix binary cache.

kiniry commented 4 years ago

I agree with @podhrmic. Let's park this as a "Won't Fix" as we can always build on a Debian self-host.