Commit fec785e
committed
fix(microvm): the admission budget was never checked against the host's RAM
SH_MAX_COMMITTED_MB=24576 less SH_MEMORY_RESERVE_MB=4096 is a 20 GiB admission
budget, and nothing in the worker reads MemTotal, so on a 16 GiB host the gate
cannot refuse before the OOM killer arrives. Every other invariant in this tier
fails at start rather than trusting the operator (AssertPathExists=/dev/kvm,
SH_MAX_COMMITTED_MB being mandatory, Config.Normalize's cross-field checks); the
one that was missing is the check against the host the unit is running on. It
has a measurement consequence too: a gate that never refuses reads as
confirmation of spec §7.4's prediction 1 rather than as its falsification.
AssertMemory=>=23G in [Unit]. systemd compares it against physical memory
(memory assigned to the container, in a container) and fails the unit at start,
the same posture as AssertPathExists -- and, like it, an assertion does not
trigger Restart=, so it cannot crash-loop. 23G against a 24 GiB budget rather
than 24G because physical memory here is MemTotal, always somewhat below nominal
RAM: a threshold equal to the budget would refuse to start on a genuine 24 GiB
host.
The test extracts the threshold, requires the >= comparison, normalises it to
MiB and bounds it on both sides of SH_MAX_COMMITTED_MB: at least 90% of it (so
raising the budget alone is a test failure, not a discovery made by the OOM
killer) and no more than it (so an assertion above nominal RAM, which would
refuse to start on the very host it was written for, is also a test failure).
Verified red on three mutations: the assertion deleted (3 checks),
SH_MAX_COMMITTED_MB raised to 65536 alone, and the threshold moved to 25G.
Parse-checked against real systemd, since an unknown key would be ignored with
only a warning: systemd 255 (ubuntu:24.04) and 249 (ubuntu:22.04) both accept
AssertMemory and the StartLimit keys, reporting nothing but the absent ExecStart
binary.
This is the unit-level form of the reviewer's suggestion. A MemTotal comparison
inside Config.Normalize would be the other half; internal/vmpool/ is outside
this change's scope, so it is not done here.
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Paolo Dettori <dettori@us.ibm.com>1 parent 0aa41d1 commit fec785e
2 files changed
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
71 | 96 | | |
72 | 97 | | |
73 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
157 | 201 | | |
158 | 202 | | |
159 | 203 | | |
| |||
0 commit comments