...
This commit is contained in:
parent
7b859d274c
commit
63f4f77366
@ -148,7 +148,7 @@ cleanup_network() {
|
|||||||
|
|
||||||
# Check if bridge still has any TAP interfaces
|
# Check if bridge still has any TAP interfaces
|
||||||
if [ -n "$bridge_name" ] && ip link show "$bridge_name" &>/dev/null; then
|
if [ -n "$bridge_name" ] && ip link show "$bridge_name" &>/dev/null; then
|
||||||
local tap_count=$(ip link show master "$bridge_name" 2>/dev/null | grep -c "tap-" || echo "0")
|
local tap_count=$(ip link show master "$bridge_name" 2>/dev/null | grep "tap-" | wc -l)
|
||||||
if [ "$tap_count" -eq 0 ]; then
|
if [ "$tap_count" -eq 0 ]; then
|
||||||
info "Bridge '$bridge_name' has no remaining TAP interfaces"
|
info "Bridge '$bridge_name' has no remaining TAP interfaces"
|
||||||
# Note: We don't automatically remove the bridge as it might be used by other services
|
# Note: We don't automatically remove the bridge as it might be used by other services
|
||||||
|
@ -563,8 +563,8 @@ log "Launching Cloud Hypervisor..."
|
|||||||
log "Starting Cloud Hypervisor with command:"
|
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 "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 \
|
cloud-hypervisor \
|
||||||
--api-socket "$VM_SOCKET" \
|
|
||||||
--memory "size=${MEMORY_MB}M" \
|
--memory "size=${MEMORY_MB}M" \
|
||||||
--cpus "boot=$CPU_CORES" \
|
--cpus "boot=$CPU_CORES" \
|
||||||
--firmware "$FIRMWARE_PATH" \
|
--firmware "$FIRMWARE_PATH" \
|
||||||
@ -594,18 +594,24 @@ log "TAP interface: $TAP_NAME"
|
|||||||
log "Bridge interface: $BRIDGE_NAME"
|
log "Bridge interface: $BRIDGE_NAME"
|
||||||
log "VM MAC address: $VM_MAC"
|
log "VM MAC address: $VM_MAC"
|
||||||
|
|
||||||
# Wait for the socket to be created (Cloud Hypervisor needs time to initialize)
|
# Wait for VM to initialize and check if it's running properly
|
||||||
log "Waiting for VM API socket to be created..."
|
log "Waiting for VM to initialize..."
|
||||||
socket_wait_count=0
|
init_wait_count=0
|
||||||
while [ ! -S "$VM_SOCKET" ] && [ $socket_wait_count -lt 15 ]; do
|
while [ $init_wait_count -lt 10 ]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
socket_wait_count=$((socket_wait_count + 1))
|
init_wait_count=$((init_wait_count + 1))
|
||||||
if [ $((socket_wait_count % 5)) -eq 0 ]; then
|
|
||||||
info "Still waiting for API socket... ($socket_wait_count/15 seconds)"
|
# 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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
test_file_exists "$VM_SOCKET" "VM API socket creation"
|
log "✓ VM initialization completed"
|
||||||
|
|
||||||
# Save VM information for management
|
# Save VM information for management
|
||||||
log "Saving VM configuration..."
|
log "Saving VM configuration..."
|
||||||
|
Loading…
Reference in New Issue
Block a user