This commit is contained in:
2025-06-15 18:49:18 +02:00
parent 69c6a57fa4
commit bcef07baa4
5 changed files with 849 additions and 7 deletions

View File

@@ -82,10 +82,13 @@ fi
mkdir -p "$VM_BASE_DIR"
# Check if the base directory is on btrfs
if ! btrfs filesystem show "$VM_BASE_DIR" &>/dev/null; then
error "Base directory $VM_BASE_DIR is not on a btrfs filesystem. Please create a btrfs filesystem first."
FILESYSTEM_TYPE=$(stat -f -c %T "$VM_BASE_DIR" 2>/dev/null)
if [ "$FILESYSTEM_TYPE" != "btrfs" ]; then
error "Base directory $VM_BASE_DIR is not on a btrfs filesystem (detected: $FILESYSTEM_TYPE). Please create a btrfs filesystem first."
fi
log "Btrfs filesystem detected at $VM_BASE_DIR"
# Create base and vms subvolumes if they don't exist
if [ ! -d "$BASE_SUBVOL" ]; then
log "Creating base subvolume at $BASE_SUBVOL"
@@ -240,12 +243,11 @@ cloud-hypervisor \
--memory "size=${MEMORY_MB}M" \
--cpus "boot=$CPU_CORES" \
--kernel "$FIRMWARE_PATH" \
--disk "path=$VM_IMAGE_PATH" \
--disk "path=$CLOUD_INIT_PATH,readonly=on" \
--disk "path=$VM_IMAGE_PATH" "path=$CLOUD_INIT_PATH,readonly=on" \
--net "tap=$TAP_NAME,mac=52:54:00:$(printf '%02x:%02x:%02x' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)))" \
--serial tty \
--console off \
--log-level info &
--log-file /tmp/cloud-hypervisor-$VM_NAME.log &
VM_PID=$!
@@ -266,7 +268,7 @@ MEMORY_MB=$MEMORY_MB
CPU_CORES=$CPU_CORES
VM_IMAGE_PATH=$VM_IMAGE_PATH
CLOUD_INIT_PATH=$CLOUD_INIT_PATH
STARTED=$(date)
STARTED="$(date '+%Y-%m-%d %H:%M:%S')"
EOF
log "VM information saved to $VM_INFO_FILE"