Skip to content

Commit fe3ef7f

Browse files
nix: homa-lifecycle, timed phases over ttyS0 and a virtio console
Following the pcp lifecycle tests: the guest gets two consoles on host TCP ports. ttyS0 stays the only kernel console and QEMU logs it to serial.log from the first byte; hvc0 is a virtio console with a root shell that the host drives: 1 start, 2 serial, 2b virtio, 3 smoke (homa-smoke over hvc0), 4 module cycles (insmod / netns add+del / rmmod x5), 5 dmesg, 6 poweroff, 7 qemu exit, 8 serial log Each phase has its own timeout and time; phases that need the shell are skipped once it is gone, and phase 8 still catches oopses after that (late RCU callbacks, F8). Reading dmesg over hvc0 takes about 200 ms instead of seconds at 115200 baud. On main, phase 3 crashes in homa_route_free (F8). With the fork #22 fix all 9 phases pass in about 22 s, and homa-vm-matrix (now with homa-lifecycle-<series>) is 8/8 in 51 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7bce3ba commit fe3ef7f

7 files changed

Lines changed: 378 additions & 19 deletions

File tree

‎flake.nix‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# nix run .#homa-microvm-test # boot a microVM, insmod homa.ko, loopback echo RPCs
2424
# nix run .#homa-microvm-test-6_12 # ... per VM kernel: 6_12 7_3 (kernel.nix vmSeries)
2525
# nix run .#homa-microvm-test-debug # ... under a KASAN/KMEMLEAK kernel
26+
# nix run .#homa-lifecycle[-6_12] # timed phases driven over ttyS0 + a virtio console
2627
# nix run .#homa-pair-test # two VMs: echo + cp_node (Homa, TCP) over a link
2728
# nix run .#homa-pair-test-6_12-7_3 # ... server kernel, client kernel (every pairing)
2829
# nix run .#homa-pair-exp # latency sweep (sysctls x workloads, metric deltas)

‎nix/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ nix build .#homa-tests # build + run the unit tests (ASan)
204204
nix run .#homa-microvm-test # default kernel: insmod, echo, GRO/RPS, rmmod
205205
nix run .#homa-microvm-test-<s> # ... on one kernel
206206
nix run .#homa-microvm-test-debug # ... under a KASAN/KMEMLEAK kernel (slow)
207+
nix run .#homa-lifecycle[-<s>] # host-driven, timed phases over ttyS0 + virtio console
207208
nix run .#homa-microvm[-<s>] # interactive guest
208209
nix run .#homa-pair-test # two VMs: echo + cp_node (Homa, TCP) across a link
209210
nix run .#homa-pair-test-<s>-<c> # ... server kernel <s>, client kernel <c>

