Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions c-fs/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ e.g.
./scripts/run/fc.x86_64
./scripts/run/xen.arm64
```

## Build and Run for <plat> / <arch> using a different file system

```console
./scripts/run/<plat>.<arch>.<file_system>
```

e.g.

```console
./scripts/run/qemu.x86_64.9pfs
```
12 changes: 12 additions & 0 deletions c-fs/scripts/build/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/qemu.x86_64.9pfs make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi

11 changes: 11 additions & 0 deletions c-fs/scripts/defconfig/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CONFIG_PLAT_KVM=y
CONFIG_KVM_VMM_QEMU=y
CONFIG_ARCH_X86_64=y
CONFIG_LIBVFSCORE=y
CONFIG_LIBVFSCORE_AUTOMOUNT_UP=y
CONFIG_LIBUK9P=y
CONFIG_LIB9PFS=y
# Uncomment for debugging.
#CONFIG_LIBUKDEBUG_PRINTD=y
#CONFIG_LIBUKDEBUG_PRINTK_INFO=y

18 changes: 18 additions & 0 deletions c-fs/scripts/run/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

if test ! -f "workdir/build/c-fs_qemu-x86_64"; then
echo "No kernel file workdir/build/c-fs_qemu-x86_64." 1>&2
echo "Did you run ./build.qemu.x86_64 ?" 1>&2
exit 1
fi

rm -fr 9pfs-rootfs
cp -r rootfs 9pfs-rootfs
qemu-system-x86_64 \
-nographic \
-m 8 \
-cpu max \
-kernel workdir/build/c-fs_qemu-x86_64 \
-append "c-fs vfs.fstab=[ \"fs0:/:9pfs:::\" ] -- /hello.txt" \
-fsdev local,id=myid,path=$(pwd)/9pfs-rootfs/,security_model=none \
-device virtio-9p-pci,fsdev=myid,mount_tag=fs0
12 changes: 12 additions & 0 deletions nginx/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ e.g.
./scripts/run/fc.x86_64
./scripts/run/xen.arm64
```

## Build and Run for <plat> / <arch> using a different file system

```console
./scripts/run/<plat>.<arch>.<file_system>
```

e.g.

```console
./scripts/run/qemu.x86_64.9pfs
```
11 changes: 11 additions & 0 deletions nginx/scripts/build/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/qemu.x86_64.9pfs make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
13 changes: 13 additions & 0 deletions nginx/scripts/defconfig/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_PLAT_KVM=y
CONFIG_KVM_VMM_QEMU=y
CONFIG_ARCH_X86_64=y
CONFIG_LIBNGINX=y
CONFIG_LIBNGINX_MAIN_FUNCTION=y
CONFIG_LIBVFSCORE=y
CONFIG_LIBVFSCORE_AUTOMOUNT_UP=y
CONFIG_LIBUK9P=y
CONFIG_LIB9PFS=y
CONFIG_LIBDEVFS=y
CONFIG_LIBDEVFS_AUTOMOUNT=y
CONFIG_LIBDEVFS_DEVSTDOUT=y
CONFIG_LIBUKNETDEV_EINFO_LIBPARAM=y
33 changes: 33 additions & 0 deletions nginx/scripts/run/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

if test ! -f "workdir/build/nginx_qemu-x86_64"; then
echo "No kernel file workdir/build/nginx_qemu-x86_64." 1>&2
echo "Did you run ./build.qemu.x86_64 ?" 1>&2
exit 1
fi

{
# Remove previously created network interface.
sudo ip link set dev virbr0 down
sudo ip link del dev virbr0
sudo ip link set dev tap0 down
sudo ip link del dev tap0
} > /dev/null 2>&1

# Create bridge interface for QEMU networking.
sudo ip link add dev virbr0 type bridge
sudo ip address add 172.44.0.1/24 dev virbr0
sudo ip link set dev virbr0 up

# Create a copy of the filesystem to be mounted as 9pfs.
rm -fr 9pfs-rootfs
cp -r rootfs 9pfs-rootfs
sudo qemu-system-x86_64 \
-nographic \
-m 8 \
-cpu max \
-netdev bridge,id=en0,br=virbr0 -device virtio-net-pci,netdev=en0 \
-append "nginx netdev.ip=172.44.0.2/24:172.44.0.1::: vfs.fstab=[ \"fs0:/:9pfs:::\" ] -- -c /nginx/conf/nginx.conf" \
-kernel workdir/build/nginx_qemu-x86_64 \
-fsdev local,id=myid,path=$(pwd)/9pfs-rootfs/,security_model=none \
-device virtio-9p-pci,fsdev=myid,mount_tag=fs0
12 changes: 12 additions & 0 deletions python3-hello/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,15 @@ e.g.
./scripts/run/fc.x86_64
./scripts/run/xen.arm64
```

## Build and Run for <plat> / <arch> using a different file system

```console
./scripts/run/<plat>.<arch>.<file_system>
```

e.g.

```console
./scripts/run/qemu.x86_64.9pfs
```
11 changes: 11 additions & 0 deletions python3-hello/scripts/build/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

make distclean
UK_DEFCONFIG=$(pwd)/scripts/defconfig/qemu.x86_64.9pfs make defconfig
touch Makefile.uk
make prepare
if test -z "$CC"; then
make -j $(nproc)
else
make CC="$CC" -j $(nproc)
fi
12 changes: 12 additions & 0 deletions python3-hello/scripts/defconfig/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_PLAT_KVM=y
CONFIG_KVM_VMM_QEMU=y
CONFIG_ARCH_X86_64=y
CONFIG_LIBPYTHON3=y
CONFIG_LIBPYTHON3_MAIN_FUNCTION=y
CONFIG_LIBVFSCORE=y
CONFIG_LIBVFSCORE_AUTOMOUNT_UP=y
CONFIG_LIBUK9P=y
CONFIG_LIB9PFS=y
CONFIG_STACK_SIZE_PAGE_ORDER=10
CONFIG_LIBPOSIX_ENVIRON=y
CONFIG_LIBPOSIX_ENVIRON_LIBPARAM=y
24 changes: 24 additions & 0 deletions python3-hello/scripts/run/qemu.x86_64.9pfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

if test ! -f "workdir/build/python3-hello_qemu-x86_64"; then
echo "No kernel file workdir/build/python3-hello_qemu-x86_64." 1>&2
echo "Did you run ./build.qemu.x86_64 ?" 1>&2
exit 1
fi

# Generate root filesystem from Dockerfile.
rm -fr ./rootfs
docker build -o ./rootfs -f Dockerfile .

# Create a copy of the filesystem to be mounted as 9pfs.
rm -fr ./9pfs-rootfs
cp -r ./rootfs ./9pfs-rootfs

qemu-system-x86_64 \
-nographic \
-m 256 \
-cpu max \
-fsdev local,id=myid,path=$(pwd)/9pfs-rootfs/,security_model=none \
-device virtio-9p-pci,fsdev=myid,mount_tag=fs0 \
-append "python3-hello_qemu-x86_64 vfs.fstab=[ \"fs0:/:9pfs:::\" ] env.vars=[ PYTHONPATH=\"/usr/local/lib/python3.10:/usr/local/lib/python3.10/site-packages\" ] -- /app/hello.py" \
-kernel workdir/build/python3-hello_qemu-x86_64