From 1cd6695315d52b4d5417fbb9fb8ad3b8c0063104 Mon Sep 17 00:00:00 2001 From: Lena Date: Wed, 1 Jul 2026 00:00:00 +0000 Subject: test: pass /dev/kvm's gid to docker numerically Group names resolved on the host do not exist inside the container, so the "kvm" fallback broke --group-add on hosts where getent found no kvm group. stat the device instead; the numeric gid is all that matters and /dev/kvm is already known to exist at this point. --- test | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test b/test index de6eaf6..7ccfc8f 100755 --- a/test +++ b/test @@ -69,10 +69,10 @@ if [ -n "$needs_kvm" ]; then echo " sudo usermod -aG kvm $(id -un)" >&2 exit 3 fi - # Pass through the host's kvm gid so the container user (mapped to - # host uid:gid) can actually open /dev/kvm. - kvm_gid=$(getent group kvm | awk -F: '{print $3}') - kvm_args="--device /dev/kvm --group-add ${kvm_gid:-kvm}" + # Pass through /dev/kvm's owning gid (numeric - group names from the + # host don't exist inside the container) so the container user + # (mapped to host uid:gid) can actually open it. + kvm_args="--device /dev/kvm --group-add $(stat -c %g /dev/kvm)" fi # Forward Ctrl-C cleanly, run as the host user so files in .tools/ stay -- cgit v1.2.3