@@ -118,6 +118,66 @@ following cmake options:
118118 -DTEST_COMPILER_IN_DOCKER_DEBIAN_TAG="bookworm"
119119 -DTEST_COMPILER_IN_DOCKER_GCC_VERSION="12"
120120
121+ Developing in QEMU
122+ ---------------
123+
124+ Sometimes it may be useful to run sio2jail in a virtual machine, e.g. to test running
125+ sio2jail under a different kernel version. In QEMU:
126+
127+ # get debian 11 QEMU image
128+ wget https://cdimage.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd64.qcow2
129+
130+ # reserve more space for QEMU image
131+ qemu-img resize debian-11-nocloud-amd64.qcow2 +10G
132+
133+ # start QEMU with KVM and sio2jail sources mounted with virtfs
134+ qemu-system-x86_64 \
135+ -enable-kvm \
136+ -m 4G \
137+ -nographic \
138+ -hda debian-11-nocloud-amd64.qcow2 \
139+ -virtfs local,path=$SIO2JAIL_SOURCES,security_model=mapped-xattr,mount_tag=sio2jail \
140+ -cpu max
141+
142+ # login as root (no password)
143+
144+ # resize root partition
145+ apt update
146+ apt install -y cloud-utils fdisk
147+ growpart /dev/sda 1
148+ resize2fs /dev/sda1
149+
150+ # install dependencies and utilities
151+ apt install -y \
152+ build-essential \
153+ cmake \
154+ gcc-multilib \
155+ g++-multilib \
156+ gperf \
157+ wget
158+
159+ # mount sio2jail sources
160+ mkdir /sio2jail
161+ mount -t 9p -o trans=virtio sio2jail /sio2jail -oversion=9p2000.L,posixacl,msize=104857600
162+
163+ # enable required sysctls
164+ sysctl -w kernel.perf_event_paranoid=-1
165+ sysctl -w kernel.unprivileged_userns_clone=1
166+
167+ # create a separate user with same uid and gid as your local user (check id -u)
168+ groupadd -g $GID dev
169+ useradd -u $UID -g dev -m dev -s /bin/bash
170+
171+ # compile and run tests as you would usually
172+ su dev
173+ cd /sio2jail
174+ mkdir build
175+ cd build
176+ make sio2jail
177+ make check
178+
179+ # to exit virtual machine use Ctrl+A X, see QEMU manpage for more escape sequences
180+
121181Notes for developers
122182--------------------
123183
0 commit comments