Skip to content

hyperv_ic: implement SaveRestore for KVP & timesync - #4081

Merged
Steven Malis (smalis-msft) merged 4 commits into
microsoft:mainfrom
smalis-msft:ic-saverestore
Jul 29, 2026
Merged

hyperv_ic: implement SaveRestore for KVP & timesync#4081
Steven Malis (smalis-msft) merged 4 commits into
microsoft:mainfrom
smalis-msft:ic-saverestore

Conversation

@smalis-msft

@smalis-msft Steven Malis (smalis-msft) commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

We've discovered a Linux kernel bug that results in crashes when vmbus channels are rapidly offered and rescinded, a pattern we exercise in our vmm_tests. Work around this by implementing SaveRestore for the last two relevant devices that didn't already support it. Mimic Hyper-V's behavior by regenerating the devices on restore, rather than actually saving state.

A future change may make SaveRestore support non-optional, that's still under discussion.

This doesn't restabilize the broken tests yet, I'll let this bake for a bit first.

@smalis-msft
Steven Malis (smalis-msft) requested a review from a team as a code owner July 29, 2026 18:27
Copilot AI review requested due to automatic review settings July 29, 2026 18:27
@smalis-msft Steven Malis (smalis-msft) added the backport_1.8.2607 Change should be backported to the release/1.8.2607 branch label Jul 29, 2026

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.

Pull request overview

Implements save/restore support for the Hyper-V IC KVP and timesync devices so they can be restored without revoking/reoffering their VMBus channels, working around a Linux kernel crash triggered by rapid offer/rescind patterns.

Changes:

  • Add saved-state wire types for negotiated IC versions (SavedVersions) and per-device channel state.
  • Enable supports_save_restore() for TimesyncIc and KvpIc, with corresponding save_open / restore_open implementations.
  • On restore, handle in-flight states safely (e.g., timesync resends a sync message; KVP drains an outstanding response before accepting new requests).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
vm/devices/hyperv_ic/src/timesync.rs Adds save/restore state capture and restore behavior for timesync channel state machine.
vm/devices/hyperv_ic/src/kvp.rs Adds save/restore for KVP channel state machine, including response-drain handling after restore.
vm/devices/hyperv_ic/src/common.rs Introduces SavedVersions and conversions to serialize negotiated version pairs in saved state.

Copilot AI review requested due to automatic review settings July 29, 2026 20:06

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 29, 2026 20:13

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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

vm/devices/hyperv_ic/src/common.rs:196

  • test_with_tracing::test is a sync-only attribute macro (it rejects async fns) and it’s not used here (tests use #[async_test]). This import will be unused and the dev-dependency becomes unnecessary unless you explicitly call test_with_tracing::init() in the async tests.
    use pal_async::async_test;
    use test_with_tracing::test;
    use vmbus_channel::connected_async_channels;

vm/devices/hyperv_ic/Cargo.toml:38

  • test_with_tracing is only referenced via an unused import in src/common.rs tests. Once that import is removed, this dev-dependency should be dropped to avoid unnecessary workspace churn (and it will likely get removed by fmt anyway).
[dev-dependencies]
test_with_tracing.workspace = true

@smalis-msft
Steven Malis (smalis-msft) enabled auto-merge (squash) July 29, 2026 20:24
Copilot AI review requested due to automatic review settings July 29, 2026 21:26

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.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

vm/devices/hyperv_ic/src/common.rs:109

  • During version negotiation you currently ignore the response status returned by read_message (_status). If the guest reports a failure status for the VERSION_NEGOTIATION transaction, we should treat negotiation as failed instead of proceeding to parse the body as if it succeeded.
                    let (message_type, _status, buf) = self.read_message().await?;

@smalis-msft
Steven Malis (smalis-msft) merged commit 788419a into microsoft:main Jul 29, 2026
69 checks passed
@smalis-msft
Steven Malis (smalis-msft) deleted the ic-saverestore branch July 29, 2026 23:00
@smalis-msft Steven Malis (smalis-msft) removed the backport_1.8.2607 Change should be backported to the release/1.8.2607 branch label Jul 31, 2026
Steven Malis (smalis-msft) added a commit that referenced this pull request Aug 4, 2026
Backport of #4081 to `release/1.8.2607`.

The cherry-pick of 788419a applied cleanly onto `release/1.8.2607`
with no conflicts and no manual edits.

Original PR: #4081

---
*This backport PR was created by an AI agent (GitHub Copilot) on behalf
of @smalis-msft.*
@benhillis

Copy link
Copy Markdown
Member

Backported to release/1.8.2607 in #4127

@benhillis Ben Hillis (benhillis) added the backported_1.8.2607 PR that has been backported to release/1.8.2607 label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported_1.8.2607 PR that has been backported to release/1.8.2607

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants