[RFC PATCH 1/3] labs: add lab infrastructure and documentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Octavian Purdila <tavi@xxxxxxxxx>

The Linux kernel labs documentation is a collection of "labs" for
various device driver topics. For each topic there are two parts: a
walk-through which explain the basic concepts and a hands-on part which
contains a few exercises.

This commit also adds the labs infrastructure which allows us to build
and test kernel modules in a qemu environment.

Signed-off-by: Octavian Purdila <tavi@xxxxxxxxx>
Signed-off-by: Daniel Baluta <daniel.baluta@xxxxxxxxx>
---
 Documentation/labs/conf.py                |   1 +
 Documentation/labs/exercises-summary.hrst |  42 ++++++++
 Documentation/labs/exercises.rst          |  82 ++++++++++++++++
 Documentation/labs/index.rst              |  33 +++++++
 Documentation/labs/subst.hrst             |   4 +
 Documentation/labs/vm.rst                 | 157 ++++++++++++++++++++++++++++++
 README.rst                                |   1 +
 tools/labs/.gitignore                     |   7 ++
 tools/labs/Makefile                       |  42 ++++++++
 tools/labs/qemu/Makefile                  |  61 ++++++++++++
 tools/labs/qemu/create_net.sh             |  37 +++++++
 tools/labs/qemu/kernel_config.x86         |  79 +++++++++++++++
 tools/labs/qemu/prepare-image.sh          |  28 ++++++
 tools/labs/qemu/qemu.sh                   |  21 ++++
 tools/labs/templates/generate_skels.py    |  55 +++++++++++
 15 files changed, 650 insertions(+)
 create mode 100644 Documentation/labs/conf.py
 create mode 100644 Documentation/labs/exercises-summary.hrst
 create mode 100644 Documentation/labs/exercises.rst
 create mode 100644 Documentation/labs/index.rst
 create mode 100644 Documentation/labs/subst.hrst
 create mode 100644 Documentation/labs/vm.rst
 create mode 120000 README.rst
 create mode 100644 tools/labs/.gitignore
 create mode 100644 tools/labs/Makefile
 create mode 100644 tools/labs/qemu/Makefile
 create mode 100755 tools/labs/qemu/create_net.sh
 create mode 100644 tools/labs/qemu/kernel_config.x86
 create mode 100755 tools/labs/qemu/prepare-image.sh
 create mode 100755 tools/labs/qemu/qemu.sh
 create mode 100755 tools/labs/templates/generate_skels.py

