#!/bin/bash
set -euo pipefail

# QEMU/KVM + libvirt stack + virt-manager GUI
sudo pacman -S --noconfirm --needed \
    qemu-full \
    libvirt \
    virt-manager \
    virt-viewer \
    dnsmasq \
    bridge-utils \
    edk2-ovmf \
    swtpm \
    vde2

sudo systemctl enable --now libvirtd.service

# Enable the default NAT network at libvirt startup
sudo virsh net-autostart default 2>/dev/null || true

sudo usermod -aG libvirt,kvm "$USER"
echo "QEMU/KVM installed. Log out and back in for group membership to take effect."
