| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
| |
The host side loses the fc and firecracker, too: rig-egress (the
command, also in the guests, and in log lines; /var/lib/rig-egress for
the lists, /run/rig-egress for the VMs' choices of list), rig-proxy (the
proxy, its user, /run/rig-proxy, and /var/lib/rig-proxy with the CA),
rig-firewall, rig-dnsmasq, /run/rig-hosts, /run/rig-addr, the bridge
rigbr0 and taps rigtapN, /etc/rig-taps and /etc/rig-vms, config.rig.vms,
the nftables tables rigs and rigs-bridge, and egress.lua's RIG_EGRESS_*.
The host's own configuration needs the new names, too: its firewall's
trusted interface rigbr0, and config.rig.vms.
|
| |
|
|
|
|
| |
The run script starts its VMs in Cloud Hypervisor, too, so it's
pkgs/run-rig, and run-rig (also its lock files), and the examples'
paths are /path/to/rigs.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The project is called rigs now, as it runs its VMs in Cloud Hypervisor,
too, not only Firecracker. So the guest's options (rig.secrets,
rig.home.required, rig.nix, ...), its kernel command line (rig.vmm,
rig.home, rig.xchg, rig.registration, rig.9pPORT), its units
(rig-secrets, rig-home, rig-xchg, rig-vmm-exit, rig-drop-caches,
rig-rw-store-unshadow), the drives' labels (rig-layer-K, rig-store,
rig-home; the run script relabels existing store and home images), and
the images (rig-layer-K.img) lose the fc and firecracker. Firecracker
itself, the VMM, keeps its name.
|
| |
|
|
|
|
|
|
|
|
|
| |
Every guest got the directory xchg, where the run script was started,
at /xchg, writable, and shared with every other VM started in the same
directory: a way across the boundary between the VMs, and to the host,
that most guests don't need (tv works with them via ssh), which is what
the VMs are for. Now there's no /xchg unless asked for: --xchg DIR
serves DIR (created if missing) via 9P, and passes fc.xchg, for which a
generator in the guest writes the automount; without it, there's no 9P
server for it, and no /xchg in the guest at all.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The proxy was only ever tested by hand, in network namespaces, with its
configuration taken out of the module. Now the VM test covers it with
the module for real: an upstream (openssl s_server) serving allowed.test
& co. with a certificate from a test CA the host trusts, and
untrusted.test with a self-signed one, and a dnsmasq on the host's lo
as nginx's resolver. Checked: whole domains passed through (with the
upstream's certificate, subdomains too), path rules decrypted (with the
proxy's), other paths, `..`, `%2e%2e` and a Host other than the server
name refused, names without a rule and other guests' rules refused, an
upstream certificate that doesn't verify a 502, POST /check for
https://, the log lines, and rules changing without a reload.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Both were only in the sandbox the project was developed in so far.
tests/qemu builds the run script with a qemu stand-in for Firecracker
(same kernel, initrd, drives, vsock via vhost-device-vsock; network via
qemu's user networking, the guest's port 22 on 127.0.0.1:2222) and a
test layer running a script at the end of boot, its output on the
console. The run script still takes a tap, so it needs modules/host
where it runs.
tests/vm-host.nix is a NixOS VM test of modules/host, with network
namespaces on veths in place of taps as guests: a VM's static address
by name, tcp:// rules over IPv4 and IPv6 and by name, DNS, anti-spoofing,
POST /check, the path units and the timer.
|
| |
|
|
|
|
|
|
|
| |
The cut-down kernel had nf_tables, with IPv4, NAT and conntrack (and
bridges, taps and veths), but not the inet, IPv6 and bridge families,
nor ct count, limit, log, reject, fib, redirect and masquerade, which
modules/host's rules use, so a guest (with --nested, for KVM) couldn't
run guests of its own, nor test modules/host. Now it has them, built
in, like the rest of its netfilter.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Cloud Hypervisor offers its guests hardware virtualization by default
(nested=on, its CPUs show svm), and Firecracker passes on whatever KVM
offers (it's "not tested with nested virtualization", but has no
switch), so whether a guest got it depended on the VMM, and the host's
kvm settings, not on anyone's choice. Now it's off unless asked for
with --nested: Cloud Hypervisor gets nested=off or on, Firecracker a
custom CPU template (cpu-config) clearing SVM (CPUID 0x80000001 ECX[2])
and VMX (CPUID 1 ECX[5]), dropped with --nested. With it, and KVM in
the guest's kernel (base/kernel.nix), the guest gets /dev/kvm, to run
VMs itself, like NixOS VM tests. Off by default, as it opens more of
the host's KVM to the guest.
|
| |
|
|
|
|
|
|
|
|
| |
Firecracker's guest configuration has no KVM, so a guest had no
/dev/kvm, even where the VMM offered hardware virtualization (Cloud
Hypervisor does by default, its CPUs show svm), and nothing could be
tested in a VM there, not even a NixOS VM test. Now the cut-down
kernel has KVM (and kvm-amd, kvm-intel) as modules, which udev loads
when the CPU has svm or vmx, i.e. when the VMM offers it (see
run-firecracker-vm --nested).
|
| |
|
|
|
|
|
|
|
| |
nix-store --verify removes paths that are gone from the database, but
not those that other valid paths refer to: it reports them, and exits
with an error, which failed nix-load-db, and with it the nix daemon,
so every nix command failed in the guest. Now nix-load-db reports it,
and the guest keeps its nix: a build that needs a missing path fails,
and says why.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
fc-rw-store-unshadow dropped every path in the rw-store that a lower
layer had, as complete there, including the host's store. But the
host's store isn't fixed like the images: its garbage collection can
remove a path any time, and then a path the guest's nix had added and
still has registered (its own copy dropped at boot, in favour of the
host's) is gone. nix-store --verify then can't fix the database (the
missing paths have valid referrers), nix-load-db fails, and with it the
nix daemon. Now only paths that an image has get dropped, and of the
host's store's, only whiteouts, which would hide its path; real copies
stay (tested in a scratch tree, with a whiteout made in a user
namespace).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
Firecracker ends on a reset (reboot, with reboot=k), but stays on
poweroff, with the guest halted; Cloud Hypervisor ends on poweroff, but
restarts the guest on a reset. So which one left the VM depended on the
VMM. Now the run script tells the guest (fc.vmm on the kernel command
line), and a generator, fc-vmm-exit, changes the shutdown's last step,
the SuccessAction of systemd-poweroff and -halt to reboot-force in
Firecracker, and of systemd-reboot and -halt to poweroff-force in Cloud
Hypervisor, after the same clean shutdown. Not a hook of
systemd-shutdown, which runs those after unmounting, i.e. without /etc,
an overlay here (found out the hard way: the first version, with such a
hook, did nothing).
|
| |
|
|
|
|
|
|
|
|
|
| |
bash passes the fds of the locks (on the store and home images, the
tap, the name) on to every child, so the 9P servers and the watcher of
nixpkgs held them, too, and when the script got killed (without its
trap running), they stayed, and kept the VM's files locked: "is in use
by another VM" on the next start. Now the helpers close them first,
and only the VMM keeps them, as long as it runs (tested: a script
killed with a helper left over leaves the file locked, and doesn't with
close_locks).
|
| |
|
|
|
|
|
|
|
|
| |
With --nixpkgs-cache (loose: 7s for nix-instantiate '<nixpkgs>' -A
hello, against 20s without), the guest doesn't see changes to the host's
nixpkgs until it drops its caches. When nixpkgs is a Git checkout, the
run script now checks its commit every 5 seconds, and on a change
(checkout, pull, rebase), connects to the guest's vsock port 1235, where
layers/nix.nix has fc-drop-caches run. Changes without a commit still
need fc-drop-caches by hand.
|
| |
|
|
|
|
|
|
|
|
|
| |
9P with cache=loose (the host's store; /nixpkgs with
--nixpkgs-cache=loose, which evaluates three times as fast as without)
never asks the host again: a file changed on the host keeps its old
size and contents in the guest (nix then reads a truncated
aliases.nix), and a name looked up before the host had it stays
missing, until the guest drops its cached dentries and inodes, which
only root can. fc-drop-caches lets anyone: a setuid wrapper for a
program that takes no input and only ever writes 2 to drop_caches.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Firecracker was the only hypervisor, with its limit of about 19 devices
(virtio-mmio, an interrupt each), no hot-plugging, and no virtio-fs.
Now the run script can also start the same build in Cloud Hypervisor
(--vmm cloud-hypervisor; Firecracker stays the default), translating
the Firecracker configuration it makes anyway into Cloud Hypervisor's
options: kernel (the same vmlinux, which it boots via PVH), initrd and
command line, CPUs and memory, the drives (read-only for the images),
the tap and MAC, vsock. The drives are image_type=raw: without it,
Cloud Hypervisor guesses, and then refuses writes to sector 0, which
wrecks ext4 (the rw-store, home). Its vsock works like Firecracker's
(a guest's connection to port PORT goes to the socket SOCKET_PORT), so
the 9P servers stay as they are, and the guest finds its drives by
label, so their order on PCI doesn't matter. Unlike Firecracker, it
restarts the guest on reboot (a reset), so the way out there is
poweroff. Its options are KEY=VALUE,... lists, so it takes no commas
in --store and --home.
|
| |
|
|
|
|
|
| |
Firecracker attaches its devices via MMIO, Cloud Hypervisor and qemu via
PCI, which the cut-down kernel has built in, and linuxPackages_latest as
a module, which the initrd needs, for the drives. Harmless where
there is no PCI (allowMissingModules, too).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
NixOS's overlay.lowerdir makes the store's lower layers a single mount
option, lowerdir=/sysroot/nix/.image/0:..., which util-linux passes with
the new mount API, which caps a string option at 255 bytes: at most 11
images, 10 with nix. Now the base system generates the store's mount
from the layers, a lowerdir+= each (kernel 6.8 and later), which has
that limit per path only (tested in a user namespace: 30 long paths,
4470 bytes, mount; a single lowerdir of them doesn't; and lowerdir+=
can't follow lowerdir=, so it's one or the other). The limit is now
Firecracker's number of devices.
The lower layers are fc.storeLowerdirs: the images first, as reading
them is fast, then what layers add, like layers/nix.nix the host's
store, which also adds its upper layer to the options, created by
fc-rw-store-unshadow now (NixOS's service for that comes only with
overlay.lowerdir).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Every change to a guest meant a new image and a reboot. For a faster
development loop, a guest with nix can now switch to a new build of its
system instead: layers/switch.nix, imported into a layer, turns the
switch on (the base system keeps it off, as a default now), and the run
script's derivation has the system, so the host builds it with
nix-build -A toplevel and runs its switch-to-configuration in the guest,
which sees the host's store, where it got built (tested: a path added on
the host shows up in the running guest). A switched guest runs what it
didn't boot, so for production, it's still a reboot with the new run
script. The kernel, its command line, Firecracker's configuration, new
secrets, and adding or removing layers need one anyway.
A path the guest looked for before the host had it stays missing, as the
store's overlay remembers that (tested), until the guest drops its
caches, which takes seconds, so that's documented, not done every time:
nothing in the guest looks for paths it doesn't have, as a rule.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nixpkgs' systemd comes with much a guest has no use for: importd (with
gnupg and openldap), cryptsetup, TPM2, FIDO2, homed, repart, sysupdate,
portabled, machined, nspawn and vmspawn, journal-remote (microhttpd,
gnutls), coredump (elfutils), BPF (libbpf), qrencode, pwquality,
AppArmor. And dbus brings in a second systemd, systemd-minimal (23M),
X11's libraries, and AppArmor, too. Leaving all that out means
building systemd, dbus and dbus-broker (which links libsystemd) from
source, on every nixpkgs bump, so it's a base module (--arg base
'[ base/systemd.nix ]'), for whoever thinks that's worth it. NixOS
leaves out the units of what the package lacks; coredump the base
system turns off already, and the module takes systemd-bsod out of the
initrd (where NixOS has it unconditionally), as systemd builds it only
with qrencode.
|
| |
|
|
|
|
|
|
|
|
|
| |
A path rule was a plain string prefix of the request's path, so
https://api.github.com/search/issues, meant for that API endpoint (with
whatever query), also allowed /search/issuesomethingelse, and the only
way around it, /search/issues/, didn't allow the endpoint itself. Now a
rule's path allows itself and the paths below it, /search/issues/...,
but not /search/issuesx; one ending in "/" still allows whatever starts
with it. The query was never part of the match, and still isn't. The
requests' checks and POST /check share the code now.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The guest mounted its drives by their device names, which come in the
order the kernel probes the drives, not necessarily in their order in
the Firecracker configuration: booted with linuxPackages_latest, where
virtio_blk and virtio_mmio are modules, the base image and nix's came
swapped (vdb and vdc), which went unnoticed only because the store's
lower layers can be in any order. With /home or the rw-store swapped,
it wouldn't have been harmless.
Now the guest goes by filesystem labels: image k is fc-layer-K (mkfs.erofs
-L), the rw-store fc-store, and home fc-home. The run script labels
the ext4 images when it creates them, and existing ones, from before
labels, before the guest starts. This also drops the drive letters'
limit of 26 drives.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
kernelPackages and caCert
The base system could only be changed by its two arguments, and a
kernel set in a layer was a conflict with the base's plain
boot.kernelPackages = kernelPackages. Now base takes NixOS modules,
merged into the base system, i.e. layer 0 and its image, so what all
layers share goes there, the kernel above all: kernel.nix is such a
module now, and no package any more, so it moves to base/ (--arg base
'[ base/kernel.nix ]', like --arg layers '[ layers/nix.nix ]'), and the
base's linuxPackages_latest is only a default. A layer can set the
kernel, too, now, but then the base image keeps its own kernel's
modules (161M for linuxPackages_latest), unused.
caCert wasn't used: the egress proxy's CA stays where modules/host puts
it, picked up if it's there; another one is
security.pki.certificateFiles, in base or a layer.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
A serial line, unlike a pty, doesn't get told when the terminal's size
changes, so the console kept the size the run script saw at boot
(systemd.tty.rows/columns.ttyS0), e.g. 6 rows, from a tmux pane that
small for a moment, and a tmux attached there drew for that, whatever
the terminal's size. Now there's resize, which asks the terminal
(ESC[6n, after moving the cursor as far as it goes, then back) and sets
what it answers (stty rows, cols), and the shell on the serial console
runs it before each prompt, until the terminal doesn't answer (within a
second). A tmux attached there still keeps its size until attached
again.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The SSH host key had a way of its own into the guest: --ssh-host-key
FILE (by default ~/.local/share/run-firecracker-vm/ssh_host_ed25519_key,
created if it didn't exist), served via 9P on vsock port 567, and
fc-ssh-host-key. Now it's a secret like any other: the base system
declares it (fc.secrets.ssh_host_ed25519_key, at
/run/ssh/ssh_host_ed25519_key, 0600, with sshd), so the run script
requires --secret ssh_host_ed25519_key=FILE, and checks it as before
(adding a missing final newline; no passphrase). There's no
--ssh-host-key any more, nor a default key, and the secrets take over
port 567.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Secrets for a guest, like API keys, had no way in but the store or
/xchg, which other VMs started in the same directory see. Now a layer
declares the secrets its guest needs (fc.secrets.NAME, with where it
goes, default /run/secrets/NAME, and whose it is, default root's, 0400),
and the run script gets them with --secret NAME=FILE (FILE read once,
so a pipe will do), refusing to start the guest without the declared
ones. Like the SSH host key, it copies them into its private temporary
directory and serves that via 9P on vsock port 568, to that guest only;
there, fc-secrets copies them into place, before sysinit.target (so
before any service with the default dependencies), but after the users
get created, and unmounts the share again. A secret the guest doesn't
declare goes to /run/secrets/NAME, root's, with a warning.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
So a guest can know beforehand whether it gets somewhere, instead of
finding out by timeouts and retries, and can tell which rule it lacks.
nginx answers POST http://172.16.0.1/check (the guests' port 80 of
172.16.0.1 gets redirected to 172.16.0.1:checkPort, default 10080;
plain HTTP anywhere else stays refused): URIs one per line, at most 100,
and true or false for each, a line each, by the same rules as the
egress: whole domains and path rules for https://HOST[/PATH] (port 443
only), and for tcp:// and udp://HOST:PORT the list's rules, with names
as resolved for the guest's tap (its hosts file), but not to
denyDestinations or the host's own addresses on fcbr0, and not to tcp
port 443, which goes to the proxy. Read-only, about the asking guest's
own list only (by its address, as for its egress), and rate-limited.
In the guest, fc-egress check URI... asks that, over bash's /dev/tcp, as
the guest may have no HTTP client, and prints true or false and the
URI, a line each; exit status 0 if all are allowed, 1 if not, 2 on
errors.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since the base system turned off the console (and with it kbd), it had
no getty at all: NixOS's gettys come with the console
(services/ttys/getty.nix), so there was no shell on ttyS0 any more, only
the kernel's and systemd's messages, and ssh. That stays the default,
and the base system's console.enable is only that now, a default, for
layers/console.nix: the console, with root logged in on ttyS0 (a
default, too: services.getty.autologinUser can name another user, or be
null for a login prompt), but no getty on tty1, and no
systemd-vconsole-setup, which moved there from the base system, like
the autologin. It's small, so the README has it imported into another
layer, rather than as a layer, with an image, of its own, which works,
too.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The guest has no screen, no X, and no hardware to tell apart but
virtio, so the base system leaves out kbd and systemd-vconsole-setup
(console.enable; the unit doesn't need disabling any more), fontconfig
and freetype, su's xauth with libX11 & co. (which shadow.nix turns on,
not as a default), and udev's hardware database (14M). And there's
nothing to unmount from a ramfs at shutdown: / is a tmpfs, and the
store's images are read-only; systemd-shutdown remounts what's still
busy, like the rw-store, read-only. About 30M less in the base image,
and a service less at every shutdown.
|
| |
|
|
|
|
|
|
| |
Each layer's system links its own initrd, so each layer's image had
one, 19 to 25M, but the guest never reads any of them: Firecracker gets
the initrd from the host. Now the images leave all of the systems'
initrds out; with nix, the top system's is still in the host's store,
where the registration says it is.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
A VM got the first free tap of its user's, and a tap's address came from
its number, so a VM's address depended on what else ran, and on the
users before it, and a reverse proxy on the host could only guess it
(172.16.0.2, i.e. fctap0, for hermes).
Now addresses are the VMs': the host module takes vms, VM name -> user
and address (vms = { hermes = { user = "tv"; ip = "172.16.0.2"; }; }),
any number of them, and a VM takes any free tap of its user's, which
gets its address while it runs, so at most as many run at the same
time as the user has taps. Taps have addresses of their own, for
VMs without one: from 172.16.0.200 on, so they stand out (but for VMs'
there). The MAC address, which dnsmasq hands out every address by, is
06:00 and the address (06:00:ac:10:00:02 for 172.16.0.2), and with it
the IPv6 addresses; the run script takes the VM's from /etc/fc-vms, or
the tap's own from /etc/fc-taps. The VMs' addresses are also in
config.fc.vms.NAME (user, ip, ip6), for the host's configuration, e.g.
proxyPass = "http://${config.fc.vms.hermes.ip}:9120";
Which address a tap has is up to fcbr0-firewall, which now also runs
when a tap's VM's name (/run/fc-egress/TAP.name, which the run script
writes) changes: the VM's, if it's one of the tap's user's in vms and
on none of their other taps, too, else the tap's own. It puts it into
the tap's new nftables sets addr_TAP and addr6_TAP, in the bridge's
table, which lets the tap send from nothing else (instead of the static
set guests), and in the other, whose per-tap rules go by them (instead
of the tap's fixed addresses); and into /run/fcbr0-addr, ADDRESS: TAP
and TAP: ADDRESS, where egress.lua finds a guest's tap (as long as both
agree, and the address and the tap are the same user's), and the run
script waits for its address before starting the guest. fc-egress vms
shows the taps' addresses, too.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The base system had nix, the nix-daemon, the host's store and nixpkgs
via 9P, and a writable store on a drive, a scratch file without --store.
Now all of that is in a layer of its own, layers/nix.nix, and the base
system has neither nix nor nix-daemon in its closure: its store is its
images, read-only, an overlay of them, or with a single image, the image
itself, as overlayfs needs at least two lower layers without an upper
one. This can become the base layer for guests that only run services.
As a layer, nix gets an image of its own: put first, it's the same for
all guests with nix, instead of in the image of whichever layer wants
nix. It sets fc.nix, which the run script goes by, and nix.enable;
setting nix.enable without it fails an assertion, as the run script
wouldn't give the guest the drive for its store.
The image decides, so the run script checks that the options fit it: a
guest with nix requires --store (no more scratch store), and one
without refuses --store, --store-size, --nixpkgs and --nixpkgs-cache.
Without the rw-store drive, the images come first, and home after them;
the store and nixpkgs aren't served, there's no fc.registration, and
the initrd doesn't mount anything via 9P. The run script now waits for
each of the 9P servers it starts, not only the store's.
|
| |
|
|
|
|
|
| |
A layer that keeps its state in /home can set fc.home.required, and the
run script then refuses to start the guest without --home, instead of
booting with /home on the tmpfs, where the state is gone when the guest
exits.
|
| |
|
|
|
|
|
|
|
| |
Being before sshd.socket made an ordering cycle: a service is after
basic.target by default, which is after sockets.target, which is after
sshd.socket. systemd broke it by dropping fc-ssh-host-key, so sshd had
no host key and closed every connection. Now fc-ssh-host-key runs
early, without default dependencies (but before shutdown.target and in
conflict with it), and makes its mount point under /run.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fc-ssh-host-key only ran on the first connection, as a requirement of
the socket-activated sshd@ instance, and without startWhenNeeded not at
all, so NixOS generated a random host key instead. Now it's required
by, and runs before, whichever of sshd.socket or sshd.service is in use,
startWhenNeeded is only a default (a layer can turn it off), and NixOS
doesn't generate host keys.
The run script now also deals with the key first thing, before starting
any servers: it may be a pipe (<(...)), so it's read once, for the copy;
a missing final newline gets added (sshd refuses the key without); and
ssh-keygen -y checks it's a key without passphrase, so a bad one stops
the run script right away rather than every connection.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The guests run sshd, started on demand, with an ed25519 host key that
isn't in the store: the run script takes it from --ssh-host-key FILE, by
default ~/.local/share/run-firecracker-vm/ssh_host_ed25519_key, created
on first use, so a user's guests share one key and one known_hosts line
covers them (see README.md), and serves a copy from its private
temporary directory via 9P on vsock port 567. In the guest,
fc-ssh-host-key copies it to /run/ssh (0600) before sshd starts, and
unmounts the share again. Who may log in is up to a layer
(users.users.<name>.openssh.authorizedKeys).
|
| |
|
|
|
|
|
| |
The guest's number of CPUs, default 2 as before, 1 to 32 (Firecracker's
range). jq sets it in the config, along with --mem-size (instead of the
quoted placeholder sed replaced) and dropping the home drive without
--home, as before.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The guests get IPv6: fcbr0 has fdfc:fc::1/64 (module argument prefix6),
the host's dnsmasq sends router advertisements, and each guest takes the
address from its MAC (SLAAC with EUI-64; the guest's networkd is set up
for that, without privacy addresses), so the host knows each tap's
address, as with IPv4.
The rules take IPv6 addresses in brackets, tcp://[42::1]:22 or
udp://[42::/16]:5000-5100, and names now resolve to both families (and
get AAAA records for the guests). Forwarded connections get NATed to
the host's address, like IPv4. Like IPv4 everything else is refused:
the bridge only lets a tap send from its own addresses (or :: for
duplicate address detection), the host only answers neighbour and router
discovery, denyDestinations and the per-guest limits apply. HTTPS stays
IPv4, through the proxy: IPv6 port 443 is refused.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
The output chain started with meta skuid != "fcbr0-egress" accept, but
meta skuid doesn't match packets without a user at all, like those the
kernel sends on its own, so they went on to nginx's restrictions. Most
are replies (ct established, accepted), but IPv6 neighbour and router
discovery (to ff02:: and fe80::) and IGMP (224.0.0.x) aren't, and got
rejected as denyDestinations: the host's own IPv6 stopped working.
Now only packets of the fcbr0-egress user jump to a chain with nginx's
restrictions; everything else passes.
|
| | |
|
| |
|
|
|
|
| |
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, ...).
|
| |
|
|
|
|
|
| |
So a log line's destination can be copied into fc-egress allow: HTTPS
connections now log https://SERVER, decrypted requests METHOD
https://HOST/URI, and fc-egress log adds tcp://DST:PORT (or udp://)
after the tap to the kernel's lines for other connections.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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, ...).
|
| |
|
|
|
|
|
|
|
|
| |
Like tcp:// and udp:// rules, HTTPS rules are now URIs:
https://DOMAIN (with subdomains, passed through) and
https://DOMAIN/PATH-PREFIX (decrypted to check the path), instead of
DOMAIN and DOMAIN/PATH-PREFIX. The old forms are refused by fc-egress
and ignored by egress.lua; to convert existing lists:
sed -i -E '/^[a-z]+:\/\//!s#^#https://#' /var/lib/fc-egress/*/*
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The guests' DNS resolves every name to the host, so ssh somename went
to the host, even with a rule for somename's address. Now the rules
can take names, tcp://NAME:PORT[-PORT]: the firewall update resolves
them on the host (IPv4) into the VM's set, and writes their addresses
to a hosts file per tap in /run/fcbr0-hosts, which the guests' dnsmasq
reads (--hostsdir; such entries win over address=/#/). A timer
resolves them again every 5 minutes.
dnsmasq can't tell guests apart, so every guest gets those addresses
for those names, but only VMs whose list has the rule can connect.
fcbr0-firewall now runs as a static user, fcbr0-firewall, which owns
/run/fcbr0-hosts, and may use IPv4 and IPv6 sockets, for resolving.
|
| |
|
|
|
|
| |
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.
|