Host admin
This page is for whoever looks after the computer cairn runs on. It covers who may use cairn, the host's policy files, the cairn admin tools, and how to remove cairn cleanly.
Who may use cairn
Only root and members of the cairn group may run VMs. The package creates the group.
sudo usermod -aG cairn alice # give alice access
cairn access alice # check: the last line says "allowed", or why not
cairn access --all # list every member of the groupThe change takes effect immediately. cairn checks /etc/group every time it runs, so the user doesn't need to log in again. On Ubuntu, a new user also needs the kvm group, and that one does need a new login. See Install.
A user whose primary group is cairn is refused, because that kind of membership can't be removed with gpasswd -d. Add them as an ordinary member instead.
cairn only knows local accounts from /etc/passwd. LDAP and sssd users can't use it.
Remove a user
List every account name that shares the user's id, and which of them are members:
shcairn access aliceRemove each name marked
memberfrom the group:shsudo gpasswd -d alice cairnRun
cairn access aliceagain. It must say not allowed, and list nopaddedentry.
Always run the second check
A group entry with stray spaces around a name (a padded entry) can't be removed with gpasswd -d, and gpasswd reports success anyway. If cairn access still lists a padded entry, remove it by editing the group file with sudo vigr.
Removing access doesn't stop VMs that are already running. The user, or root through sudo -iu alice, stops them as shown in Stop everything, or deletes them with cairn destroy.
A stopped cairn run app may still hold work that hasn't synced back. Give the user access back for long enough to recover it, then remove it again.
Host policy files
Two files in /etc/cairn/ set limits for everyone. The package installs both with every setting at its default. Upgrades keep your edits. Reference copies are in /usr/share/doc/cairn/net.conf.example and /usr/share/doc/cairn/vmm.conf.example.
After editing either file, check it:
cairn admin check-configok /etc/cairn/net.conf
ok /etc/cairn/vmm.confThis uses the same parser the helper programs use. cairn doctor runs the same check.
Network policy: /etc/cairn/net.conf
Limits for cairn-helper, the program that sets up networks and published ports.
| Setting | Default | Meaning |
|---|---|---|
max_networks_per_uid | 16 | The most networks one user may have (1 to 4096). |
max_ports_per_uid | 64 | The most published ports one user may have (1 to 4096). |
min_host_port | 1024 | The lowest port an ordinary user may publish (1 to 65535). |
allow_privileged_ports | empty | User ids that may publish below min_host_port. |
allow_public_publish | false | Whether every user may publish on addresses other than 127.0.0.1. |
allow_public_uids | empty | User ids that may publish on other addresses even when allow_public_publish is false. |
extra_blocked | empty | Extra IPv4 ranges (CIDR) that VMs may never reach, on top of the built-in list. |
transit_pool | 10.250.0.0/16 | The range used for the small link between each network and the host. It mustn't overlap a route on the host. |
For example, to let user 1001 publish on any address, and allow everyone at most 8 networks:
max_networks_per_uid = 8
allow_public_uids = 1001VM policy: /etc/cairn/vmm.conf
Limits for cairn-jail, the program that starts each VM in its jail.
| Setting | Default | Meaning |
|---|---|---|
max_machines_per_uid | 64 | The most VM jails one user may have at once, running or waiting to be cleaned up (1 to 4096). |
root_size_mib | 64 | The size in MiB of each running VM's private in-memory filesystem (32 to 1024). |
There are deliberately no settings for where Firecracker, the jailer or the jails live.
File format rules
Both files use the same strict format:
- one
key = valueper line. Blank lines and lines starting with#are ignored; - a
#after a value is an error, so put comments on their own line; - each key may appear once;
- an unknown key is an error, not a warning. The helper refuses to start, and names the line;
- lists are separated by commas. User ids are numbers (names aren't accepted).
The file must be a regular file of at most 64 KiB, owned by root and writable only by root. It's read without following symlinks. A missing file means every setting has its default.
Admin tools
cairn admin holds tools for the host administrator. All of them accept --json.
| Command | What it does |
|---|---|
sudo cairn admin inventory | List everything cairn has on the host: every network and port record, every VM jail, and every cairn process. Changes nothing. --require-quiet exits 0 only if nothing remains. |
sudo cairn admin cleanup | Finish any leftover cleanup for the network helper and the jail. |
sudo cairn admin maintenance begin | Turn on maintenance mode. |
sudo cairn admin maintenance end | Turn it off. |
sudo cairn admin maintenance status | Show whether it's on. |
cairn admin check-config | Check the policy files. --file <PATH> checks a different file. Any user can run it. |
cairn admin check-caps <PATH>... | Compare files' Linux capabilities with --expect (none by default, or a list such as cap_a,cap_b=ep). Used by packaging tests. |
cairn admin probe-device <PATH>... | Open devices and report on each. Used by cairn doctor for /dev/kvm and /dev/net/tun. |
Running a root-only command as an ordinary user fails with a message that tells you to use sudo.
Maintenance mode
Maintenance mode stops anything new from starting on the host, so you can upgrade or remove cairn safely. Running VMs aren't touched.
sudo cairn admin maintenance begin --why upgrade --require-quiet
# ... upgrade or remove ...
sudo cairn admin maintenance endbeginruns cleanup, turns maintenance mode on, and records whether the host is quiet.--why <word>labels it, for exampleupgradeorremove(defaultadmin).- With
--require-quiet, if anything is still running, it turns maintenance mode off again and exits1.
While it's on, deploys and other commands that create things stop with the maintenance message.
Stop everything but keep the data
As each user, stop every app and network. Nothing is deleted.
cairn ps # see what is running
cairn stop <app> # for each running app; the disk is kept
cairn run --stop # for a cairn run app, from inside its folder
cairn net ls # list networks
systemctl --user stop cairn-net-<network>.service # for each network
cairn ps # every app should now show "stopped"To bring them back later, run cairn net up <network> and then cairn start <app>.
To delete instead, which can't be undone: cairn destroy <app>, then cairn net destroy <network>.
Remove cairn
First stop everything, as above. Then remove the package:
sudo dnf --setopt=clean_requirements_on_remove=False remove cairnsudo apt remove cairnRemoving the package keeps every user's ~/.cairn, including app disks, volumes and network definitions. If anything is still running, the removal refuses and lists what is still running.
Why the extra dnf option?
By default, dnf removes dependencies that nothing else needs any more (git, for example) before cairn's own removal script gets the chance to refuse. The option keeps them, so that a refused removal really does leave the system unchanged.
Forcing removal
If you have to remove the package while VMs are still running, create the override file as root and remove the package again:
sudo touch /var/lib/cairn/force-removeThe package then removes itself without checking. Anything still running, including VMs and their network rules, is left behind with nothing managing it, and /var/lib/cairn is kept. The file is used once and then deleted.