You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When --nested-virtualization is set, prepare the KVM group in user-data #93
When you launch a Linux builder with --nested-virtualization (spawn#91) to do
nested KVM work (e.g. building a Windows AMI per infra/amis/windows/, #83), the
host exposes /dev/kvm — but it's root:kvm 0660, so an ordinary login user
can't open it until they're in the kvm group.
The manual fix is sudo usermod -aG kvm $USER, but group membership only
applies to new logins — the SSH session you ran it from still can't access /dev/kvm, so the first packer build / qemu-system-x86_64 dies with:
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize kvm: Permission denied
You then have to reconnect or wrap the build in sg kvm -c '...'. This bit us
during the first real #83 build run.
Proposal
When --nested-virtualization is set, have spawn's Linux user-data add the
login user to the kvm group at boot. user-data runs as root before the
user's first SSH login, so by the time they connect the group is already active
in their session — no usermod, no reconnect, no sg kvm dance.
Roughly, in the Linux user-data builder when nested virt is requested:
# nested virtualization: let the login user reach /dev/kvm without a re-loginif [ -e /dev/kvm ];then
groupadd -f kvm
usermod -aG kvm "$LOGIN_USER"fi
Notes / scope:
Only emit this when NestedVirtualization is true (no reason to touch the kvm
group otherwise).
Don't install qemu/packer for them — toolchain choice is the user's (Ubuntu
vs other); just make /dev/kvm reachable. Keep the README's explicit install
steps.
Linux-only (the flag is meaningless for the Windows guest case).
$LOGIN_USER is whatever spawn already injects the SSH key for.
Acceptance
spawn launch ... --nested-virtualization → SSH in → id -nG includes kvm
on the first session, and test -w /dev/kvm succeeds without sudo/sg.
No kvm-group changes when --nested-virtualization is absent.
Activity