sync: pull cocoon v0.5.1 updates (idle-TAP softirq fix + dep bump) - #21
Merged
Conversation
Picks up shared-package fixes cocoon-macos gets for free: flock poll 100ms->2ms (#114), store Update fsyncs off the flock hold (#126), /proc-scan tolerance for vanishing pids (#129), per-NIC CNI teardown (#111). Adapts the two ReflinkCopy call sites to the new SyncMode arg (utils.Sync = preserve the prior fsync).
Port of cocoon #130. A stopped CNI VM keeps its netns/TAP for a fast restart, but the dead VMM leaves the TAP carrier-less while its veth stays up on the bridge; tc mirred redirect then fires against the down device per LAN broadcast, storming softirqs until the host soft-locks. Quiesce on stop and on rm (before Delete), Unquiesce on start, via the network provider. cocoon's bridge backend no-ops Quiesce, so --net tap|bridge additionally toggles the host TAP link directly.
--force maps to grace 0 (immediate SIGKILL), default to the ACPI grace window; mirrors cocoon f6ebebc which pinned the same mapping with a test.
…t to ip /simplify follow-up on the quiesce port: setTapLink flips the link with netlink.LinkSetUp/Down (already a dependency, promoted to direct) rather than exec-ing `ip link set` — it never enters a netns, so the fork-safety rationale that keeps launchCmd/ensureNetnsLoopback on `ip netns exec` does not apply, and it matches how cocoon toggles the same link. Gate on r.Netns (host vs netns TAP) instead of re-listing bridge-backed modes, and de-duplicate the idle-TAP softirq-storm rationale across teardownNet/quiesceNet/setTapLink.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the applicable changes from cocoon (now v0.5.1) into cocoon-macos.
Closes #19.
Included
1. Bump cocoon v0.4.6 → v0.5.1 (
f308eb0)Picks up shared-package fixes cocoon-macos gets for free through its imports: flock poll 100ms→2ms (#114), store
Updatefsyncs off the flock hold (#126),/proc-scan tolerance for pids that vanish mid-scan (#129), per-NIC CNI teardown (#111). Adapts the twoutils.ReflinkCopycall sites to its newSyncModearg (utils.Sync, preserving the prior fsync).2. Quiesce host NICs on stop/rm — port of cocoon #130 (
00e2c3e,4a2f113)A stopped CNI VM keeps its netns/TAP for a fast restart, but the dead VMM leaves the TAP carrier-less while its veth stays up on the bridge; tc mirred redirect then fires against the down device per LAN broadcast, storming softirqs until the host soft-locks — a host-crash landmine for any stopped or
rm'd CNI VM. NowQuiesceon stop and on rm (beforeDelete),Unquiesceon start.cocoon's bridge backend no-ops
Quiesce(bridge TAPs have no tc redirect), and QEMU opens the TAP withscript=noand never touches its link, so--net tap|bridgetoggles the host TAP directly vianetlink.LinkSetUp/Down(host netns only — a CNI TAP is the provider's job). netlink was already an indirect dependency, promoted to direct.Start ordering note (vs #19's proposed scope). #19 proposed unquiesce before launching QEMU and re-quiesce on launch failure. This PR unquiesces after a successful launch instead: unquiescing before QEMU opens the TAP would briefly recreate the exact carrier-less-TAP + veth-up condition the fix removes (a storm window on every start), whereas launching first means the TAP already has carrier when the veths come up, and a failed launch simply leaves the network quiesced (no rollback needed). Same end state (veths up iff the VM is running), without reopening the window.
3. Guard test for the stop/rm force→grace mapping (
e5bd110)Pins
--force→ immediate SIGKILL (grace 0), default → the ACPI grace window; mirrors cocoon f6ebebc.Assessed and skipped (already satisfied / not applicable)
--data-diskonly creates fresh qcow2s under the VM dir, so there is no external path to symlink-smuggle a managed root through.cmd/image/oci.goalready builds onutils.SplitRanges/utils.CopyRangeBody.Listreads records viaReadDir+loadRecwith no per-VM lock, andsaveRecis atomic (utils.AtomicWriteJSON), so lock-free reads are safe.Validation
go build,go vet, andgo testare green on bothGOOS=linuxandGOOS=darwin. Reviewed with a reuse/simplification/efficiency/altitude pass; the netlink swap and ther.Netnsgate onsetTapLinkcame out of it.