← Back to Pull requests

pkg/driver/qemu: use fresh help buffers per command in inspectFeatures #5886

Closed
unknown closed this pull request without merging on Nov 27, 2026 10:18 UTC
View on GitHub
unknown unknown commented on Nov 26, 2026 10:41 UTC
Author

What This PR Changes

Allocate fresh stdout and stderr buffers per command via a small inspectHelp helper in pkg/driver/qemu/qemu.go:

  • Prevents -accel help, -netdev help, -machine help, and -cpu help outputs from accumulating or overwriting prior slices via bytes.Buffer.Bytes() backing-array reuse.

  • Preserves stderr fallback when an earlier command wrote to stdout.

  • Wraps failed command errors with %w so logrus.Warn reports only that command's own stdout/stderr.
  • Adds TestInspectFeatures unit tests in pkg/driver/qemu/qemu_test.go.

    Linked Issue (Required in most cases)

    N/A (isolated bug fix in pkg/driver/qemu/qemu.go with unit tests; no existing issue).

    How I Tested This

    Unit tests, cross-compile test builds, linters, and build on Linux Mint 22.3 (x86_64, QEMU 8.2.2):

    go test -v -race ./pkg/driver/qemu/...
    GOOS=windows go test -c -o /dev/null ./pkg/driver/qemu
    GOOS=darwin CGO_ENABLED=0 go test -c -o /dev/null ./pkg/driver/qemu
    go run -modfile=./hack/tools/go.mod github.com/golangci/golangci-lint/v2/cmd/golangci-lint run ./pkg/driver/qemu/...
    make editorconfig-checker nobin ltag
    make native
    

  • Without the fix on 3268d9b3, TestInspectFeatures fails because NetdevHelp/CPUHelp contain prior commands' output and stderr fallback is masked. With the fix, all tests and linters pass (0 issues).
  • Real limactl verification (vmOpts.qemu.cpuType.x86_64: vhost-user — a -netdev help string):

  • Before (3268d9b3): passed Lima's CPUHelp check and launched QEMU (qemu-system-x86_64: unable to find CPU model 'vhost-user').

  • After: rejected cleanly in qemu.Cmdline before launching QEMU (ha.stderr.log: `cpu vhost-user is not supported by /usr/bin/qemu-system-x86_64`).
  • AI Usage

    Assisted-by: Gemini

    Diff: 225 lines (+168 / -57) across 2 files Reviewer: AkihiroSuda Review duration: 1416m
    All Vouch review confidence checks passed
    Residual risk 0.15 = 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 · 225 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.324
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5886"
    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.9% (MEDIUM) · Higher = larger blast radius
    36.9%
    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.6% · Safe to merge
    14.6%
    Repository