gioser
⎇ main scripts/run-vm.sh Shell · 40 lines · 1.2 KB History raw

journal-query CLI, machined, polkit con grants reales, GNOME boot test 48e41331a · Sergio ·

1#!/usr/bin/env bash
2# run-vm.sh — boot de la imagen rootfs en QEMU con KVM.
3#
4# Inputs:
5#   $1 — imagen disco (qcow2 o raw) con el rootfs ya parchado
6#   $@ — args adicionales a qemu
7#
8# Default: 4 GiB RAM, 2 vCPU, virtio-net, OpenGL para GNOME shell.
9
10set -euo pipefail
11
12DISK="${1:-}"
13shift || true
14
15if [[ -z "$DISK" || ! -f "$DISK" ]]; then
16    echo "Uso: $0 <disk.qcow2> [args extra de qemu]" >&2
17    echo "Genera la imagen con scripts/build-rootfs.sh primero." >&2
18    exit 1
19fi
20
21# Boot config: redirige init a ente-zero. Usa los flags que el initramfs
22# de la imagen base entienda — `init=` es universal para GRUB-equivalentes.
23KERNEL_CMDLINE="root=/dev/vda1 rw console=ttyS0,115200 init=/usr/local/bin/ente-zero RUST_LOG=info"
24
25# Config QEMU. -display gtk con OpenGL para GNOME shell. -display none
26# para CI/headless (el test verifica solamente boot via console).
27DISPLAY_FLAGS="${ENTE_VM_DISPLAY:--display gtk,gl=on}"
28
29exec qemu-system-x86_64 \
30    -enable-kvm \
31    -cpu host \
32    -smp 2 \
33    -m 4G \
34    -drive "file=$DISK,if=virtio" \
35    -netdev user,id=net0 \
36    -device virtio-net-pci,netdev=net0 \
37    -serial mon:stdio \
38    $DISPLAY_FLAGS \
39    -append "$KERNEL_CMDLINE" \
40    "$@"