pmem/run_qemu/run-qemu

Claude Code and agent skill by pmem/run_qemu

Trust tier 2
  • community
LLM review pending
Source check pending

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-qemu

SKILL.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
1. vm_start(linux_dir=".", rebuild="kmod", preset="small", cxl=true)
→ Returns immediately. VM is building in background.
2. vm_status(instance=0)
→ Poll every 30-60s until state is "ready".
States: starting → ready (or exited on failure)
3. vm_run(instance=0, command="uname -r")
→ Execute commands inside the VM via SSH.
4. vm_dmesg(instance=0, grep="cxl")
→ Check kernel log for specific messages.
5. vm_log(instance=0, tail_lines=100)
→ Read console log for boot messages or errors.
6. vm_stop(instance=0)
→ Graceful shutdown when done.
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):

ParameterTypeDefaultDescription
linux_dirstr.Path to the Linux kernel tree
rebuildstrkmodkmod (rebuild kernel+modules), img (full rootfs), wipe (clean slate), none (just boot)
presetstrsmallNUMA topology: tiny, small, med, large, huge
cxlboolfalseEnable CXL topology
cxl_testboolfalseCXL unit test environment (includes cxl_test kernel module)
nfit_testboolfalseNFIT unit test environment (includes libnvdimm test modules). Overrides preset to med.
defconfigbooltrueRun make olddefconfig before building
instanceint0Instance number — determines SSH port (10022+N)
timeout_minutesint0Auto-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
vm_start(cxl=true, preset="small", extra_args="--cxl-debug")
# Poll vm_status until ready...
vm_run(command="lspci | grep '3[45]:00'")
vm_run(command="readlink -f /sys/bus/cxl/devices/mem0")
vm_dmesg(grep="cxl")

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:

vm_start(cxl_test=true, extra_args="--cxl-debug")
# cxl_test implies cxl, and includes extra CXL mock modules
vm_run(command="modprobe cxl_test")
vm_dmesg(grep="cxl_test")
NFIT Unit Testing (nfit_test)

Tests libnvdimm with mock NFIT/NVDIMM devices. Forces preset to med:

vm_start(nfit_test=true)
# Includes libnvdimm 'extra' modules and memmap reserved memory
vm_run(command="modprobe nfit_test")
vm_dmesg(grep="nfit")
Multiple VMs
vm_start(instance=0, preset="small") # SSH port 10022
vm_start(instance=1, preset="med", cxl=true) # SSH port 10023
vm_run(instance=0, command="uname -r")
vm_run(instance=1, command="lspci | grep CXL")

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
ModeWhat it doesWhen to use
kmodRebuild kernel + update rootfs modulesDefault. Iterative kernel development
imgRebuild entire rootfs image from scratchWhen rootfs is broken or after major config changes
wipeDelete everything (including package cache) and rebuildWhen switching distro versions or corrupted cache
noneDon't rebuild anything, just bootQuick re-test of existing build
Topology Presets
PresetNodesMem-onlyPMEMsEFI-memsLegacy-PMEMs
tiny10100
small20200
med24412
large44422
huge88822
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:

bash
make defconfig
# Or merge CXL configs:
./scripts/kconfig/merge_config.sh .config ../run_qemu/.github/workflows/*.cfg
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
bash
cd /path/to/linux
run_qemu.sh --defconfig --preset=small
# Drops you into a serial console. Ctrl-a x to exit.
# SSH in from another terminal: ssh -p 10022 root@localhost
CXL Topology Testing
bash
run_qemu.sh --defconfig --cxl --cxl-debug --preset=small
CXL Unit Testing
bash
run_qemu.sh --defconfig --cxl-test --cxl-debug
NFIT Unit Testing
bash
run_qemu.sh --defconfig --nfit-test
# Note: --nfit-test forces preset=med
Automated Test Run
bash
run_qemu.sh --defconfig --autorun=my_test.sh --timeout=10 --log=/tmp/rq_test.log
# Runs my_test.sh as a systemd service on boot
# Kills VM after 10 minutes
# Console output captured in /tmp/rq_test.log
Iterative Development Cycle
bash
# First run (creates rootfs):
run_qemu.sh --defconfig --rebuild=img --cxl
# Subsequent runs (kernel-only rebuild, fast):
run_qemu.sh --defconfig --cxl
# (default --rebuild=kmod rebuilds the kernel and updates modules)

Option Reference

Build & Image
OptionDescription
--rebuild=MODEkmod (default), img, wipe, none
--rootfs=FILENon-default rootfs image (default: root.img)
--strip-modulesStrip kernel modules after install
--defconfigRun make olddefconfig before build
--mirror=URLUse alternate package mirror
--ndctl-build / --no-ndctl-buildBuild ndctl in rootfs (default: on)
Topology
OptionDescription
--preset=NAMEtiny, small (default), med, large, huge
--nodes=NCPU+memory nodes
--mems=NMemory-only nodes
--pmems=NPersistent memory DIMMs
--nvmes=NNVMe devices
--mem-size=MiBSize of each memory device (default: 2048)
CXL
OptionDescription
--cxlEnable CXL topology
--cxl-debugEnable CXL dyndbg
--cxl-pmems=NNumber of CXL memdevs with pmem (0-4, default: 2)
--cxl-testSet up CXL unit test environment (includes cxl_test module)
NFIT / NVDIMM
OptionDescription
--nfit-testSet up NFIT unit test environment (forces preset=med)
--nfit-debugEnable NVDIMM/NFIT dyndbg
--dax-debugEnable DAX dyndbg
Runtime
OptionDescription
--instance=N / -n NInstance ID, offsets SSH port (default: 0)
--timeout=MIN / -t MINAuto-kill timeout in minutes (0=disabled)
--log=FILE / -l FILEConsole output to file
--autorun=FILE / -A FILERun FILE as systemd service on boot
--post-script=FILERun FILE after VM exits
Kernel Command Line
OptionDescription
--kcmd-replace=FILEReplace kernel cmdline from FILE
--kcmd-append=FILEAppend to kernel cmdline from FILE
Display & Debug
OptionDescription
--gdbWait for GDB connection (port 10000)
--gdb-qemuStart QEMU under GDB
--qmpEnable QMP control socket
--debug / -vEnable set -x debugging
--cmdlinePrint QEMU command line without starting
--cursesUse curses display instead of nographic
Other
OptionDescription
--rwPersist runtime image changes
--no-kvmDisable KVM (slow, for non-KVM hosts)
--legacy-biosDon't use OVMF/EDK2
--direct-kernel / --no-direct-kernelSupply kernel to QEMU via -kernel (default: on)
--forget-disksForce re-creation of disk images
--hmatSet up HMAT table in QEMU
--git-qemu / -gUse QEMU from ~/git/qemu/
--quiet / -qReduce output verbosity

Troubleshooting

Build Failures
  • Check that .config exists and has the needed options enabled
  • Use --rebuild=wipe to 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_log or --log) for kernel panics
  • Try --no-kvm if 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_log for boot progress
CXL Devices Not Visible
  • Ensure .config has CXL options enabled (CONFIG_CXL_BUS=y, CONFIG_CXL_PCI=m, etc.)
  • Use --cxl-debug for dyndbg output
  • Check vm_dmesg(grep="cxl") for driver messages
nfit_test / cxl_test Issues
  • These require --rebuild=img or 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/pmem/run_qemu/run-qemu/badge)](https://verified-skill.com/skills/pmem/run_qemu/run-qemu)

Something wrong with this skill or its page? Tell us.