diff options
| author | tv <tv@krebsco.de> | 2026-11-17 02:59:16 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-17 02:59:16 +0000 |
| commit | e0640333d0e9eb872a3abf68a9da1685ab570076 (patch) | |
| tree | 21a779ff77bfcea49a7cea148f9a81900bac3847 | |
| parent | e0b8ef7a5f907baf7362ee34f24c107238590a8f (diff) | |
run-firecracker-vm: --egress defaults to the VM's name
A named VM uses the list of the same name unless given another with
--egress; without a name, still the list default. A missing list means
no egress (with a warning), as before; there's no fallback to default.
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | modules/host/default.nix | 6 | ||||
| -rw-r--r-- | pkgs/run-firecracker-vm/default.nix | 7 |
3 files changed, 14 insertions, 8 deletions
@@ -101,11 +101,14 @@ fc-egress lists fc-egress log -f ``` -Each VM uses one list, `default` unless given another, and can have a -name (also its host name; unique among your running VMs): +Each VM can have a name (also its host name; unique among your running +VMs), and uses one list: the one given with `--egress`, else the one +named like the VM, else (no name) `default`: ```sh -./result/bin/run-firecracker-vm --egress work --name box +fc-egress -l box allow cache.nixos.org +./result/bin/run-firecracker-vm --name box # list box +./result/bin/run-firecracker-vm --name box2 --egress box # list box, too fc-egress vms # running VMs: tap (as in the log), name, list fc-egress -v box allow example.org # the list box uses fc-egress use box default # switch box to another list diff --git a/modules/host/default.nix b/modules/host/default.nix index c70e505..5e9480e 100644 --- a/modules/host/default.nix +++ b/modules/host/default.nix @@ -24,7 +24,8 @@ # with fc-egress (see fc-egress help) at any time; changes apply to the # next connection. Which list a VM uses is in /run/fc-egress/TAP (one # line, the list's name, writable by the tap's user), which the run script -# writes when it takes the tap (--egress LIST, default "default") and +# writes when it takes the tap (--egress LIST, default: the VM's name +# (--name), or "default") and # empties when the VM exits. No list, or one that doesn't exist, allows # nothing. Likewise /run/fc-egress/TAP.name, the VM's name (--name), so # fc-egress can take names instead of taps; only fc-egress reads it. @@ -167,7 +168,8 @@ ${lib.concatMapStrings (t: " ${t.name}) user=${t.user} ;;\n") taps} echo " fc-egress use VM LIST" echo " fc-egress log [JOURNALCTL-OPTION...]" echo "LIST is a whitelist's name (default: default); a VM uses the one" - echo " given to run-firecracker-vm --egress (default: default)" + echo " given to run-firecracker-vm --egress (default: its --name," + echo " or default)" echo "VM is a running VM's name (run-firecracker-vm --name) or tap;" echo " -v VM means the list it uses" echo "RULE is DOMAIN (HTTPS, with subdomains, not decrypted)" diff --git a/pkgs/run-firecracker-vm/default.nix b/pkgs/run-firecracker-vm/default.nix index 223654a..f77520e 100644 --- a/pkgs/run-firecracker-vm/default.nix +++ b/pkgs/run-firecracker-vm/default.nix @@ -320,8 +320,8 @@ pkgs.writeShellScriptBin "run-firecracker-vm" /* sh */ '' # when the guest exits, or with --store, to FILE, which keeps it across # boots (created if it doesn't exist, of --store-size, default 16G; the # file is sparse, so that's only an upper limit). - # The guest's egress goes by the user's whitelist LIST (default: - # default), see modules/host and fc-egress. --name names the VM, for + # The guest's egress goes by the user's whitelist LIST (default: the + # VM's name, or without one, default), see modules/host and fc-egress. --name names the VM, for # fc-egress and as the guest's host name; only one running VM of the # user's can have a given name. set -efu @@ -333,7 +333,7 @@ pkgs.writeShellScriptBin "run-firecracker-vm" /* sh */ '' args= rw_store= rw_store_size=16G - egress=default + egress= name= nixpkgs=${lib.escapeShellArg (toString pkgs.path)} while test $# -gt 0; do @@ -349,6 +349,7 @@ pkgs.writeShellScriptBin "run-firecracker-vm" /* sh */ '' *) usage >&2; exit 1 esac done + egress=''${egress:-''${name:-default}} tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT |
