Skip to content

Commit

Permalink
Document running tests in qemu
Browse files Browse the repository at this point in the history
  • Loading branch information
teqwve committed Dec 1, 2024
1 parent 048ddba commit 411f442
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,65 @@ To run test suit use 'check' target, e.g in build directory run:

make check

note that sio2jail may not support newer kernel versions (#40), it may be required to
use a virtual machine for running tests (see the next section).

Running in QEMU
---------------

Since sio2jail may not support newest kernel versions it may be handy to use a virtual
machine for development:

# get debian 11 QEMU image
wget https://cdimage.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd64.qcow2

# reserve more space for QEMU image
qemu-img resize debian-11-nocloud-amd64.qcow2 +10G

# start QEMU with KVM and sio2jail sources mounted with virtfs
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-nographic \
-hda debian-11-nocloud-amd64.qcow2 \
-virtfs local,path=$SIO2JAIL_SOURCES,security_model=mapped-xattr,mount_tag=sio2jail \
-cpu max

# login as root (no password)

# resize root partition
apt update
apt install -y cloud-utils fdisk
growpart /dev/sda 1
resize2fs /dev/sda1

# install dependencies and utilities
apt install -y \
build-essential \
cmake \
gcc-multilib \
g++-multilib \
gperf \
wget

# mount sio2jail sources
mkdir /sio2jail
mount -t 9p -o trans=virtio sio2jail /sio2jail -oversion=9p2000.L,posixacl,msize=104857600

# create a separate user with same uid and gid as your local user (check id -u)
groupadd -g $GID dev
useradd -u $UID -g dev -m dev -s /bin/bash

# compile and run tests as you would usually
su dev
cd /sio2jail
mkdir build
cd build
make sio2jail
make check

# to exit virtual machine use Ctrl+A X, see QEMU manpage for more escape sequences

Notes for developers
--------------------

Expand Down

0 comments on commit 411f442

Please sign in to comment.