Skip to main content

Module setup

Module setup 

Source
Expand description

A guided setup of this computer: what to install, start or restart, in which order, for the kinds of project wanted (containers, VMs), with which engine and which hypervisor. The one place these rules live:

  • options works out, from what the machine check found (Machine), what each choice a setup offers takes here: a UI renders those actions and runs each, never working them out itself;
  • plan() puts them in order for a whole setup, from what is Wanted;
  • walk() runs that plan step by step through the caller’s own runner of each step, the machine checked again after each (an install changes what comes next);
  • on Windows, join_hyperv_admins and schedule_restart carry out what a setup asks beyond installs, as crate::docker::start_engine starts an engine; on Linux, share_virtualization lets VirtualBox share the CPU’s virtualization with KVM.

Why something is passed over or left alone is a code (PassedOver, LeftAlone) a UI says in its own words.

Structs§

DockerFound
Docker and its engines, as the machine check found them.
EngineOption
A container engine, and what makes it the one Docker uses here.
HypervisorOption
A local hypervisor: what gets it here (get: nothing once it is installed and can run), then what Vagrant needs to drive it (vagrant: Vagrant, its plugin, VMware’s utility, in order).
Machine
What a setup reads of the machine check (Check): the computer, its package manager, Docker and its engines, WSL 2, the Vagrant providers and the groups pending a login.
Options
What each choice of a setup takes on this computer.
Plan
A whole setup on one computer.
Step
One action of a plan, with the item it is about (wsl, docker, engine:<id>, vagrant, <hypervisor>, plugin:<name>, vmware-utility).
Steps
How a walk runs its steps: the caller’s own runner of each, and its machine check.
Walked
Where a walk ended.
Wanted
What a whole setup is for.

Enums§

Action
One thing a setup does, or leaves to its user, on this computer.
Event
What a walk tells as it goes; O: how the caller’s runner says a step ended.
LeftAlone
Why a setup leaves a step alone: its user’s to take, or it can’t run here (left_alone).
ManualReason
Why something is the user’s to get.
OnFailure
What a walk does once a step failed.
PassedOver
Why a hypervisor wanted isn’t the one a setup sets up. A UI says each in its own words.
Restart
How a restart was asked for.
RestartFailed
Why a restart wasn’t scheduled.
SetupPath
A kind of project a setup readies this computer for.
ShareFailed
Why KVM wasn’t set to share the CPU’s virtualization.
Shared
When VirtualBox can use the CPU’s virtualization.
WindowsFeature
A Windows feature that starts only after a restart.

Constants§

OPTION
The option itself: KVM turns the CPU’s virtualization on only while one of its VMs runs.
OPTION_FILE
The modprobe file the option is written to, in /etc/modprobe.d.
RESTART_NOTE_MAX
The longest note a restart shows while Windows counts down (shutdown.exe takes 512).

Functions§

cant_run
An installed hypervisor that still can’t run VMs once everything Vagrant needs is in (no /dev/kvm, not in the kvm group, a stuck service): its reason says why.
engines_on
The engines a setup offers on os, in the order it shows them.
installable
The hypervisor a setup installs as provider on os, when it installs it.
join_hyperv_admins
Adds this account to “Hyper-V Administrators” (join_hyperv_admins_step), each line it prints handed to on_line.
join_hyperv_admins_step
The step that adds this account to “Hyper-V Administrators” through one UAC prompt: the membership applies from the account’s next sign-in.
left_alone
Why a setup doesn’t run action itself, when it doesn’t: its user’s to take, or it can’t run here. None for a step a setup runs (a restart and a new login it leaves to its caller).
options
What each choice takes on machine m; hyperv_restart: a setup turned Hyper-V on in this boot, so it waits for a restart.
plan
The whole setup wanted on machine m with its options (super::options), in a setup’s order: WSL 2 and the engine, then the hypervisor and what Vagrant needs for it; a restart or a new login last, so everything else is done first.
recommended_engine
The engine a setup installs in one click on os: Docker Desktop on macOS and Windows, Docker Engine on Linux.
schedule_restart
Asks Windows to restart in after (shutdown /r /t <s> /c <note>), its countdown showing note. A restart scheduled already is Restart::AlreadyScheduled, not a failure.
share_script
The root script that writes OPTION to OPTION_FILE in modprobe_d, then, when reload names KVM’s CPU module (kvm_intel, kvm_amd), unloads it and kvm and loads it again, which loads kvm with the option. An unload modprobe refuses (a module in use) leaves the option for the next restart; the CPU module is loaded again either way.
share_step
The step that sets KVM on host to share the CPU’s virtualization, elevated by elevation: its modules loaded again when nothing uses KVM now (kvm::in_use).
share_virtualization
Sets KVM to share the CPU’s virtualization (share_step, each line it prints handed to on_line), then reads when VirtualBox can use it. Nothing runs where KVM doesn’t hold it.
sharing
When VirtualBox can use the CPU’s virtualization on the context’s host, as detection reads it now: none when KVM holds it and isn’t set to share it.
walk
Walks the setup wanted from machine and its options: the next step of the plan not done yet (a restart or a new login last, never run) run by steps, told to on, the machine checked again after it, until none is left, or (on_failure) one fails.