Skip to content

sidecar_client: leave VP stopped when the driver rejects a start - #5237

Merged
Sunil Muthuswamy (sunilmut) merged 1 commit into
microsoft:mainfrom
sunilmut:user/sunilmut/sidecar-start-rollback-repro
Nov 25, 2026
Merged

Sunil Muthuswamy (sunilmut) merged 1 commit into
microsoft:mainfrom
sunilmut:user/sunilmut/sidecar-start-rollback-repro

Conversation

@sunilmut

Copy link
Copy Markdown
Member

start_async marked the VP running before the start ioctl and left it that
way if the ioctl failed. The sidecar driver rejects a start in
sidecar_claim before starting the CPU, so no completion ever arrives: a
later run panicked on the "stopped" assertion and a wait would hang. The
VP state is shared, so re-acquiring the VP accessor did not reset it.

This change returns the VP to stopped when the start fails. It is still marked
running before the ioctl, because a completion can arrive as soon as the CPU
starts.

To make this unit-testable, the state transition moves unchanged into
SidecarClientState::start_vp, which start_async calls with the same ioctl.

Test changes (the crate's first unit tests):

  • A rejected run through the real ioctl (/dev/null returns ENOTTY) leaves
    the VP stopped and reusable with a re-acquired accessor (failed before).
  • A rejected start leaves the VP stopped and can be retried (failed before).
  • The VP is marked running while the start request is issued.

start_async marked the VP running before the start ioctl and left it
that way if the ioctl failed. The sidecar driver rejects a start before
starting the CPU, so no completion ever arrived: a later run panicked on
the "stopped" assertion and a wait would hang. Return the VP to stopped
when the start fails.

Move the state transition into SidecarClientState::start_vp so it can
be unit tested without the sidecar driver.

Test changes:
- Add the crate's first unit tests.
- Verify a rejected run through the real ioctl leaves the VP reusable.
- Verify a rejected start leaves the VP stopped and can be retried.
- Verify the VP is marked running before the start request is issued.
@sunilmut
Sunil Muthuswamy (sunilmut) requested a review from a team as a code owner November 23, 2026 00:35
Copilot AI balanced review requested due to automatic review settings November 23, 2026 00:35
@github-actions github-actions Bot added the unsafe Related to unsafe code label Nov 23, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Rollback safety depends on failed start ioctls leaving the CPU unstarted with no completion possible, a contract requiring human confirmation because the driver is absent and /dev/null tests cannot validate it.

No open issues 🎉

What changed in this PR

This PR fixes sidecar VP state handling so a rejected start leaves the VP stopped and reusable, rather than causing a later run to panic or a wait to hang.

Changes:

  • Extracts the start transition into SidecarClientState::start_vp, restoring the stopped state on failure while preserving running-before-start ordering.
  • Adds regression tests for rejected starts, accessor reuse, and state ordering.
  • Adds the Linux test tracing dependency.
File Description
openhcl/​sidecar_client/​src/​lib.rs Fixes failed-start state recovery and adds regression tests.
openhcl/​sidecar_client/​Cargo.toml Adds test_with_tracing as a Linux development dependency.
Cargo.lock Records the new test dependency for sidecar_client.

Review effort: Balanced

@sunilmut
Sunil Muthuswamy (sunilmut) merged commit bfaed88 into microsoft:main Nov 25, 2026
108 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants