Skip to content

Commit

Permalink
riscv64: Replace 9p rootfs with virtio-blk
Browse files Browse the repository at this point in the history
The new dev-riscv image will contain a `rootfs.img` to be used as
`virtio-blk`. Effectively resolve the problems encountered while running
unit-tests of `linux-loader` and `vm-memory`.

Signed-off-by: Ruoqing He <[email protected]>
  • Loading branch information
TimePrinciple committed Sep 29, 2024
1 parent 24bf6da commit e24510d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ jobs:
echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
echo "Next version to be published is: ${NEXT_VERSION}"
- name: Build RISC-V rootfs
id: build-riscv-rootfs
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.riscv64_rootfs
push: false
load: true
platforms: linux/amd64
tags: rootfs
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Convert rootfs to raw image
run: |
mkdir -p ./extracted
docker run --privileged --rm --volume ./riscv64/convert.sh:/convert.sh \
--volume ./extracted:/to_extract --entrypoint /convert.sh rootfs
docker buildx prune --all --force
docker image rm rootfs
- name: Build and push Docker image for RISC-V
id: build-and-push-riscv
uses: docker/build-push-action@v6
Expand Down
24 changes: 24 additions & 0 deletions riscv64/convert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex

apt-get update

DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \
qemu-utils

TMP_MOUNT_DIR=tmp_mount_dir
ROOTFS_DIR=/opt/rootfs
EXTRACT_DIR=/to_extract

# Move rootfs into image with raw format
qemu-img create $EXTRACT_DIR/rootfs.img 5G && mkfs.ext4 $EXTRACT_DIR/rootfs.img
mkdir $TMP_MOUNT_DIR
# This operation need `privileged` docker container
mount -o loop $EXTRACT_DIR/rootfs.img $TMP_MOUNT_DIR
mv $ROOTFS_DIR/* $TMP_MOUNT_DIR
umount $TMP_MOUNT_DIR
rmdir $TMP_MOUNT_DIR

mv /root/.ssh $EXTRACT_DIR
# Enable docker builx to transfer into container
chmod 777 $EXTRACT_DIR/.ssh

0 comments on commit e24510d

Please sign in to comment.