This commit is contained in:
2026-03-15 10:05:06 +01:00
parent b2ad5a8be5
commit 3f0b00ff24
2 changed files with 17 additions and 31 deletions

View File

@@ -5,8 +5,7 @@ SSH_PORT=2222
MEMORY=8G
CPUS=4
MOUNTS=()
CLAUDE_DIR=""
CLAUDE_JSON=""
CLAUDE=false
IMAGE=""
usage() {
@@ -15,8 +14,7 @@ Usage: ephvm-run.sh <image.qcow2> [options]
Options:
--mount <path> Mount host directory into VM (repeatable)
--claude <path> Mount claude config dir writable into VM
--claude-json <path> Copy claude.json into mounted claude dir
--claude Mount claude config dir (auto-detects from CLAUDE_CONFIG_DIR or ~/.claude)
--memory <size> VM memory (default: 8G)
--cpus <n> VM CPUs (default: 4)
--ssh-port <port> SSH port forward (default: 2222)
@@ -32,8 +30,7 @@ shift
while [ $# -gt 0 ]; do
case "$1" in
--mount) MOUNTS+=("$2"); shift 2 ;;
--claude) CLAUDE_DIR="$2"; shift 2 ;;
--claude-json) CLAUDE_JSON="$2"; shift 2 ;;
--claude) CLAUDE=true; shift ;;
--memory) MEMORY="$2"; shift 2 ;;
--cpus) CPUS="$2"; shift 2 ;;
--ssh-port) SSH_PORT="$2"; shift 2 ;;
@@ -73,15 +70,17 @@ for mount_path in "${MOUNTS[@]}"; do
FS_ID=$((FS_ID + 1))
done
if [ -n "$CLAUDE_DIR" ]; then
CLAUDE_DIR=$(realpath "$CLAUDE_DIR")
if [ "$CLAUDE" = true ]; then
if [ -z "${CLAUDE_CONFIG_DIR:-}" ]; then
echo "error: --claude requires CLAUDE_CONFIG_DIR to be set"
exit 1
fi
mkdir -p "$CLAUDE_CONFIG_DIR"
claude_dir=$(realpath "$CLAUDE_CONFIG_DIR")
QEMU_ARGS+=(
-virtfs "local,path=$CLAUDE_DIR,mount_tag=claude,security_model=none,id=fs${FS_ID}"
-virtfs "local,path=$claude_dir,mount_tag=claude,security_model=none,id=fs${FS_ID}"
)
fi
if [ -n "$CLAUDE_JSON" ]; then
QEMU_ARGS+=(-fw_cfg "name=opt/claude.json,file=$CLAUDE_JSON")
fi
exec "${QEMU_ARGS[@]}"