diff options
Diffstat (limited to 'pkgs/run-firecracker-vm/default.nix')
| -rw-r--r-- | pkgs/run-firecracker-vm/default.nix | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pkgs/run-firecracker-vm/default.nix b/pkgs/run-firecracker-vm/default.nix index 37423a8..37047b0 100644 --- a/pkgs/run-firecracker-vm/default.nix +++ b/pkgs/run-firecracker-vm/default.nix @@ -370,11 +370,13 @@ pkgs.writeShellScriptBin "run-firecracker-vm" /* sh */ '' args="$args systemd.tty.rows.ttyS0=$rows systemd.tty.columns.ttyS0=$cols" fi - # Take the first tap device (see modules/host) that no other VM holds. The - # lock is held until the script exits. The MAC address is derived from - # the tap's number, so the VM gets the same DHCP lease every time. + # Take the first tap device of the user's (see modules/host) that no other + # VM holds. The lock is held until the script exits. The MAC address is + # derived from the tap's number, as modules/host does, for the tap's + # fixed address. tap= for t in $(find /sys/class/net -maxdepth 1 -name 'fctap*' -printf '%f\n' | sort -V); do + test "$(cat /sys/class/net/$t/owner)" = "$(id -u)" || continue exec {lock}>"''${XDG_RUNTIME_DIR:-/tmp}/run-firecracker-vm.$t.lock" if flock -n "$lock"; then tap=$t @@ -383,7 +385,7 @@ pkgs.writeShellScriptBin "run-firecracker-vm" /* sh */ '' exec {lock}>&- done if test -z "$tap"; then - echo "$0: no free tap device fctap*, see modules/host" >&2 + echo "$0: no free tap device fctap* of $(id -un)'s, see modules/host" >&2 exit 1 fi n=''${tap#fctap} |
