Skip to content

feat(virtq): add packed virtio ring primitives#1382

Merged
andreiltd merged 10 commits into
hyperlight-dev:mainfrom
andreiltd:tandr/virtq-1-ring
May 11, 2026
Merged

feat(virtq): add packed virtio ring primitives#1382
andreiltd merged 10 commits into
hyperlight-dev:mainfrom
andreiltd:tandr/virtq-1-ring

Conversation

@andreiltd
Copy link
Copy Markdown
Member

@andreiltd andreiltd commented Apr 16, 2026

Add low-level packed virtqueue ring implementation in hyperlight_common::virtq, based on the virtio packed ring format.

This is split from: #1368 and does not include any actual plumbing for guest/host communication.

Useful materials:

@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch from 3db3820 to bd2fd96 Compare April 16, 2026 10:20
@andreiltd andreiltd added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Apr 16, 2026
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch 2 times, most recently from b4c8142 to 16de50c Compare April 16, 2026 10:30
Copy link
Copy Markdown
Contributor

@dblnz dblnz left a comment

Choose a reason for hiding this comment

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

Great stuff, @andreiltd !
I left a few comments, most are small remarks, others are things I might have missed.
This is part 1 of my review, I still have some things left to look at that I plan on doing tomorrow.

Comment thread src/hyperlight_common/src/virtq/access.rs Outdated
Comment thread src/hyperlight_common/src/virtq/access.rs Outdated
Comment thread src/hyperlight_common/src/virtq/desc.rs Outdated
Comment thread src/hyperlight_common/src/virtq/desc.rs Outdated
Comment thread src/hyperlight_common/src/virtq/desc.rs Outdated
Comment thread src/hyperlight_common/src/virtq/event.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch 4 times, most recently from 857f4bf to 2c6adcb Compare April 22, 2026 13:09
Comment thread src/hyperlight_common/src/virtq/access.rs
Comment thread src/hyperlight_common/src/virtq/access.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch 3 times, most recently from 79ee809 to 141fc6b Compare April 27, 2026 12:32
Comment thread src/hyperlight_common/src/virtq/ring.rs
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch from 141fc6b to e27dacb Compare April 27, 2026 14:06
ludfjig
ludfjig previously approved these changes May 5, 2026
Copy link
Copy Markdown
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

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

This PR is very clean, big fan!

I know we don't really have policy on asserts vs errors etc in hyperlight (I personally like asserts...), but ring.rs has 3 debug_assert! that could be useful in release mode as well, and they're already in methods that return Results. Do you think it makes sense to convert them to errros instead?

Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/mod.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/desc.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Copy link
Copy Markdown
Member

@simongdavies simongdavies left a comment

Choose a reason for hiding this comment

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

Great stuff a few minor comments but looks good to me

Comment thread src/hyperlight_common/src/virtq/access.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/desc.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs Outdated
Comment thread src/hyperlight_common/src/virtq/event.rs
@andreiltd andreiltd requested a review from jsturtevant as a code owner May 6, 2026 12:28
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch 2 times, most recently from c384e6f to 6541fea Compare May 7, 2026 08:41
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch from 6541fea to 519472d Compare May 7, 2026 08:55
ludfjig
ludfjig previously approved these changes May 8, 2026
Copy link
Copy Markdown
Contributor

@ludfjig ludfjig left a comment

Choose a reason for hiding this comment

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

LGTM, not sure if you saw this comment but not blocking

I know we don't really have policy on asserts vs errors etc in hyperlight (I personally like asserts...), but ring.rs has 3 debug_assert! that could be useful in release mode as well, and they're already in methods that return Results. Do you think it makes sense to convert them to errros instead?

danbugs
danbugs previously approved these changes May 8, 2026
Copy link
Copy Markdown
Contributor

@danbugs danbugs left a comment

Choose a reason for hiding this comment

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

Only minor NITs. Really great work, @andreiltd !

Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs
Comment thread src/hyperlight_common/src/virtq/ring.rs
@andreiltd andreiltd dismissed stale reviews from danbugs and ludfjig via 657da05 May 11, 2026 10:12
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch from 657da05 to 032ac0b Compare May 11, 2026 10:13
@andreiltd
Copy link
Copy Markdown
Member Author

andreiltd commented May 11, 2026

LGTM, not sure if you saw this comment but not blocking

I know we don't really have policy on asserts vs errors etc in hyperlight (I personally like asserts...), but ring.rs has 3 debug_assert! that could be useful in release mode as well, and they're already in methods that return Results. Do you think it makes sense to convert them to errros instead?

Hey @ludfjig, sorry - there were few back and forth with usage of asserts so I thought I already addressed that - we had CI checks that banned usage of assert macro at some point but that has been now relaxed. I converted the asserts in question into invalid state errors - I think it makes sense for dealing with malicious driver. Thanks for pointing that out!

032ac0b

Copy link
Copy Markdown
Contributor

@dblnz dblnz left a comment

Choose a reason for hiding this comment

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

Great work! I have nothing else to add.

@andreiltd andreiltd enabled auto-merge (squash) May 11, 2026 19:36
andreiltd added 10 commits May 11, 2026 21:39
Add low-level packed virtqueue ring implementation in
hyperlight_common::virtq, based on the virtio packed ring format.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
@andreiltd andreiltd force-pushed the tandr/virtq-1-ring branch from 032ac0b to 130bb27 Compare May 11, 2026 19:40
@andreiltd andreiltd merged commit cee5ccd into hyperlight-dev:main May 11, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants