From 5af79afa30ddbc1d64b6158e26d1876aa956b929 Mon Sep 17 00:00:00 2001 From: GHEORGHISOR Mario-Alin Date: Sat, 17 May 2025 12:31:20 +0300 Subject: [PATCH 1/3] app/c-fs: Update naming convention and add script for qemu.x86_64.9pfs Signed-off-by: GHEORGHISOR Mario-Alin --- c-fs/scripts/README.md | 12 ++++++++++++ c-fs/scripts/build/qemu.x86_64.9pfs | 12 ++++++++++++ c-fs/scripts/defconfig/qemu.x86_64.9pfs | 11 +++++++++++ c-fs/scripts/run/qemu.x86_64.9pfs | 18 ++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 c-fs/scripts/build/qemu.x86_64.9pfs create mode 100644 c-fs/scripts/defconfig/qemu.x86_64.9pfs create mode 100644 c-fs/scripts/run/qemu.x86_64.9pfs diff --git a/c-fs/scripts/README.md b/c-fs/scripts/README.md index da75452a..0b5e37f7 100644 --- a/c-fs/scripts/README.md +++ b/c-fs/scripts/README.md @@ -54,3 +54,15 @@ e.g. ./scripts/run/fc.x86_64 ./scripts/run/xen.arm64 ``` + +## Build and Run for / using a different file system + +```console +./scripts/run/.. +``` + +e.g. + +```console +./scripts/run/qemu.x86_64.9pfs +``` diff --git a/c-fs/scripts/build/qemu.x86_64.9pfs b/c-fs/scripts/build/qemu.x86_64.9pfs new file mode 100644 index 00000000..0b063c95 --- /dev/null +++ b/c-fs/scripts/build/qemu.x86_64.9pfs @@ -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 + diff --git a/c-fs/scripts/defconfig/qemu.x86_64.9pfs b/c-fs/scripts/defconfig/qemu.x86_64.9pfs new file mode 100644 index 00000000..644c0e0b --- /dev/null +++ b/c-fs/scripts/defconfig/qemu.x86_64.9pfs @@ -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 + diff --git a/c-fs/scripts/run/qemu.x86_64.9pfs b/c-fs/scripts/run/qemu.x86_64.9pfs new file mode 100644 index 00000000..02bce53a --- /dev/null +++ b/c-fs/scripts/run/qemu.x86_64.9pfs @@ -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 From b9c57c793119e837957608369cf51342b0e0b616 Mon Sep 17 00:00:00 2001 From: GHEORGHISOR Mario-Alin Date: Sat, 17 May 2025 13:27:37 +0300 Subject: [PATCH 2/3] app/python3-hello: Update naming convention and add script for qemu.x86_64.9pfs Signed-off-by: GHEORGHISOR Mario-Alin --- python3-hello/scripts/README.md | 12 ++++++++++ python3-hello/scripts/build/qemu.x86_64.9pfs | 11 +++++++++ .../scripts/defconfig/qemu.x86_64.9pfs | 12 ++++++++++ python3-hello/scripts/run/qemu.x86_64.9pfs | 24 +++++++++++++++++++ 4 files changed, 59 insertions(+) create mode 100644 python3-hello/scripts/build/qemu.x86_64.9pfs create mode 100644 python3-hello/scripts/defconfig/qemu.x86_64.9pfs create mode 100644 python3-hello/scripts/run/qemu.x86_64.9pfs diff --git a/python3-hello/scripts/README.md b/python3-hello/scripts/README.md index 656458c1..15366baa 100644 --- a/python3-hello/scripts/README.md +++ b/python3-hello/scripts/README.md @@ -54,3 +54,15 @@ e.g. ./scripts/run/fc.x86_64 ./scripts/run/xen.arm64 ``` + +## Build and Run for / using a different file system + +```console +./scripts/run/.. +``` + +e.g. + +```console +./scripts/run/qemu.x86_64.9pfs +``` diff --git a/python3-hello/scripts/build/qemu.x86_64.9pfs b/python3-hello/scripts/build/qemu.x86_64.9pfs new file mode 100644 index 00000000..fb974580 --- /dev/null +++ b/python3-hello/scripts/build/qemu.x86_64.9pfs @@ -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 diff --git a/python3-hello/scripts/defconfig/qemu.x86_64.9pfs b/python3-hello/scripts/defconfig/qemu.x86_64.9pfs new file mode 100644 index 00000000..55a57a86 --- /dev/null +++ b/python3-hello/scripts/defconfig/qemu.x86_64.9pfs @@ -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 diff --git a/python3-hello/scripts/run/qemu.x86_64.9pfs b/python3-hello/scripts/run/qemu.x86_64.9pfs new file mode 100644 index 00000000..47bf58c8 --- /dev/null +++ b/python3-hello/scripts/run/qemu.x86_64.9pfs @@ -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 From 55d80c9e55675e87e3f974d6345ad76930bd62ec Mon Sep 17 00:00:00 2001 From: GHEORGHISOR Mario-Alin Date: Sat, 17 May 2025 13:41:08 +0300 Subject: [PATCH 3/3] app/nginx: Update naming convention and add script for qemu.x86_64.9pfs Signed-off-by: GHEORGHISOR Mario-Alin --- nginx/scripts/README.md | 12 +++++++++ nginx/scripts/build/qemu.x86_64.9pfs | 11 ++++++++ nginx/scripts/defconfig/qemu.x86_64.9pfs | 13 ++++++++++ nginx/scripts/run/qemu.x86_64.9pfs | 33 ++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 nginx/scripts/build/qemu.x86_64.9pfs create mode 100644 nginx/scripts/defconfig/qemu.x86_64.9pfs create mode 100644 nginx/scripts/run/qemu.x86_64.9pfs diff --git a/nginx/scripts/README.md b/nginx/scripts/README.md index 91d8c3e5..40122c45 100644 --- a/nginx/scripts/README.md +++ b/nginx/scripts/README.md @@ -54,3 +54,15 @@ e.g. ./scripts/run/fc.x86_64 ./scripts/run/xen.arm64 ``` + +## Build and Run for / using a different file system + +```console +./scripts/run/.. +``` + +e.g. + +```console +./scripts/run/qemu.x86_64.9pfs +``` diff --git a/nginx/scripts/build/qemu.x86_64.9pfs b/nginx/scripts/build/qemu.x86_64.9pfs new file mode 100644 index 00000000..fb974580 --- /dev/null +++ b/nginx/scripts/build/qemu.x86_64.9pfs @@ -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 diff --git a/nginx/scripts/defconfig/qemu.x86_64.9pfs b/nginx/scripts/defconfig/qemu.x86_64.9pfs new file mode 100644 index 00000000..a99e9b21 --- /dev/null +++ b/nginx/scripts/defconfig/qemu.x86_64.9pfs @@ -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 diff --git a/nginx/scripts/run/qemu.x86_64.9pfs b/nginx/scripts/run/qemu.x86_64.9pfs new file mode 100644 index 00000000..fcc13287 --- /dev/null +++ b/nginx/scripts/run/qemu.x86_64.9pfs @@ -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