Skip to content
rapido-linuxPublic

About

Quickly test Linux kernel changes

Resources

Contributing

Stars

24 stars

Watchers

10 watching

Forks

Repository files navigation

Rapido helps you quickly test Linux kernel changes.

Quick Start

git clone https://github.com/rapido-linux/rapido.git && cd rapido
cargo build --offline --release
./rapido cut simple-example # boot a throwaway VM using the host kernel

Setup

Clone this repository and install the following dependencies:

  • QEMU: Boots a given VM image and compiled Linux kernel on the local system
  • systemd-networkd: Configures networking within Rapido VMs (optional)
  • iproute2: Configures Bridge and TAP devices on the host (optional)

Rapido obtains all dependencies from the local system; no magic images or internet downloads are necessary. Individual cut scripts may require extra local dependencies. E.g. cut/fstests_btrfs.sh runs xfstests, which is obtained from the configured FSTESTS_SRC path.

Rapido is primarily configured via rapido.conf. To boot a custom Linux kernel, copy rapido.conf.example and set the KERNEL_SRC parameter to the path of your compiled kernel source.

Network Configuration

Test VM images may be "cut" with or without network support. For networking, per-VM systemd-networkd configuration should be specified in the net-conf directory. An example is provided in net-conf.example. The rapido setup-network command should be run as root to configure a bridge network device and VM-assigned tap devices. By default, the bridge network is isolated, and isn't connected to any physical adapters.

Running

Depending on which kernel component or functionality you'd like to test, choose a cut script to generate a VM image. E.g.

./rapido cut fstests-btrfs

The cut script collects all required kernel modules and user-space dependencies from the local system and writes a VM initramfs image to initrds/myinitrd.

Rapido attempts to use the copy_file_range() syscall when copying file data to 4K-aligned initramfs destination offsets. This allows the host filesystem to avoid file data duplication by using reflinks where supported, e.g. on XFS and Btrfs.

Once generated, a VM using the image and kernel will boot immediately. Subsequent VMs can be booted manually via:

./rapido boot

Rapido can be used to test kernels on confined systems such as GitHub CI Runners. See Rapido's own .github/workflows/ci.yml file as an example for compiling and booting a mainline kernel VM from a ubuntu-latest GitHub Runner.

Adding Your Own Tests

Rapido can be easily extended to test most kernel functionality. Simply copy the cut/simple_example.sh and autorun/simple_example.sh scripts and modify them to suit your needs. The example scripts are fully annotated.

Feedback and Bug Reporting

Please raise any questions or issues upstream via https://github.com/rapido-linux/rapido/issues.

Also see troubleshooting tips.

Architecture

Architecture Diagram

ASCII art
                                   +------------------------+
                                   |                        |
                                   | Rapido 'cut' script    |
                                   |                        |
                                   | +--------------------+ |    +-----+
                                   | |                    | |    |     |
                                   | | File manifest:     | |    |     |
+------------------------+         | | • Kernel modules   | |    |     |
|                        |         | | • User space files | |    |     |
| Userspace dependencies |         | |                    | |    |     |
| E.g.                   |         | +---------+----------+ |    |     |
| • xfstests, blktests   |         |           |            <----+     |
| • Ceph conf + binaries |         | +---------v----------+ |    |     |
| • Samba                |         | |                    | |    |     |
| • etc.                 +--->--+----> "rapido-cut.rs"    | |    |  r  |
|                        |      |  | | initramfs creator  | |    |  a  |
+------------------------+      ^  | |                    | |    |  p  |
                                |  | +---------+----------+ |    |  i  |
+-------------------------+     |  |           |            |    |  d  |
|                         |     |  +------------------------+    |  o  |
| Rapido 'autorun' files  +-->--+              |                 |  .  |
|                         |     |    +---------v----------+      |  c  |
+-------------------------+     |    |                    |      |  o  |
                                |    | Initramfs          |      |  n  |
                                ^    | • Includes all     |      |  f  |
+------------------------+      |    |   kernel and user  |      |     |
| Compiled Linux Kernel  |      |    |   dependencies     |      |  /  |
|                        |      |    |                    |      |     |
| +---------+            |      |    +---------+----------+      |  n  |
| | Modules +---------------->--+              |                 |  e  |
| +---------+            |         +------------------------+    |  t  |
|                        |         |           |            |    |     |
| +---------+            |         |    "rapido-vm.rs"      |    |  c  |
| | bzImage +---------------->--+  |           |            |    |  o  |
| +---------+            |      |  |  +--------v----+       |    |  n  |
|                        |      |  |  |             |       <----+  f  |
+------------------------+      +-----> QEMU / KVM  |       |    |     |
                                   |  |             |       |    |     |
                                   |  +--------+----+       |    |     |
                                   |           |            |    +--+--+
                                   +------------------------+       |
   ===================                         |                    |
   | Virtual network O--------+    +-----------v---------------+    v
   =========^=========        |   ++                           |    |
            |                 |   !| Virtual Machine           |    |
            |                 |   !| • Console redirected via  |    |
            |                 +---oO   stdin and stdout        <----+
+-----------+------------+        !| • "rapido-init.rs" and    |    |
|                        |        !|   'autorun' executed      |    |
| Rapido "setup-network" |        !|                           |    v
|                        |        !+--------------------------++    |
+-----------^------------+        +~~~~~~~~~~~~~~~~~~~~~~~~~~~+     |
            |                                                       |
            +------------------------------<------------------------+

About

Quickly test Linux kernel changes

Resources

Contributing

Stars

24 stars

Watchers

10 watching

Forks

Releases

Contributors

Languages