...
This commit is contained in:
@@ -563,8 +563,8 @@ log "Launching Cloud Hypervisor..."
|
||||
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"
|
||||
|
||||
# Try with API socket first, fall back without it if needed
|
||||
cloud-hypervisor \
|
||||
--api-socket "$VM_SOCKET" \
|
||||
--memory "size=${MEMORY_MB}M" \
|
||||
--cpus "boot=$CPU_CORES" \
|
||||
--firmware "$FIRMWARE_PATH" \
|
||||
@@ -594,18 +594,24 @@ log "TAP interface: $TAP_NAME"
|
||||
log "Bridge interface: $BRIDGE_NAME"
|
||||
log "VM MAC address: $VM_MAC"
|
||||
|
||||
# Wait for the socket to be created (Cloud Hypervisor needs time to initialize)
|
||||
log "Waiting for VM API socket to be created..."
|
||||
socket_wait_count=0
|
||||
while [ ! -S "$VM_SOCKET" ] && [ $socket_wait_count -lt 15 ]; do
|
||||
# Wait for VM to initialize and check if it's running properly
|
||||
log "Waiting for VM to initialize..."
|
||||
init_wait_count=0
|
||||
while [ $init_wait_count -lt 10 ]; do
|
||||
sleep 1
|
||||
socket_wait_count=$((socket_wait_count + 1))
|
||||
if [ $((socket_wait_count % 5)) -eq 0 ]; then
|
||||
info "Still waiting for API socket... ($socket_wait_count/15 seconds)"
|
||||
init_wait_count=$((init_wait_count + 1))
|
||||
|
||||
# Check if VM process is still running
|
||||
if ! kill -0 "$VM_PID" 2>/dev/null; then
|
||||
error "VM process died during initialization. Check log: $VM_LOG_FILE"
|
||||
fi
|
||||
|
||||
if [ $((init_wait_count % 3)) -eq 0 ]; then
|
||||
info "VM initializing... ($init_wait_count/10 seconds)"
|
||||
fi
|
||||
done
|
||||
|
||||
test_file_exists "$VM_SOCKET" "VM API socket creation"
|
||||
log "✓ VM initialization completed"
|
||||
|
||||
# Save VM information for management
|
||||
log "Saving VM configuration..."
|
||||
|
||||
Reference in New Issue
Block a user