pmem/run_qemu/run-qemu
Claude Code and agent skill by pmem/run_qemu
- community
Checking that the SKILL.md file is still in the repository.
Use this skill for building Linux kernels and booting QEMU VMs with custom topologies (CXL, NUMA, NVDIMMs). Covers building, launching, testing inside VMs, and managing VM lifecycle via MCP tools or CLI.
Install
npx vskill@latest install pmem/run_qemu/run-qemuSKILL.md
run_qemu
Overview
run_qemu builds a Linux kernel from a source tree, creates a Fedora rootfs using mkosi, installs the kernel into it, and boots QEMU with a generated command line. It supports complex NUMA/CXL/NVDIMM topologies and provides SSH access to the guest.
Run from the root of a Linux kernel tree. The run_qemu.sh script should be in the user's PATH.
Prerequisites: mkosi, qemu-system-x86_64, rsync, dracut, KVM-enabled host, nopasswd sudo preferred.
MCP Tools (Primary Agent Interface)
When the run-qemu MCP server is available, use these tools for all VM operations. They provide structured, async-safe interaction with run_qemu.
Typical Agent Workflow
Tool Reference
vm_start — Build kernel and launch VM
Builds the kernel, creates/updates the rootfs, and launches QEMU in the background. Returns immediately with instance info. Runs make olddefconfig by default to avoid interactive config prompts.
Typed parameters (common options):
| Parameter | Type | Default | Description | |
|---|---|---|---|---|
linux_dir | str | . | Path to the Linux kernel tree | |
rebuild | str | kmod | kmod (rebuild kernel+modules), img (full rootfs), wipe (clean slate), none (just boot) | |
preset | str | small | NUMA topology: tiny, small, med, large, huge | |
cxl | bool | false | Enable CXL topology | |
cxl_test | bool | false | CXL unit test environment (includes cxl_test kernel module) | |
nfit_test | bool | false | NFIT unit test environment (includes libnvdimm test modules). Overrides preset to med. | |
defconfig | bool | true | Run make olddefconfig before building | |
instance | int | 0 | Instance number — determines SSH port (10022+N) | |
timeout_minutes | int | 0 | Auto-kill timeout in minutes (0=disabled) |
`extra_args` (str): Any additional run_qemu.sh options not covered above, passed verbatim. Examples:
"--cxl-debug"— enable CXL dyndbg"--hmat"— enable HMAT table"--kcmd-append myfile.txt"— append kernel command line from file"--no-kvm"— disable KVM (for environments without hardware virtualization)
vm_status — Check VM state
Returns the current state: starting, ready, exited, or unknown. When ready, the SSH connection string is included.
vm_run — Execute command in VM
Runs a shell command via SSH. Returns stdout, stderr, and exit code. The VM must be in ready state.
vm_dmesg — Read kernel log
Reads dmesg from the VM. Supports filtering by level (err, warn) and grep pattern.
vm_log — Read console log
Reads the QEMU console log file. Supports tail (last N lines) and grep filtering.
vm_stop — Stop VM
Gracefully shuts down the VM. Tries QMP quit → SSH poweroff → SIGTERM → SIGKILL.
vm_list — List running VMs
Shows all running run_qemu instances with their state and SSH ports.
Common MCP Workflows
CXL Topology Testing
The default CXL topology creates:
- 1 CXL host bridge (bus #52, window at 0x4c00000000)
- 1 root port
- 1 Type 3 device (256M persistent)
CXL Unit Testing (cxl_test)
Uses the kernel's cxl_test module to mock a CXL hierarchy without real hardware:
NFIT Unit Testing (nfit_test)
Tests libnvdimm with mock NFIT/NVDIMM devices. Forces preset to med:
Multiple VMs
Core Concepts
Build Directory
run_qemu creates a builddir (default: ../builddir-<branch>) containing:
- The rootfs image (
root.img) - mkosi cache (
mkosi.cache/) - Built kernel artifacts
Rebuild Modes
| Mode | What it does | When to use | |
|---|---|---|---|
kmod | Rebuild kernel + update rootfs modules | Default. Iterative kernel development | |
img | Rebuild entire rootfs image from scratch | When rootfs is broken or after major config changes | |
wipe | Delete everything (including package cache) and rebuild | When switching distro versions or corrupted cache | |
none | Don't rebuild anything, just boot | Quick re-test of existing build |
Topology Presets
| Preset | Nodes | Mem-only | PMEMs | EFI-mems | Legacy-PMEMs | |
|---|---|---|---|---|---|---|
| tiny | 1 | 0 | 1 | 0 | 0 | |
| small | 2 | 0 | 2 | 0 | 0 | |
| med | 2 | 4 | 4 | 1 | 2 | |
| large | 4 | 4 | 4 | 2 | 2 | |
| huge | 8 | 8 | 8 | 2 | 2 |
Kernel .config Management
run_qemu does not manage .config — it's the user's responsibility. The MCP's vm_start runs make olddefconfig by default to avoid interactive prompts. Common patterns:
SSH Access
- SSH port = 10022 + instance number
- Root password:
root(serial console auto-logs in) - Recommended
.ssh/config:
`` Host rq Hostname localhost User root Port 10022 StrictHostKeyChecking no UserKnownHostsFile /dev/null ``
- File sharing:
dpipe /usr/lib/ssh/sftp-server = ssh rq sshfs :$HOME/CXL /root/CXL -o passive
Manual CLI Workflows (when MCP not available)
If the MCP tools are not available, drive run_qemu.sh directly from a bash shell.
Interactive Kernel Test
CXL Topology Testing
CXL Unit Testing
NFIT Unit Testing
Automated Test Run
Iterative Development Cycle
Option Reference
Build & Image
| Option | Description | |
|---|---|---|
--rebuild=MODE | kmod (default), img, wipe, none | |
--rootfs=FILE | Non-default rootfs image (default: root.img) | |
--strip-modules | Strip kernel modules after install | |
--defconfig | Run make olddefconfig before build | |
--mirror=URL | Use alternate package mirror | |
--ndctl-build / --no-ndctl-build | Build ndctl in rootfs (default: on) |
Topology
| Option | Description | |
|---|---|---|
--preset=NAME | tiny, small (default), med, large, huge | |
--nodes=N | CPU+memory nodes | |
--mems=N | Memory-only nodes | |
--pmems=N | Persistent memory DIMMs | |
--nvmes=N | NVMe devices | |
--mem-size=MiB | Size of each memory device (default: 2048) |
CXL
| Option | Description | |
|---|---|---|
--cxl | Enable CXL topology | |
--cxl-debug | Enable CXL dyndbg | |
--cxl-pmems=N | Number of CXL memdevs with pmem (0-4, default: 2) | |
--cxl-test | Set up CXL unit test environment (includes cxl_test module) |
NFIT / NVDIMM
| Option | Description | |
|---|---|---|
--nfit-test | Set up NFIT unit test environment (forces preset=med) | |
--nfit-debug | Enable NVDIMM/NFIT dyndbg | |
--dax-debug | Enable DAX dyndbg |
Runtime
| Option | Description | |
|---|---|---|
--instance=N / -n N | Instance ID, offsets SSH port (default: 0) | |
--timeout=MIN / -t MIN | Auto-kill timeout in minutes (0=disabled) | |
--log=FILE / -l FILE | Console output to file | |
--autorun=FILE / -A FILE | Run FILE as systemd service on boot | |
--post-script=FILE | Run FILE after VM exits |
Kernel Command Line
| Option | Description | |
|---|---|---|
--kcmd-replace=FILE | Replace kernel cmdline from FILE | |
--kcmd-append=FILE | Append to kernel cmdline from FILE |
Display & Debug
| Option | Description | |
|---|---|---|
--gdb | Wait for GDB connection (port 10000) | |
--gdb-qemu | Start QEMU under GDB | |
--qmp | Enable QMP control socket | |
--debug / -v | Enable set -x debugging | |
--cmdline | Print QEMU command line without starting | |
--curses | Use curses display instead of nographic |
Other
| Option | Description | |
|---|---|---|
--rw | Persist runtime image changes | |
--no-kvm | Disable KVM (slow, for non-KVM hosts) | |
--legacy-bios | Don't use OVMF/EDK2 | |
--direct-kernel / --no-direct-kernel | Supply kernel to QEMU via -kernel (default: on) | |
--forget-disks | Force re-creation of disk images | |
--hmat | Set up HMAT table in QEMU | |
--git-qemu / -g | Use QEMU from ~/git/qemu/ | |
--quiet / -q | Reduce output verbosity |
Troubleshooting
Build Failures
- Check that
.configexists and has the needed options enabled - Use
--rebuild=wipeto start fresh if the rootfs is corrupted - mkosi cache issues: remove
builddir/mkosi.cache/or use--rebuild=wipe
VM Won't Boot
- Check the log file (
vm_logor--log) for kernel panics - Try
--no-kvmif hardware virtualization isn't available - Verify QEMU is installed:
qemu-system-x86_64 --version
SSH Not Connecting
- Verify the correct port: 10022 + instance number
- Check host firewall: port 10022 may be blocked
- Wait for boot to complete — the VM needs time to start sshd
- Check
vm_logfor boot progress
CXL Devices Not Visible
- Ensure
.confighas CXL options enabled (CONFIG_CXL_BUS=y, CONFIG_CXL_PCI=m, etc.) - Use
--cxl-debugfor dyndbg output - Check
vm_dmesg(grep="cxl")for driver messages
nfit_test / cxl_test Issues
- These require
--rebuild=imgor higher when switching to/from test mode - Check that the test modules are built:
vm_run(command="modinfo cxl_test")
Security
- Security scanPassed, 91 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/run-qemu/SKILL.md
Popularity
- Repository stars
- 77
- Repository forks
- 32
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 22 May 2026, 5 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pmem/run_qemu/run-qemu)