‎nix/STATUS.md‎

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Related docs:
3333
| Single VM | `homa-microvm-test-{6_12,7_3}` | ✅ insmod, loopback echo, netns/veth with GRO+RPS (about 1.7k `homa_gro_receive` and 460 `homa_set_softirq_cpu` calls), rmmod, clean dmesg |
3434
| Two VMs | `homa-pair-test-<server>-<client>` | ✅ all four 6.12/7.3 pairings: ping, echo 100 B–1 MB, cp_node w4 over Homa and over TCP, clean dmesg on both. 8 VMs in parallel finish in 50 s |
3535
| Latency sweep | `homa-pair-exp`, `homa-pair-exp-socket` | ✅ F2 explained: QEMU's TCP `socket` link stalls packets; over the UDP `dgram` link (now the default) Homa's P50 matches TCP's |
36-
| VM matrix | `homa-vm-matrix` | ❌ on `main`: all 6 oops in `homa_route_free` (F8). ✅ 6/6 with the fix (fork #22), 46 s |
36+
| Lifecycle | `homa-lifecycle-{6_12,7_3}` | ❌ on `main`: phase 3 (smoke) crashes in `homa_route_free` (F8), and phases 7–8 report it. ✅ all 9 phases with the fix, about 22 s |
37+
| VM matrix | `homa-vm-matrix` | ❌ on `main` (F8). ✅ 8/8 with the fix (fork #22): smoke and lifecycle per kernel, plus four pairs, in 51 s |
3738
| KASAN VM | `homa-microvm-test-debug` | ⏳ not run yet (F7) |
3839
| Static analysis | `analysis-deep` | Four rounds triaged; see the bugs below |
3940

@@ -54,6 +55,34 @@ On the earlier TCP `socket` link, Homa's P50 was 2927–5024 µs and TCP's P99 a
5455
These are functional numbers: an emulated link between VMs that share host CPUs. They show
5556
that traffic flows, not how fast Homa is.
5657

58+
### Lifecycle test (`nix run .#homa-lifecycle`)
59+
60+
This follows the pcp and xdp2 lifecycle tests. The guest has two consoles on host TCP
61+
ports:
62+
63+
- **ttyS0** is the only kernel console. QEMU logs it to `serial.log` from the first byte,
64+
so an oops is caught even after the shell has died, during shutdown for instance.
65+
- **hvc0** is a virtio console running a root shell. The host drives each phase through it,
66+
and it is fast: reading 612 lines of `dmesg` takes 188 ms, where 115200 baud would take
67+
seconds. Kernel messages never mix into command output.
68+
69+
Results on 7.3 with the F8 fix:
70+
71+
| Phase | | ms |
72+
|---|---|---|
73+
| 1 start | qemu running, ports listening | 108 |
74+
| 2 serial | first kernel line on ttyS0 | 2482 |
75+
| 2b virtio | root shell answering on hvc0 | 12698 |
76+
| 3 smoke | `homa-smoke` over hvc0 | 2722 |
77+
| 4 cycles | 5 × insmod, netns add/del, rmmod | 1025 |
78+
| 5 dmesg | no BUG/Oops/WARNING/KASAN | 188 |
79+
| 6 shutdown | `poweroff` over hvc0 | 2 |
80+
| 7 exit | qemu exits | 3050 |
81+
| 8 serial-log | no oops anywhere in `serial.log` | 8 |
82+
83+
On `main`, phase 3 crashes. Phases 4–6 are then SKIPped (there is no shell), phase 7 reports
84+
"qemu exited before poweroff", and phase 8 shows the oops and its `RIP:` line.
85+
5786
### Build matrix (`nix build .#homa-build-matrix`)
5887

5988
| Kernel | Source | Result |
@@ -88,6 +117,7 @@ that traffic flows, not how fast Homa is.
88117
| `homa-microvm-test` (7.3.0), `homa-microvm-test-6_12` | ✅ PASS |
89118
| `homa-microvm-test-debug` (KASAN) | ⏳ not run (rebuilds the kernel) |
90119
| `homa-pair-test`, `homa-pair-test-<server>-<client>` | ✅ PASS for all four 6.12/7.3 pairings |
120+
| `homa-lifecycle`, `homa-lifecycle-<series>` | ✅ PASS with the F8 fix (see below) |
91121

92122
---
93123

@@ -305,4 +335,4 @@ and the 7.3 trees are prepared from source with each arch's nixpkgs kernel confi
305335
| 2026-10-21 | Round 2: rebased on `main`, 6.18 default, hermetic unit KDIR, real-code fuzz-mock (found #121), `analysis-reports/round2/` |
306336
| 2026-10-22 | 7.x: default 7.3, `kernel-src.nix` (7.0–7.2 and local trees), `homa-build-matrix`, per-kernel microVMs, GRO/RPS smoke test |
307337
| 2026-10-28 | The 7.1 patch landed upstream (#120), so `nix/patches/` is empty. Two-VM pair tests, cross-kernel pairs, this status doc. F2 latency sweep (`homa-pair-exp`): RESEND-timer stalls from QEMU's `socket` link, pair tests moved to `dgram` |
308-
| 2026-10-29 | John: `main` will target an LTS of 7.3+ (F1 closed). Phase 3 `homa-vm-matrix`; guests boot with `init_on_free=1`; found F8 (UAF in `homa_route_free`), fix as fork #22. riscv64/aarch64 cross builds (`homa-cross-matrix`, F9) |
338+
| 2026-10-29 | John: `main` will target an LTS of 7.3+ (F1 closed). Phase 3 `homa-vm-matrix`; guests boot with `init_on_free=1`; found F8 (UAF in `homa_route_free`), fix as fork #22. riscv64/aarch64 cross builds (`homa-cross-matrix`, F9). `homa-lifecycle` (pcp-style phases over ttyS0 and hvc0) |

‎nix/microvms/constants.nix‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@
2020

2121
stateVersion = "24.11";
2222

23+
# Lifecycle test (lifecycle.nix, pcp pattern): per-phase timeouts in seconds, and the host
24+
# TCP ports of each guest's consoles, serial (ttyS0) = portBase + 2i and virtio (hvc0) =
25+
# portBase + 2i + 1, where i is 0 for the default kernel and 1, 2, ... per vmMatrix entry.
26+
lifecycle = {
27+
portBase = 24700;
28+
timeouts = {
29+
start = 10; # qemu up and its console ports listening
30+
serial = 30; # first kernel line in serial.log
31+
virtio = 120; # a root shell answering on hvc0 (full boot)
32+
smoke = 180; # homa-smoke (smoke.nix), run over hvc0
33+
cycles = 90; # insmod / netns add+del / rmmod, several times
34+
command = 30; # any other single command
35+
exit = 60; # poweroff until qemu exits
36+
};
37+
moduleCycles = 5;
38+
};
39+
2340
# Two-VM pair test (pair.nix, lib-pair.nix; uds-rdma-proxy pattern). The guests share a
2441
# private L2 link on eth1: a QEMU "dgram" (UDP) netdev between two host ports, so no
2542
# root, tap or bridge is needed ("socket", a TCP stream, is kept for comparison; see

‎nix/microvms/default.nix‎

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# homa-microvm[-<series>] the QEMU runner package (nix run boots it directly)
66
# homa-microvm-test[-<series>] boot, run smoke.nix in the guest (insmod, loopback echo
77
# RPCs, rmmod), PASS/FAIL from the console log
8+
# homa-lifecycle[-<series>] host-driven phases over ttyS0 + a virtio console, each
9+
# timed: boot, smoke, module cycles, dmesg, poweroff, exit
10+
# (lifecycle.nix, pcp pattern)
811
# homa-microvm-debug default kernel with KASAN/KMEMLEAK
912
# homa-microvm-test-debug ... the same test under sanitizers
1013
# homa-pair-test[-<s>-<c>] two VMs (lib-pair.nix): Homa between server <s>, client <c>
@@ -43,9 +46,11 @@ let
4346
, pairPort ? constants.pair.socketPortBase
4447
, pairExperiments ? null
4548
, pairLink ? "dgram"
49+
, consolePorts ? null
4650
}: import ./mkVm.nix {
4751
inherit pkgs lib microvm nixpkgs buildSystem constants homaUtils
48-
kernelPackages withSanitizers autoTest pairNode pairPort pairExperiments pairLink;
52+
kernelPackages withSanitizers autoTest pairNode pairPort pairExperiments pairLink
53+
consolePorts;
4954
homaModule = buildModule { inherit kernelPackages; };
5055
homaModuleDebug = buildModule { inherit kernelPackages; enableDebug = true; };
5156
};
@@ -55,6 +60,17 @@ let
5560
runner = mkGuest { inherit kernelPackages withSanitizers; autoTest = true; };
5661
};
5762

63+
# Lifecycle test; index picks the guest's console ports (constants.lifecycle).
64+
mkLifecycle = { kernelPackages, label, index }:
65+
let
66+
base = constants.lifecycle.portBase + 2 * index;
67+
consolePorts = { serial = base; virtio = base + 1; };
68+
in
69+
import ./lifecycle.nix {
70+
inherit pkgs lib constants label consolePorts;
71+
runner = mkGuest { inherit kernelPackages consolePorts; };
72+
};
73+
5874
# Two-VM pair test: node0 (server) on serverKp, node1 (client) on clientKp.
5975
mkPairTest = { serverKp, clientKp, label, port, experiments ? null, link ? "dgram" }: import ./lib-pair.nix {
6076
inherit pkgs lib constants label port link;
@@ -112,17 +128,18 @@ let
112128

113129
defaultKp = kernelConfig.kernelPackages;
114130

115-
# homa-vm-matrix: every per-kernel smoke test and every pair, in parallel (phase 3).
131+
# homa-vm-matrix: every per-kernel smoke and lifecycle test and every pair, in parallel.
116132
matrix = import ./matrix.nix {
117133
inherit pkgs lib;
118134
tests =
119-
lib.mapAttrsToList
120-
(s: _: {
121-
name = "homa-microvm-test-${s}";
122-
kernels = s;
123-
exe = perKernel."homa-microvm-test-${s}";
124-
})
125-
kernelConfig.vmMatrix
135+
lib.concatMap
136+
(s: map
137+
(kind: {
138+
name = "homa-${kind}-${s}";
139+
kernels = s;
140+
exe = perKernel."homa-${kind}-${s}";
141+
}) [ "microvm-test" "lifecycle" ])
142+
vmSeries
126143
++ map
127144
(p: {
128145
name = "homa-pair-test-${p.server}-${p.client}";
@@ -132,18 +149,21 @@ let
132149
pairList;
133150
};
134151

135-
perKernel = lib.concatMapAttrs
136-
(s: kp: {
137-
"homa-microvm-${s}" = mkGuest { kernelPackages = kp; };
138-
"homa-microvm-test-${s}" = mkTest { kernelPackages = kp; label = "-${s}"; };
139-
})
140-
kernelConfig.vmMatrix;
152+
perKernel = lib.foldl' (a: b: a // b) { } (lib.imap1
153+
(i: s:
154+
let kp = kernelConfig.vmMatrix.${s}; in {
155+
"homa-microvm-${s}" = mkGuest { kernelPackages = kp; };
156+
"homa-microvm-test-${s}" = mkTest { kernelPackages = kp; label = "-${s}"; };
157+
"homa-lifecycle-${s}" = mkLifecycle { kernelPackages = kp; label = "-${s}"; index = i; };
158+
})
159+
vmSeries);
141160
in
142161
{
143162
packages = {
144163
homa-microvm = mkGuest { kernelPackages = defaultKp; };
145164
homa-microvm-debug = mkGuest { kernelPackages = defaultKp; withSanitizers = true; };
146165
homa-microvm-test = mkTest { kernelPackages = defaultKp; label = ""; };
166+
homa-lifecycle = mkLifecycle { kernelPackages = defaultKp; label = ""; index = 0; };
147167
homa-microvm-test-debug = mkTest {
148168
kernelPackages = defaultKp;
149169
label = "-debug";

0 commit comments

Comments
 (0)