...
This commit is contained in:
@@ -383,10 +383,36 @@ if [ ! -f "$FIRMWARE_PATH" ]; then
|
||||
chmod +x "$FIRMWARE_PATH"
|
||||
test_step "Firmware executable check" "[ -x '$FIRMWARE_PATH' ]"
|
||||
log "✓ Firmware downloaded to $FIRMWARE_PATH"
|
||||
else
|
||||
log "✓ Firmware already exists at $FIRMWARE_PATH"
|
||||
test_file_exists "$FIRMWARE_PATH" "Firmware verification"
|
||||
fi
|
||||
else
|
||||
log "✓ Firmware already exists at $FIRMWARE_PATH"
|
||||
test_file_exists "$FIRMWARE_PATH" "Firmware verification"
|
||||
fi
|
||||
|
||||
# Extract kernel and initrd from base image
|
||||
log "Extracting kernel and initrd for kernel boot..."
|
||||
EXTRACT_SCRIPT="$(dirname "$0")/extract_kernel.sh"
|
||||
if [ -f "$EXTRACT_SCRIPT" ]; then
|
||||
"$EXTRACT_SCRIPT"
|
||||
else
|
||||
warn "Kernel extraction script not found, attempting manual extraction..."
|
||||
# Fallback manual extraction
|
||||
KERNEL_PATH="$BASE_SUBVOL/vmlinuz"
|
||||
INITRD_PATH="$BASE_SUBVOL/initrd.img"
|
||||
if [ ! -f "$KERNEL_PATH" ] || [ ! -f "$INITRD_PATH" ]; then
|
||||
log "Extracting kernel and initrd manually..."
|
||||
TEMP_MOUNT=$(mktemp -d)
|
||||
losetup -P /dev/loop1 "$BASE_IMAGE_PATH"
|
||||
mount /dev/loop1p16 "$TEMP_MOUNT"
|
||||
cp "$TEMP_MOUNT/vmlinuz-6.8.0-60-generic" "$KERNEL_PATH" 2>/dev/null || true
|
||||
cp "$TEMP_MOUNT/initrd.img-6.8.0-60-generic" "$INITRD_PATH" 2>/dev/null || true
|
||||
umount "$TEMP_MOUNT"
|
||||
losetup -d /dev/loop1
|
||||
rmdir "$TEMP_MOUNT"
|
||||
fi
|
||||
fi
|
||||
|
||||
test_file_exists "$BASE_SUBVOL/vmlinuz" "Kernel extraction"
|
||||
test_file_exists "$BASE_SUBVOL/initrd.img" "Initrd extraction"
|
||||
|
||||
# Create VM subvolume by cloning from base
|
||||
log "Setting up VM-specific storage..."
|
||||
@@ -625,14 +651,19 @@ log "Generated MAC address for VM: $VM_MAC"
|
||||
log "Launching Cloud Hypervisor..."
|
||||
|
||||
# Try to start Cloud Hypervisor and capture any error output
|
||||
log "Starting Cloud Hypervisor with command:"
|
||||
log "cloud-hypervisor --api-socket $VM_SOCKET --memory size=${MEMORY_MB}M --cpus boot=$CPU_CORES --firmware $FIRMWARE_PATH --disk path=$VM_IMAGE_PATH path=$CLOUD_INIT_PATH,readonly=on --net tap=$TAP_NAME,mac=$VM_MAC --serial file=$VM_LOG_FILE --console off --event-monitor path=${VM_LOG_FILE}.events"
|
||||
log "Starting Cloud Hypervisor with kernel boot:"
|
||||
log "cloud-hypervisor --memory size=${MEMORY_MB}M --cpus boot=$CPU_CORES --kernel $KERNEL_PATH --initramfs $INITRD_PATH --cmdline 'root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0' --disk path=$VM_IMAGE_PATH path=$CLOUD_INIT_PATH,readonly=on --net tap=$TAP_NAME,mac=$VM_MAC --serial file=$VM_LOG_FILE --console off --event-monitor path=${VM_LOG_FILE}.events"
|
||||
|
||||
# Use kernel boot instead of firmware boot to properly pass root device
|
||||
KERNEL_PATH="$BASE_SUBVOL/vmlinuz"
|
||||
INITRD_PATH="$BASE_SUBVOL/initrd.img"
|
||||
|
||||
# Try with API socket first, fall back without it if needed
|
||||
cloud-hypervisor \
|
||||
--memory "size=${MEMORY_MB}M" \
|
||||
--cpus "boot=$CPU_CORES" \
|
||||
--firmware "$FIRMWARE_PATH" \
|
||||
--kernel "$KERNEL_PATH" \
|
||||
--initramfs "$INITRD_PATH" \
|
||||
--cmdline "root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyS0" \
|
||||
--disk "path=$VM_IMAGE_PATH" "path=$CLOUD_INIT_PATH,readonly=on" \
|
||||
--net "tap=$TAP_NAME,mac=$VM_MAC" \
|
||||
--serial "file=$VM_LOG_FILE" \
|
||||
|
||||
Reference in New Issue
Block a user