This repository was archived by the owner on May 22, 2026. It is now read-only.
Commit 21117ac
committed
macos: add signal shim for downstream rust-vmm crates
Adds macOS compatibility for the `signal` module so downstream rust-vmm
crates (`vhost`, `vhost-user-backend`, `virtiofsd`, …) can build and
run on macOS without code changes. All macOS code is gated behind
`#[cfg(target_os = "macos")]` and adds no new dependencies; Linux and
Android builds are unaffected. The crate stays at `BSD-3-Clause` and no
third-party code is vendored.
Host-signal validation uses `1..=SIGUSR2` because macOS signal numbers
do not match Linux's: SIGSYS=12, SIGTERM=15, SIGUSR2=31. The
`SIGHUP..=SIGSYS` range used on Linux would reject valid macOS signals.
Pending-signal clearing goes via unblock-then-reblock because macOS
does not expose `sigtimedwait`.
What this PR no longer ships, and why:
- No `eventfd` shim. The cross-platform `EventConsumer` /
`EventNotifier` primitive added in #244 already covers the daemon
side of `vhost-user-backend`. The remaining macOS callers of
`vmm_sys_util::eventfd::EventFd` are inside the `vhost` crate's
`VhostBackend` / `VhostBackendMut` traits, whose only consumers are
Linux-only (kernel vhost drivers, vhost-user frontends inside
Linux-only VMMs). A small follow-up PR to `vhost` gates those trait
methods on Linux, after which nothing in the macOS build path
references `vmm_sys_util::eventfd` and a shim is genuinely
unnecessary.
- No `epoll` shim. Consumers needing epoll-shaped polling on macOS
should use `mio` (see vhost #316), which gives proper cross-platform
event polling backed by `kqueue` on macOS — a cleaner architectural
answer than shimming the Linux API.
Tests:
- `macos::signal::tests` — validator range, register/block/unblock/kill
round-trips, pending-signal clearing.
Pre-existing failures in `rand` and `unix::tempdir` on macOS are out of
scope for this PR.
Signed-off-by: Chris Thomas <chris.thomas@antimatter-studios.com>1 parent 273e5d4 commit 21117ac
5 files changed
Lines changed: 420 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments