tl;dr

  • Create a virtual machine (VM) with extracted kernel and initrd
  • QEMU to run VMs
  • libvirt to manage VMs and to automate
  • Configure SSH access from the host to the VM
  • Fetch the list of modules loaded in the guest kernel

Commands

launch_vm_qemu # launch a VM with qemu with the extracted kernel and initrd
create_vm_virsh # create a virsh VM with the extracted kernel and initrd
sudo systemctl start libvirtd && systemctl status libvirtd # start libvirtd and check its status
sudo virsh net-start default && sudo virsh net-list # start default network and list networks
sudo virsh console arm64 # re-attach to the console of the running vm
sudo virsh list --all # list all created VMs
sudo virsh dominfo arm64 # Show detailed information about a vm
sudo virsh start --console arm64 # start a previously created vm
sudo virsh shutdown arm64 # shutdown a vm gracefully
sudo virsh destroy arm64 # force shutdown a vm
sudo virsh undefine arm64 # remove stopped vm

Notes

To keep my activate.sh script versioned, I structured my setup as follows:

/home
β”œβ”€β”€ lk_dev
β”‚   β”œβ”€β”€ shared_arm64
β”‚   └── vm
β”‚       β”œβ”€β”€ arm64_boot
β”‚       β”‚   β”œβ”€β”€ initrd.img-6.1.0-43-arm64
β”‚       β”‚   └── vmlinuz-6.1.0-43-arm64
β”‚       β”œβ”€β”€ arm64_img.qcow2
β”‚       └── base_arm64_img.qcow2
└── pietro
    └── github
        └── open-source-development
            └── lk_dev
                └── activate.sh

The VMs had to be stored under the home directory for virsh access. Note that when creating the /home/lk_dev directory and it’s groups, I had to restart the computer, logging out and back in wasn’t enough.

The Debian image from the guide wasn’t available anymore, so the version used was the daily version 20260225-2399.

⚠️ Remember to start libvirtd after restarting the computer.

sudo systemctl start libvirtd
systemctl status libvirtd

The Debian image used doesn’t come with SSH installed, so I had to install it manually by running the VM with virsh and then executing:

sudo apt install update
sudo apt install openssh-server

After the setup was completed, I could access the VM successfully with SSH:

ssh root@192.168.122.135

Reference

Setting up a test environment for Linux Kernel Dev using QEMU and libvirt