Repository : ssh://git@open-mesh.org/doc
On branches: backup-redmine/2019-11-07,master
commit 71c3e48673e076b9844a37ef8edf4aa0fccbd3a9 Author: Sven Eckelmann sven@narfation.org Date: Sun Oct 27 13:48:57 2019 +0000
doc: open-mesh/Kernel_hacking_Debian_image
71c3e48673e076b9844a37ef8edf4aa0fccbd3a9 open-mesh/Kernel_hacking_Debian_image.textile | 120 +++++++------------------- 1 file changed, 29 insertions(+), 91 deletions(-)
diff --git a/open-mesh/Kernel_hacking_Debian_image.textile b/open-mesh/Kernel_hacking_Debian_image.textile index 20cd1e7..e1265fc 100644 --- a/open-mesh/Kernel_hacking_Debian_image.textile +++ b/open-mesh/Kernel_hacking_Debian_image.textile @@ -292,90 +292,47 @@ make olddefconfig make all -j$(nproc || echo 1) </code></pre>
-h2. Start of the simple environment +h2. Building the batman-adv module
-The two node environment must be started inside a screen session. The hub (bridge with 5 tap devices) has to be started first to have a simple network. A more complex network setup can be on the page [[vde switch interconnect]] and [[bridge interconnect]] +The kernel module can be build outside the virtual environment and shared over the 9p mount. The path to the kernel sources have to be provided to the make process
-<pre> -cat > hub.sh << "EOF" -#! /bin/sh -USER="$(whoami)" -BRIDGE=br-qemu - -sudo ip link add "${BRIDGE}" type bridge -for i in `seq 1 5`; do - sudo ip tuntap add dev tap$i mode tap user "$USER" - sudo ip link set tap$i up - sudo ip link set tap$i master "${BRIDGE}" -done - -sudo ip link set "${BRIDGE}" up -sudo ip addr replace 192.168.251.1/24 dev br-qemu -EOF +<pre><code class="shell"> +make KERNELPATH="$(pwd)/../linux-next" +</code></pre> + +The kernel module can also be compiled for better readability for the calltraces: + +<pre><code class="shell"> +make EXTRA_CFLAGS="-fno-inline -Og -fno-optimize-sibling-calls" KERNELPATH="$(pwd)/../linux-next" V=1 +</code></pre>
-chmod +x hub.sh -</pre> +h2. Start of the environment
-The @SHARED_PATH@ in run.sh has to be changed to a valid path which is used to share the precompiled batman-adv.ko and other tools +h3. interconnect initialization
-<pre> -cat > run.sh << "EOF" -#! /bin/bash +The [[open-mesh:OpenWrt_in_QEMU#interconnect-initialization|interconnect.sh from the OpenWrt environment]] can be reused again.
-if [ -z "${STY}" ]; then - echo "must be started inside a screen session" >&2 - exit 1 -fi +h3. VM instances bringup
-SHARED_PATH="$(pwd)" -NUM_SESSIONS=5 -BASE_IMG=debian.img +The [[open-mesh:OpenWrt_in_QEMU#VM-instances-bringup|run.sh from the OpenWrt environment]] can mostly be reused. There are only minimal adjustments required.
-BOOTARGS=() -BOOTARGS+=("-kernel") -BOOTARGS+=("linux-next/arch/x86/boot/bzImage") -BOOTARGS+=("-append") -BOOTARGS+=("root=/dev/vda rw console=ttyS0 nokaslr") - -for i in $(seq 1 "${NUM_SESSIONS}"); do - if [ ! -e "/sys/class/net/tap${i}" ]; then - echo "hub script must be started first to create tap$i interface" >&2 - exit 1 - fi -done - -for i in $(seq 1 "${NUM_SESSIONS}"); do - normalized_id="$(echo "$i"|awk '{ printf "%02d\n",$1 }')" - twodigit_id="$(echo $i|awk '{ printf "%02X", $1 }')" - - qemu-img create -b "${BASE_IMG}" -f qcow2 root.cow$i - screen qemu-system-x86_64 -enable-kvm -name "instance${i}" \ - "${BOOTARGS[@]}" \ - -display none -no-user-config -nodefaults \ - -m 512 -device virtio-balloon \ - -cpu host -smp 2 -machine q35,accel=kvm,usb=off,dump-guest-core=off \ - -drive file=root.cow$i,if=virtio,cache=unsafe \ - -nic tap,ifname=tap$i,script=no,model=virtio-net-pci,mac=02:ba:de:af:fe:"${twodigit_id}" \ - -nic user,model=virtio-net-pci,mac=06:ba:de:af:fe:"${twodigit_id}" \ - -virtfs local,path="${SHARED_PATH}",security_model=none,mount_tag=host \ - -gdb tcp:127.0.0.1:$((23000+$i)) \ - -device virtio-rng-pci \ - -serial mon:stdio - sleep 1 -done -EOF +The BASE_IMG is of course no longer the same because a new image "debian.img" was created for our new environment. The image also doesn't contain a bootloader or kernel anymore. These must now be supplied manually to qemu. + +<pre><code class="shell"> +BASE_IMG=debian.img +BOOTARGS+=("-kernel" "linux-next/arch/x86/boot/bzImage") +BOOTARGS+=("-append" "root=/dev/vda rw console=ttyS0 nokaslr") +</code></pre>
-chmod +x run.sh -</pre> +h3. Automatic test initialization
-The test-init.sh script can be used to automatically initialize the testsetup during boot: +The [[open-mesh:OpenWrt_in_QEMU#Automatic-test-initialization|test-init.sh from the OpenWrt environment]] is always test specific. But its main functionality is still the same as before. A simple example would be:
-<pre> +<pre><code class="shell"> cat > test-init.sh << "EOF" #! /bin/sh
set -e -export PATH="/host/batctl/:$PATH"
## get internet access dhclient enp0s2 @@ -396,27 +353,8 @@ ip link set up dev bat0 EOF
chmod +x test-init.sh -</pre> - - -Everything can then be started up inside a screen session - -<pre> -screen -./hub.sh -./run.sh -</pre> - -h2. Building the batman-adv module - -The kernel module can be build outside the virtual environment and shared over the 9p mount. The path to the kernel sources have to be provided to the make process - -<pre> -make KERNELPATH="$(pwd)/../linux-next" -</pre> +</code></pre>
-The kernel module can also be compiled for better readability for the calltraces: +h2. Start
-<pre> -make EXTRA_CFLAGS="-fno-inline -Og -fno-optimize-sibling-calls" KERNELPATH="$(pwd)/../linux-next" V=1 -</pre> \ No newline at end of file +The startup method [[open-mesh:OpenWrt_in_QEMU#Start|from the OpenWrt environment]] should be used here. \ No newline at end of file