← Back to Pull requests

pkg/driver/qemu: eliminate race condition and send on closed channel in qWaitCh #5856

Closed
unknown closed this pull request without merging on Nov 26, 2026 00:20 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 11:30 UTC
Author

What This PR Changes

In LimaQemuDriver.Start, two goroutines concurrently wrote to l.qWaitCh (the qCmd.Wait() goroutine that closed l.qWaitCh and the usernet ConfigureDriver goroutine). An early QEMU exit closed l.qWaitCh while the usernet goroutine could still send on it (panic: send on closed channel), or vice versa.

This PR coordinates qWaitErrCh and usernetErrCh through a single coordinateQEMUWait goroutine that cancels, joins errors, and closes l.qWaitCh, and adds TestCoordinateQEMUWaitNoRaceOrPanic in pkg/driver/qemu/qemu_test.go.

Linked Issue (Required in most cases)

N/A

How I Tested This

Environment: Linux Mint 22.3 (Linux 7.0.0-43-generic, x86_64), QEMU 8.2.2, Go 1.26.4 (go1.26.11), golangci-lint 2.15.0, commit a263af26 vs base 1c12d399:

make ltag && make limactl native-guestagent
CGO_ENABLED=1 go build -race -o _output/bin/limactl-race ./cmd/limactl
go test -race -count=10 ./pkg/driver/qemu/...
golangci-lint run ./pkg/driver/qemu/...

# Normal QEMU lifecycle with race detector:
limactl-race start --tty=false --vm-type=qemu --mount-type=9p --containerd=none template:default  # exit 0
limactl-race stop default  # exit 0, zero race/panic in ha.stderr.log

# Early QEMU exit alongside `networks: [{lima: user-v2}]`:
# Base 1c12d399: `WARNING: DATA RACE` + `panic: send on closed channel` (`host agent process has exited: exit status 2`)
# PR a263af26: zero race/panic, clean exit 1 (`QEMU has already exited`)

<img width="914" height="274" alt="pr5856_before_after" src="https://github.com/user-attachments/assets/a1f9d4aa-aa43-4ddf-be48-5e78b29ad54c" />

Not tested locally: macOS QEMU / Windows QEMU host runs.

AI Usage

Assisted-by: Antigravity

Diff: 218 lines (+163 / -55) across 2 files Reviewer: AkihiroSuda Review duration: 2209m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 218 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.322
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5856"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.7% (MEDIUM) · Higher = larger blast radius
36.7%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.5% · Safe to merge
14.5%
Repository