diff --git a/Documentation/labs/conf.py b/Documentation/labs/conf.py
new file mode 100644
index 0000000..25a53c0
--- /dev/null
+++ b/Documentation/labs/conf.py
@@ -0,0 +1 @@
+rst_prolog = ".. include:: subst.hrst"
diff --git a/Documentation/labs/exercises-summary.hrst b/Documentation/labs/exercises-summary.hrst
new file mode 100644
index 0000000..0cddaa2
--- /dev/null
+++ b/Documentation/labs/exercises-summary.hrst
@@ -0,0 +1,42 @@
+
+To solve exercises need to perform these steps:
+
+   * prepare skeletons from templates
+   * build modules
+   * copy modules to VM
+   * start the VM and test the module in the VM.
+
+The current lab name is |LAB_NAME|. See the exercises for the task name.
+
+.. container:: toggle
+
+   .. container:: header
+
+      **See details**
+
+   The skeleton code is generated from full source examples located in
+   ``tools/labs/templates``. To solve the tasks start by generating
+   the skeleton code:
+
+   .. parsed-literal:: shell
+
+      tools/labs $ make clean
+      tools/labs $ LABS=<lab name>/<task name> make skels
+
+   Where task name is defined for each task. Once the skelton drivers are
+   generated build the source:
+
+   .. code-block:: shell
+
+      tools/labs $ make build
+
+   Then copy the modules and start the VM:
+
+   .. code-block:: shell
+
+      tools/labs $ make copy
+      tools/labs $ make boot
+
+   The modules are placed in /home/root/skels/|LAB_NAME|/<task_name>.
+
+   Review the `Exercises`_ section for more detailed information.
diff --git a/Documentation/labs/exercises.rst b/Documentation/labs/exercises.rst
new file mode 100644
index 0000000..7120efa
--- /dev/null
+++ b/Documentation/labs/exercises.rst
@@ -0,0 +1,82 @@
+Exercises
+=========
+
+In order to facilitate learning each topic has a hands-on exercises
+section which will contain in-depth, incremental clues on how to solve
+one or multiple tasks. To focus on a particular issue most of the
+tasks will be performed on existing skeleton drivers. Each skeleton
+driver has clearly marked sections that needs to be filled in order to
+complete the tasks.
+
+The skeleton drivers are generated from full source examples located
+in tools/labs/templates. To solve tasks you start by generating the
+skeleton drivers, running the **skels** target in *tools/labs*. To
+keep the workspace clean it is recommended to generate the skeletons
+for one lab only and clean the workspace before start working on a new
+lab. Labs can be selecting by using the **LABS** variable:
+
+.. code-block:: shell
+
+   tools/labs $ make clean
+   tools/labs $ LABS=kernel_modules make skels
+		
+   tools/labs $ ls skels/kernel_modules/
+   1-2-test-mod  3-error-mod  4-multi-mod  5-oops-mod  6-cmd-mod  \
+   7-list-proc  8-kprobes  9-kdb
+
+You can also uses the same variable to generate skeletons for specific
+tasks:
+
+.. code-block:: shell
+
+   tools/labs $ LABS="kernel_modules/6-cmd-mod kernel_modules/8-kprobes" make skels
+		
+   tools/labs$ ls skels/kernel_modules
+   6-cmd-mod  8-kprobes
+
+
+For each task you may have multiple steps to perform, usually
+incremental. These steps are marked in the code source as well as in
+the lab exercises with the keyword *TODO*. If we have multiple steps
+to perform they will be prefix by a number, like *TODO1*, *TODO2*,
+etc. If no number is used it is assumed to be the one and only
+step. If you want to resume a tasks from a certain step, you can using
+the **TODO** variable. The following example will generate the
+skeleton with the first *TODO* step resolved:
+
+.. code-block:: shell
+
+   tools/labs $ TODO=2 LABS="kernel_modules/8-kprobes" skels
+
+Once the skelton drivers are generated you can build them with the
+**build** make target:
+
+.. code-block:: shell
+
+   tools/labs $ make build
+   echo "# autogenerated, do not edit " > skels/Kbuild
+   for i in ./kernel_modules/8-kprobes; do echo "obj-m += $i/" >> skels/Kbuild; done
+   make -C /home/tavi/src/linux M=/home/tavi/src/linux/tools/labs/skels ARCH=x86 modules
+   make[1]: Entering directory '/home/tavi/src/linux'
+   CC [M]  /home/tavi/src/linux/tools/labs/skels/./kernel_modules/8-kprobes/kprobes.o
+   Building modules, stage 2.
+   MODPOST 1 modules
+   CC      /home/tavi/src/linux/tools/labs/skels/./kernel_modules/8-kprobes/kprobes.mod.o
+   LD [M]  /home/tavi/src/linux/tools/labs/skels/./kernel_modules/8-kprobes/kprobes.ko
+   make[1]: Leaving directory '/home/tavi/src/linux'
+
+
+To copy the drivers to the VM you can use either use ssh or update the
+VM image directly using the **copy** target:
+
+.. code-block:: shell
+
+   tools/labs $ make copy
+   ...
+   'skels/kernel_modules/8-kprobes/kprobes.ko' -> '/tmp/tmp.4UMKcISmQM/home/root/skels/kernel_modules/8-kprobes/kprobes.ko'
+
+.. attention:: The **copy** target will faili if the VM is
+   running. This is intentional so that the we avoid corrupting the
+   filesystem.
+
+
diff --git a/Documentation/labs/index.rst b/Documentation/labs/index.rst
new file mode 100644
index 0000000..9e61a8e
--- /dev/null
+++ b/Documentation/labs/index.rst
@@ -0,0 +1,33 @@
+Linux device driver labs
+========================
+
+This is a collection of "howtos" for various device driver topics. For
+each topic there are two parts:
+
+* a walk-through the topic which contains an overview, the main
+  abstractions, simple examples and pointers to APIs
+
+* a hands-on part which contains a few exercises that should be
+  resolved by the student; to focus on the topic at hand, the student
+  is presented with a starting coding skeleton and with in-depth tips
+  on how to solve the exercises
+
+They are based on the labs of the `Operatings Systems 2
+<http://ocw.cs.pub.ro/courses/so2>`_ course, Computer Science
+department, Faculty of Automatic Control and Computers, Politehnica
+Univesity of Bucharest.
+
+You can get the latest version at http://github.com/linux-kernel-labs.
+
+To get started build the documentation from the sources:
+
+.. code-block:: c
+   
+   cd tools/labs && make docs
+
+then point your browser at **Documentation/output/labs/index.html**.
+
+.. toctree::
+
+   vm.rst
+   exercises.rst
diff --git a/Documentation/labs/subst.hrst b/Documentation/labs/subst.hrst
new file mode 100644
index 0000000..d0f113b
--- /dev/null
+++ b/Documentation/labs/subst.hrst
@@ -0,0 +1,4 @@
+.. |LXR| replace:: LXR
+.. _LXR: http://elixir.free-electrons.com/linux/latest/source
+
+
diff --git a/Documentation/labs/vm.rst b/Documentation/labs/vm.rst
new file mode 100644
index 0000000..8517308
--- /dev/null
+++ b/Documentation/labs/vm.rst
@@ -0,0 +1,157 @@
+=====================
+Virtual Machine Setup
+=====================
+
+Exercises are designed to run on a qemu based virtual machine. In
+order to run the virtual machine you will need following packages:
+
+* build-essential
+* qemu-system-x86
+* qemu-system-arm
+* kvm
+* python3
+
+The virtual machine setup uses prebuild Yocto images that it downloads
+from downloads.yocyoproject.org and a kernel image that it builds
+itself. The following images are supported:
+
+* core-image-minimal-qemu
+* core-image-minimal-dev-qemu
+* core-image-sato-dev-qemu
+* core-image-sato-qemu
+* core-image-sato-sdk-qemu
+
+and can be selected from tools/labs/qemu/Makefile.
+
+
+Starting the VM
+---------------
+
+The virtual machine scripts are available in tools/labs/qemeu and you
+can can start the virtual machine by using the **boot** make target in
+tools/labs:
+
+.. code-block:: shell
+
+   ~/src/linux/tools/labs$ make boot
+   ARCH=x86 qemu/qemu.sh -kernel zImage.x86 -device virtio-serial \
+		-chardev pty,id=virtiocon0 -device virtconsole,chardev=virtiocon0 \
+		-net nic,model=virtio,vlan=0 -net tap,ifname=tap0,vlan=0,script=no,downscript=no\
+		-drive file=rootfs.img,if=virtio,format=raw --append "root=/dev/vda console=hvc0" \
+		--display none -s
+   char device redirected to /dev/pts/19 (label virtiocon0)
+
+
+.. note:: To show the qemu console use "QEMU_DISPLAY=sdl make
+          boot". This will show the VGA output and will also give
+          access to the standard keyboard.
+   
+Connecting to the VM
+--------------------
+
+Once the machine is booted you can connect to it on the serial port. A
+link named *serial.pts* is created to the right emulated serial port
+and you can use **minicom**, **picocom** to connect to the virtual
+machine from the host:
+
+.. code-block:: shell
+
+   $ minicom -D serial.pts
+
+   Poky (Yocto Project Reference Distro) 2.3 qemux86 /dev/hvc0
+
+   qemux86 login: root
+   root@qemux86:~#
+
+Networking is also setup and you can use ssh to connect to the virtual
+machine after finding out the allocated IP address:
+
+.. code-block:: shell
+
+   $ mincom -D serial.pts
+
+   Poky (Yocto Project Reference Distro) 2.3 qemux86 /dev/hvc0
+
+   qemux86 login: root
+   root@qemux86:~# ifconfig
+   eth0      Link encap:Ethernet  HWaddr 52:54:00:12:34:56
+             inet addr:172.20.0.6  Bcast:172.20.0.255  Mask:255.255.255.0
+	     UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
+	     RX packets:41 errors:0 dropped:0 overruns:0 frame:0
+	     TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
+	     collisions:0 txqueuelen:1000
+	     RX bytes:7578 (7.4 KiB)  TX bytes:1296 (1.2 KiB)
+
+   lo        Link encap:Local Loopback
+	     inet addr:127.0.0.1  Mask:255.0.0.0
+	     inet6 addr: ::1%134535719/128 Scope:Host
+	     UP LOOPBACK RUNNING  MTU:65536  Metric:1
+	     RX packets:0 errors:0 dropped:0 overruns:0 frame:0
+	     TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
+	     collisions:0 txqueuelen:1000
+	     RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
+
+   $ ssh root@172.20.0.6
+   The authenticity of host '172.20.0.6 (172.20.0.6)' can't be established.
+   RSA key fingerprint is SHA256:CW1opJUHi4LDt1lnKjBVv12kXZ4s+8rreMBm5Jsdm00.
+   Are you sure you want to continue connecting (yes/no)? yes
+   Warning: Permanently added '172.20.0.6' (RSA) to the list of known hosts.
+   root@qemux86:~#
+
+.. attention:: The Yocto core-image-minimal-qemu does not include an
+               SSH server, so you will not able to connect via ssh if
+               you are using this image.
+
+
+Connecting a debugger to the VM kernel
+--------------------------------------
+
+You can connect gdb to the running VM kernel and inspect the state of
+the kernel by running the *gdb* target from tools/labs:
+
+.. code-block :: shell
+
+   $ make gdb
+   ln -fs /home/tavi/src/linux/vmlinux vmlinux
+   gdb -ex "target remote localhost:1234" vmlinux
+   GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
+   Copyright (C) 2016 Free Software Foundation, Inc.
+   License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+   This is free software: you are free to change and redistribute it.
+   There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
+   and "show warranty" for details.
+   This GDB was configured as "x86_64-linux-gnu".
+   Type "show configuration" for configuration details.
+   For bug reporting instructions, please see:
+   <http://www.gnu.org/software/gdb/bugs/>.
+   Find the GDB manual and other documentation resources online at:
+   <http://www.gnu.org/software/gdb/documentation/>.
+   For help, type "help".
+   Type "apropos word" to search for commands related to "word"...
+   Reading symbols from vmlinux...done.
+   Remote debugging using localhost:1234
+   0xc13cf2f2 in native_safe_halt () at ./arch/x86/include/asm/irqflags.h:53
+   53asm volatile("sti; hlt": : :"memory");
+   (gdb) bt
+   #0  0xc13cf2f2 in native_safe_halt () at ./arch/x86/include/asm/irqflags.h:53
+   #1  arch_safe_halt () at ./arch/x86/include/asm/irqflags.h:95
+   #2  default_idle () at arch/x86/kernel/process.c:341
+   #3  0xc101f136 in arch_cpu_idle () at arch/x86/kernel/process.c:332
+   #4  0xc106a6dd in cpuidle_idle_call () at kernel/sched/idle.c:156
+   #5  do_idle () at kernel/sched/idle.c:245
+   #6  0xc106a8c5 in cpu_startup_entry (state=<optimized out>)
+   at kernel/sched/idle.c:350
+   #7  0xc13cb14a in rest_init () at init/main.c:415
+   #8  0xc1507a7a in start_kernel () at init/main.c:679
+   #9  0xc10001da in startup_32_smp () at arch/x86/kernel/head_32.S:368
+   #10 0x00000000 in ?? ()
+   (gdb)
+
+Rebuild the kernel image
+------------------------
+
+The kernel image is built the first time the VM is started. To rebuild
+the kernel remove the **zImage** file and run the zImage target (or
+start the VM again).
+
+.. add info about how to update the image
diff --git a/README.rst b/README.rst
new file mode 120000
index 0000000..a030cc1
--- /dev/null
+++ b/README.rst
@@ -0,0 +1 @@
+Documentation/labs/index.rst
\ No newline at end of file
diff --git a/tools/labs/.gitignore b/tools/labs/.gitignore
new file mode 100644
index 0000000..a6940b6
--- /dev/null
+++ b/tools/labs/.gitignore
@@ -0,0 +1,7 @@
+skels
+vmlinux
+zImage
+serial.pts
+rootfs.img
+core-image-minimal-*.ext4
+.modinst
\ No newline at end of file
diff --git a/tools/labs/Makefile b/tools/labs/Makefile
new file mode 100644
index 0000000..d218a90
--- /dev/null
+++ b/tools/labs/Makefile
@@ -0,0 +1,42 @@
+KDIR=$(shell realpath $(PWD)/../..)
+
+LABS?=$(shell cd templates && find -mindepth 1 -maxdepth 1 -type d)
+MODS=$(shell cd templates && find $(LABS) -mindepth 1 -name Kbuild | xargs dirname)
+TODO?=0
+
+include qemu/Makefile
+
+skels:
+	mkdir -p skels
+	cd templates && find $(LABS) -type f | xargs ./generate_skels.py --output ../skels --todo $(TODO)
+	rm -f skels/Kbuild
+
+skels/Kbuild:
+	echo "# autogenerated, do not edit " > $@
+	echo "ccflags-y += -Wno-unused-function -Wno-unused-label -Wno-unused-variable " >> $@
+	for i in $(shell cd skels && find -mindepth 1 -name Kbuild | xargs dirname); do echo "obj-m += $$i/" >> $@; done
+
+build: $(KCONFIG) skels/Kbuild
+	$(MAKE) -C $(KDIR) M=$(PWD)/skels ARCH=$(ARCH) modules
+	for i in $(shell find skels -name Makefile | xargs dirname); do $(MAKE) -C $$i; done
+
+TEMPDIR := $(shell mktemp -u)
+
+copy: $(YOCTO_IMAGE)
+	if  [ -e qemu.mon ]; then exit 1; fi
+	mkdir $(TEMPDIR)
+	sudo mount -t ext4 -o loop $(YOCTO_IMAGE) $(TEMPDIR)
+	find skels -type f \( -name *.ko -or -executable \) | xargs sudo cp --parents -t $(TEMPDIR)/home/root || true
+	sudo umount $(TEMPDIR)
+	rmdir $(TEMPDIR)
+
+docs:
+	$(MAKE) -C $(KDIR) DOCBOOKS= SPHINXDIRS=labs htmldocs
+
+slides:
+	$(MAKE) -C $(KDIR) BUILDDIR=$(KDIR)/Documentation/output/slides DOCBOOKS= SPHINXDIRS=labs slides
+
+clean::
+	rm -rf skels
+
+.PHONY: skels
diff --git a/tools/labs/qemu/Makefile b/tools/labs/qemu/Makefile
new file mode 100644
index 0000000..40e9181
--- /dev/null
+++ b/tools/labs/qemu/Makefile
@@ -0,0 +1,61 @@
+QEMU_DISPLAY ?= none
+ARCH ?= x86
+ifeq ($(ARCH),x86)
+b = b
+endif
+ZIMAGE=$(KDIR)/arch/$(ARCH)/boot/$(b)zImage
+KCONFIG=$(KDIR)/.config
+
+YOCTO_URL=http://downloads.yoctoproject.org/releases/yocto/yocto-2.3/machines/qemu/qemu$(ARCH)/
+YOCTO_IMAGE=core-image-minimal-qemu$(ARCH).ext4
+#YOCTO_IMAGE=core-image-minimal-dev-qemu$(ARCH).ext4
+#YOCTO_IMAGE=core-image-sato-dev-qemu$(ARCH).ext4
+#YOCTO_IMAGE=core-image-sato-qemu$(ARCH).ext4
+#YOCTO_IMAGE=core-image-sato-sdk-qemu$(ARCH).ext4
+
+QEMU_OPTS = -kernel $(ZIMAGE) \
+	-device virtio-serial \
+	-chardev pty,id=virtiocon0 -device virtconsole,chardev=virtiocon0 \
+	-net nic,model=virtio,vlan=0 -net tap,ifname=tap0,vlan=0,script=no,downscript=no \
+	-drive file=$(YOCTO_IMAGE),if=virtio,format=raw \
+	--append "root=/dev/vda console=hvc0" \
+	--display $(QEMU_DISPLAY) -s
+
+boot: .modinst tap0
+	ARCH=$(ARCH) qemu/qemu.sh $(QEMU_OPTS)
+
+TEMPDIR := $(shell mktemp -u)
+
+$(KCONFIG): qemu/kernel_config.x86
+	cp $^ $@
+	$(MAKE) -C $(KDIR) oldnoconfig
+
+zImage: $(ZIMAGE)
+
+$(ZIMAGE): $(KCONFIG)
+	$(MAKE) -C $(KDIR)
+	$(MAKE) -C $(KDIR) modules
+
+.modinst: $(ZIMAGE) $(YOCTO_IMAGE)
+	mkdir $(TEMPDIR)
+	sudo mount -t ext4 -o loop $(YOCTO_IMAGE) $(TEMPDIR)
+	sudo $(MAKE) -C $(KDIR) modules_install INSTALL_MOD_PATH=$(TEMPDIR)
+	sudo umount $(TEMPDIR)
+	rmdir $(TEMPDIR)
+	sleep 1 && touch .modinst
+
+gdb: $(ZIMAGE)
+	gdb -ex "target remote localhost:1234" $(KDIR)/vmlinux
+
+$(YOCTO_IMAGE):
+	wget $(YOCTO_URL)/$(YOCTO_IMAGE)
+	sudo qemu/prepare-image.sh $(YOCTO_IMAGE)
+
+tap0:
+	qemu/create_net.sh $@
+
+clean::
+	rm -f .modinst
+
+.PHONY: clean tap0
+
diff --git a/tools/labs/qemu/create_net.sh b/tools/labs/qemu/create_net.sh
new file mode 100755
index 0000000..3f76547
--- /dev/null
+++ b/tools/labs/qemu/create_net.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+if test $# -ne 1; then
+    echo "Usage: $0 <device>" 1>&2
+    echo " <device> must be tap0 or tap1"
+    exit 1
+fi
+
+device=$1
+
+case "$device" in
+    "tap0")
+        subnet=172.213.0
+        ;;
+    "tap1")
+        subnet=172.214.0
+        ;;
+    *)
+        echo "Unknown device" 1>&2
+        exit 1
+        ;;
+esac
+
+# If device doesn't exist add device.
+if ! /sbin/ip link show dev "$device" > /dev/null 2>&1; then
+    sudo ip tuntap add mode tap user "$USER" dev "$device"
+fi
+
+# Reconfigure just to be sure (even if device exists).
+sudo /sbin/ip address flush dev "$device"
+sudo /sbin/ip link set dev "$device" down
+sudo /sbin/ip address add $subnet.1/24 dev "$device"
+sudo /sbin/ip link set dev "$device" up
+
+mkdir -p $PWD/tftp
+
+sudo dnsmasq --enable-tftp --tftp-root=$PWD/tftp --no-resolv --no-hosts --bind-interfaces --interface $device -F $subnet.2,$subnet.20 -x dnsmasq.pid || true
diff --git a/tools/labs/qemu/kernel_config.x86 b/tools/labs/qemu/kernel_config.x86
new file mode 100644
index 0000000..bb18e79
--- /dev/null
+++ b/tools/labs/qemu/kernel_config.x86
@@ -0,0 +1,79 @@
+# CONFIG_64BIT is not set
+# CONFIG_LOCALVERSION_AUTO is not set
+# CONFIG_CROSS_MEMORY_ATTACH is not set
+# CONFIG_USELIB is not set
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_COMPAT_BRK is not set
+CONFIG_SLAB=y
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_SMP=y
+# CONFIG_X86_EXTENDED_PLATFORM is not set
+# CONFIG_SCHED_OMIT_FRAME_POINTER is not set
+# CONFIG_X86_MCE is not set
+# CONFIG_MICROCODE is not set
+# CONFIG_COMPACTION is not set
+# CONFIG_SECCOMP is not set
+# CONFIG_RELOCATABLE is not set
+# CONFIG_SUSPEND is not set
+CONFIG_BINFMT_AOUT=y
+CONFIG_BINFMT_MISC=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_UEVENT_HELPER is not set
+CONFIG_DEVTMPFS=y
+# CONFIG_STANDALONE is not set
+# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+CONFIG_VIRTIO_BLK=y
+CONFIG_NETDEVICES=y
+CONFIG_VIRTIO_NET=y
+# CONFIG_DEVMEM is not set
+CONFIG_VIRTIO_CONSOLE=y
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_HID_A4TECH is not set
+# CONFIG_HID_APPLE is not set
+# CONFIG_HID_BELKIN is not set
+# CONFIG_HID_CHERRY is not set
+# CONFIG_HID_CHICONY is not set
+# CONFIG_HID_CYPRESS is not set
+# CONFIG_HID_EZKEY is not set
+# CONFIG_HID_KENSINGTON is not set
+# CONFIG_HID_LOGITECH is not set
+# CONFIG_HID_MICROSOFT is not set
+# CONFIG_HID_MONTEREY is not set
+# CONFIG_USB_SUPPORT is not set
+CONFIG_VIRTIO_PCI=y
+# CONFIG_X86_PLATFORM_DEVICES is not set
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_EXT4_FS_SECURITY=y
+CONFIG_EXT4_ENCRYPTION=y
+# CONFIG_DNOTIFY is not set
+# CONFIG_INOTIFY_USER is not set
+CONFIG_PROC_KCORE=y
+CONFIG_TMPFS=y
+CONFIG_TMPFS_POSIX_ACL=y
+CONFIG_CONFIGFS_FS=y
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_INFO_DWARF4=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+# CONFIG_UNUSED_SYMBOLS is not set
+# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_DEBUG_SLAB=y
+CONFIG_DEBUG_SLAB_LEAK=y
+CONFIG_DEBUG_RT_MUTEXES=y
+CONFIG_PROVE_LOCKING=y
+CONFIG_DEBUG_ATOMIC_SLEEP=y
+# CONFIG_FTRACE is not set
+# CONFIG_X86_VERBOSE_BOOTUP is not set
+# CONFIG_X86_DEBUG_FPU is not set
+CONFIG_CRYPTO_ECHAINIV=y
+# CONFIG_VIRTUALIZATION is not set
diff --git a/tools/labs/qemu/prepare-image.sh b/tools/labs/qemu/prepare-image.sh
new file mode 100755
index 0000000..459fa74
--- /dev/null
+++ b/tools/labs/qemu/prepare-image.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+size=$(stat -c%s $1)
+if [ $size -lt 50000000 ]; then
+    e2fsck -f $1
+    resize2fs $1 50M
+fi
+
+TMP=$(mktemp -d)
+
+mount -t ext4 -o loop $1 $TMP
+
+# add console
+echo "hvc0:12345:respawn:/sbin/getty 115200 hvc0" >> $TMP/etc/inittab
+
+# add more vty
+cat >> $TMP/etc/inittab <<EOF
+2:12345:respawn:/sbin/getty 38400 tty2
+3:12345:respawn:/sbin/getty 38400 tty3
+4:12345:respawn:/sbin/getty 38400 tty4
+5:12345:respawn:/sbin/getty 38400 tty5
+EOF
+
+# enable networking
+echo -e "auto eth0\niface eth0 inet dhcp" >> $TMP/etc/network/interfaces
+
+sudo umount $TMP
+rmdir $TMP
diff --git a/tools/labs/qemu/qemu.sh b/tools/labs/qemu/qemu.sh
new file mode 100755
index 0000000..329ef34
--- /dev/null
+++ b/tools/labs/qemu/qemu.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# This script runs qemu and creates a symbolic link named serial.pts
+# to the qemu serial console (pts based). Because the qemu pts
+# allocation is dynamic, it is preferable to have a stable path to
+# avoid visual inspection of the qemu output when connecting to the
+# serial console.
+
+case $ARCH in
+    x86)
+	qemu=qemu-system-i386
+	;;
+    arm)
+	qemu=qemu-system-arm
+	;;
+esac
+
+echo info chardev | nc -U -l qemu.mon | egrep -o "/dev/pts/[0-9]*" | xargs -I PTS ln -fs PTS serial.pts &
+$qemu "$@" -monitor unix:qemu.mon
+rm qemu.mon 
+rm serial.pts
diff --git a/tools/labs/templates/generate_skels.py b/tools/labs/templates/generate_skels.py
new file mode 100755
index 0000000..17a6ea6
--- /dev/null
+++ b/tools/labs/templates/generate_skels.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python3 -u
+
+import argparse, fnmatch, glob, os.path, re, sys, shutil
+
+parser = argparse.ArgumentParser(description='Generate skeletons sources from full sources')
+parser.add_argument('paths', metavar='path', nargs='+', help='list of files to process')
+parser.add_argument('--output', help='output dir to copy processed files')
+parser.add_argument('--todo', type=int, help='don\'t remove TODOs less then this', default=1)
+args = parser.parse_args()
+
+def process_file(p, pattern):
+	f = open(p, "r")
+	g = open(os.path.join(args.output, p), "w")
+	skip_lines = 0
+	for l in f.readlines():
+		if skip_lines > 0:
+			skip_lines -= 1
+			m = re.search(pattern, l)
+			if m :
+				l = "%s%s%s\n" % (m.group(1), m.group(2), m.group(4))
+				g.write(l)
+			continue
+		m = re.search(pattern, l)
+		if m:
+			todo=1
+			if m.group(2):
+				todo = int(m.group(2))
+			if todo >= args.todo:
+				if m.group(3):
+					skip_lines = int(m.group(3))
+				else:
+					skip_lines = 1
+			l = "%s%s%s\n" % (m.group(1), m.group(2), m.group(4))
+		g.write(l)
+
+for p in args.paths:
+	print("skel %s" % (p), sep = '')
+	name=os.path.basename(p)
+	try:
+		os.makedirs(os.path.join(args.output, os.path.dirname(p)))
+	except:
+		pass
+
+	copy = False
+	if name == "Kbuild" or name == "Makefile":
+		pattern="(^#\s*TODO)([0-9]*)\/?([0-9]*)(:.*)"
+	elif fnmatch.fnmatch(name, '*.c') or fnmatch.fnmatch(name, '*.h'):
+		pattern="(.*/\*\s*TODO)([ 0-9]*)/?([0-9]*)(:.*)"
+	else:
+		copy = True
+
+	if copy:
+		shutil.copyfile(p, os.path.join(args.output, p))
+	else:
+		process_file(p, pattern)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux