Loading...
Loading...
Guidance for starting and configuring QEMU virtual machines with proper serial console access. This skill should be used when tasks involve starting QEMU VMs, configuring serial console or telnet access, booting ISO images, or troubleshooting VM startup issues. Covers pre-flight checks, idempotent startup procedures, and intelligent readiness verification.
npx skill4agent add letta-ai/skills qemu-startup# Check QEMU installation
which qemu-system-x86_64 || which qemu-system-i386
# Check for process management tools (availability varies by environment)
which ps pkill pgrep kill 2>/dev/null
# Check for network diagnostic tools
which nc netstat ss lsof 2>/dev/null
# Check for telnet client
which telnet-enable-kvm# Check if KVM module is loaded
ls /dev/kvm 2>/dev/null && echo "KVM available" || echo "KVM not available"
# Alternative check
grep -E '(vmx|svm)' /proc/cpuinfo > /dev/null && echo "CPU supports virtualization"-enable-kvm# Verify the ISO/disk image exists and is readable
ls -la /path/to/image.iso
# Check if the target port is already in use
# Use whichever tool is available:
nc -z localhost PORT 2>/dev/null && echo "Port in use"
# or
netstat -tuln | grep PORT
# or
ss -tuln | grep PORTqemu-system-x86_64 \
-m 512 \ # Memory (adjust as needed)
-cdrom /path/to/image.iso \ # Boot ISO
-nographic \ # No graphical output
-serial telnet:localhost:PORT,server,nowait \ # Serial on telnet
-monitor none # Disable QEMU monitor on stdio| Issue | Cause | Solution |
|---|---|---|
| QEMU monitor prompt instead of serial console | Missing | Add |
| "Port already in use" error | Previous QEMU instance still running | Clean up existing processes first |
| VM hangs at boot | KVM flag on system without KVM | Remove |
| No output visible | Serial console not properly configured | Ensure |
# Build command conditionally
if [ -e /dev/kvm ]; then
KVM_FLAG="-enable-kvm"
else
KVM_FLAG=""
fi
qemu-system-x86_64 $KVM_FLAG -m 512 ...# Find existing QEMU processes (use available tools)
ps aux | grep qemu | grep -v grep
# If pkill available:
pkill -f "qemu.*PORT" 2>/dev/null
# If only kill available, find PID first:
# Then: kill PID
# Wait briefly for port release
sleep 2
# Verify port is free before startingsleep# Poll for port availability with timeout
MAX_WAIT=60
WAITED=0
while ! nc -z localhost PORT 2>/dev/null; do
sleep 2
WAITED=$((WAITED + 2))
if [ $WAITED -ge $MAX_WAIT ]; then
echo "Timeout waiting for VM"
exit 1
fi
done
echo "Port is listening after ${WAITED}s"# Test telnet connection and look for expected output
# Use timeout to avoid hanging
timeout 10 telnet localhost PORT
# For automated verification, check for login prompt
echo "" | timeout 5 telnet localhost PORT 2>&1 | grep -i "login"# Find process listening on the port
lsof -i :PORT # if available
# or
netstat -tlnp | grep PORT
# or
ss -tlnp | grep PORTpspkillssnc/dev/kvm-enable-kvm-nographic-monitor noneStart
│
├─► Pre-flight checks pass?
│ No ──► Adapt approach based on available tools
│ Yes ──► Continue
│
├─► KVM available?
│ No ──► Omit -enable-kvm flag
│ Yes ──► Include -enable-kvm flag
│
├─► Port already in use?
│ Yes ──► Clean up existing processes, wait for port release
│ No ──► Continue
│
├─► Start QEMU with complete command
│
├─► Poll for port readiness (with timeout)
│
├─► Verify connection and expected output
│
└─► Confirm final state explicitly