Skip to content

feat(virtq): use Rc pointer equality instead if generation for pools - #1945

Open
andreiltd wants to merge 1 commit into
hyperlight-dev:mainfrom
andreiltd:virtq-pool-inst
Open

andreiltd wants to merge 1 commit into
hyperlight-dev:mainfrom
andreiltd:virtq-pool-inst

Conversation

@andreiltd

Copy link
Copy Markdown
Member

Instead of threading generation through pools it's actually simpler to use Rc::ptr_eq to check if pool belongs to current snapshot generation and swap pools on restore.

Instead of threading generation through pools it's actually simpler to
use Rc::ptr_eq to check if pool belongs to current snapshot generation
and swap pools on restore.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 12:10
@andreiltd andreiltd added the kind/refactor For PRs that restructure or remove code without adding new functionality. label Oct 16, 2026
@andreiltd andreiltd changed the title feat(virtq): use Rc pointer equality instead generation for pools feat(virtq): use Rc pointer equality instead if generation for pools Oct 16, 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.

🟡 Changes recommended

Reservation validation rejects every nonempty pool swap, causing restore failures with retained buffers and posted chains.

1 open finding
What changed in this PR

This PR uses shared pool identity to track virtqueue allocation ownership across snapshot restores.

Changes:

  • Replace pool generation counters with Rc pointer identity and pool swaps.
  • Keep retained leases tied to their original pools.
  • Expand swap tests and update transport documentation.
File Description
src/​hyperlight_host/​tests/​integration_test.rs Rename the retained-buffer test.
src/​hyperlight_guest/​src/​transport/​context.rs Clarify pool ownership and restore safety comments.
src/​hyperlight_guest/​src/​transport/​backing.rs Update alias allocator terminology.
src/​hyperlight_common/​src/​virtq/​producer.rs Swap pools while preserving posted chains.
src/​hyperlight_common/​src/​virtq/​pool/​tests.rs Test swap reservations, ordering, and validation.
src/​hyperlight_common/​src/​virtq/​pool/​slot.rs Implement pool identity and replacement allocation state.
src/​hyperlight_common/​src/​virtq/​buffer.rs Return leases to their original pools.
docs/​virtio-host-guest-communication.md Document pool swaps and retained ownership.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +386 to +396
for addr in reserved {
if let Some(lower) = &mut inner.lower
&& lower.contains(addr)
{
lower.allocation_len(addr)?;
lower.reserve_addr(addr)?;
} else {
inner.upper.allocation_len(addr)?;
inner.upper.reserve_addr(addr)?;
}
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/refactor For PRs that restructure or remove code without adding new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants