| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
|
|
| |
A layer's image is now firecracker-layer-K-NAME.img, NAME being the
layer's file name without .nix (or, for .../NAME/default.nix, NAME).
Layers that aren't files, and the base system, keep just the number.
|
| |
|
|
|
|
|
| |
The guest's memory was fixed at 1024 MiB, which hermes, its gateway and
a claude process or two outgrow. --mem-size MIB sets it, default 1024.
The config gets it like the other per-run values, from a placeholder,
here a quoted one, replaced by the bare number.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nix in the guest deletes a path in the store that isn't in its
database before it adds it, like any of the host's store's paths, which
aren't registered. On the overlay, that leaves a whiteout in the
rw-store, or an opaque directory with what nix adds again, if it gets
that far. With a persistent rw-store, that hides the path from every
later boot, from images that have it, too: a hermes layer's setup
failed with exit 255, as python3's binary wrapper couldn't exec the
python the rw-store hid.
A path that a lower layer has is complete there, and the same as
anything of that name in the rw-store. So drop such paths from the
rw-store in the initrd, before sysroot-nix-store.mount; what's left is
what only the guest added.
|
| |
|
|
|
|
|
|
|
| |
Without --home, /home is now simply part of the guest's root file
system (a tmpfs, gone when it exits, as before), instead of a scratch
disk. With --home, the disk is attached after the images, and the run
script puts fc.home on the kernel command line, which makes a small
generator in the guest mount it, so a guest without it doesn't wait for
a drive that isn't there. The images are back at vdb, vdc, ...
|
| |
|
|
|
|
|
|
|
|
| |
/home is now on its own disk: a scratch file, removed when the guest
exits, or with --home FILE, one that persists (created if it doesn't
exist, sparse, --home-size, default 16G), handled like the store's
(--store), and also locked against use by two VMs. Separate from the
store, so either can be kept or thrown away.
The images move one drive up (vdc, vdd, ...).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new argument layers is a list of NixOS modules, each a layer on top
of the ones before, the first on top of the base system. The guest runs
the top layer's system. Each layer gets its own erofs image with only
the store paths of its system's closure that the layers below don't
have, so the base image (and those of layers below) stays the same
whatever goes on top:
nix-build pkgs/run-firecracker-vm --arg layers '[ ./my-service.nix ]'
The images become read-only drives, mounted as overlay lower layers
(with the host store below them, as before). The writable store disk
is now the first drive (/dev/vda), the images follow (vdb, vdc, ...).
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
A VM can now have a name: run-firecracker-vm --name NAME. It's unique
among the user's running VMs (a lock in the user's runtime directory,
like the taps'), becomes the guest's host name (systemd.hostname= on the
kernel command line), and goes to /run/fc-egress/TAP.name while the VM
runs, for fc-egress. Names are letters, digits and -, and can't look
like a tap's.
fc-egress takes a running VM's name or tap where it takes a VM:
-v VM works on the list the VM uses, use VM LIST switches it to another
list, and vms shows tap, name and list. The logs keep saying taps
(fc-egress vms maps them).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Whitelists are now named, any number per user, in
/var/lib/fc-egress/USER/LIST, and each VM uses one of them:
run-firecracker-vm --egress LIST (default: default). The run script
writes the list's name to /run/fc-egress/TAP when it takes the tap, and
empties it when the VM exits; a list that doesn't exist allows nothing.
A user's VMs can only use that user's lists.
So the unit of policy is the tap (i.e. the running VM) rather than the
user: nftables sets allow_TAP, nginx decrypt sockets decrypt-TAP.sock,
egress_taps.lua maps guest addresses to tap and user. fcbr0-firewall
updates a tap when its file in /run/fc-egress changes, and all of a
user's taps when anything in the user's directory does. nginx's
connection limit stays per user.
fc-egress takes -l LIST (default: default), and has new commands lists
and vms (running VMs' taps and their lists). Log lines now say user,
tap and (nginx's) list: "ALLOW|DENY USER TAP LIST ...", kernel:
"fc-egress ALLOW|DENY USER TAP".
The old rules file, /var/lib/fc-egress/USER/allowed, is now just a list
named "allowed"; rename it to "default" to keep using it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- denyDestinations (default: loopback, private, link-local, CGNAT,
multicast, ...): no user's rules can open those, neither tcp:// and
udp:// rules nor the proxy, whatever a name resolves to: nginx's own
outgoing connections may only go to port 443 outside them, and not to
the host. tcp:// rules no longer open anything on the host itself.
- fcbr0-firewall no longer runs as root, but with only CAP_NET_ADMIN,
doesn't follow symlinks, and gets started per user when that user's
rules change, so one user can't stop the others' updates. Rules files
are read up to 64k only, by egress.lua, too.
- Limits per guest (maxConnections open, maxNewConnections per second),
and per user in nginx, so one user can't starve the others.
- tcp:// and udp:// connections, and refused ones, get logged
(rate-limited) with the user; fc-egress log shows them.
- The run script keeps its lock files in a directory of the user's own,
not in /tmp, where others could take them first.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The host module takes users = { NAME = TAPS; ... } instead of a single
user: each user gets that many taps, and rules of their own, in
/var/lib/fc-egress/USER/allowed, managed with fc-egress as before.
The proxy tells whose a guest is by its address: each tap has a fixed
one, handed out by dnsmasq by MAC address (derived from the tap's number,
as the run script does), and the bridge drops anything a guest sends from
another address. The decrypting server gets a socket per user, as it
can't see the guest's address. The run script only takes the user's own
taps.
|
| |
|
|
|
|
|
|
|
|
| |
/nixpkgs isn't cached in the guest, so changes to a checkout show up
right away, but evaluating is slow. --nixpkgs-cache sets 9P's cache
mode for it, e.g. loose, which made evaluating tmux several times
faster. It gets passed on the kernel command line as fc.9p566=cache=MODE,
and mount.vsock9p appends such options for the port it mounts.
Options also take the --option=value form now.
|
| |
|
|
|
|
|
|
|
| |
A <nixpkgs> outside the store got copied (i.e. hashed) to the store on
every evaluation, for the guest's NIX_PATH, so no-op builds still took
~25s with a checkout. Now a third 9P server serves nixpkgs from wherever
it is, read-only, at /nixpkgs in the guest, which NIX_PATH points to.
It's in neither the closure nor the registration any more, and
run-firecracker-vm --nixpkgs DIR can serve another one.
|
| |
|
|
|
|
|
| |
"${pkgs.path}" copies nixpkgs to the store, which means hashing all of
it, on every evaluation, even when it's a store path already. That
took no-op builds from ~3s to ~25s. Use builtins.storePath when it's a
store path; only a nixpkgs outside the store still gets copied.
|
| |
|
|
|
| |
egress.lua goes along. The host now imports it as
(import .../modules/host { user = ...; }).
|
|
|
So default.nix (or shell.nix, flake.nix) at the top can become something
else. kernel.nix goes along, as it's only an argument of the runner.
|