Skip to content

Add RawMessageProvider trait and expand SendError/ReceiveError variants#756

Open
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3f-raw-message
Open

Add RawMessageProvider trait and expand SendError/ReceiveError variants#756
wdcui wants to merge 1 commit intomainfrom
wdcui/pr3f-raw-message

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 7, 2026

Summary

  • Add RawMessageProvider trait for direct guest-host byte channels that bypass the IP stack. Default impl returns Err(Unavailable).
  • Add Provider supertrait bound + RawMessageProvider.
  • Expand SendError with Io(i32) and Unavailable variants; expand ReceiveError with ProtocolError and Eof variants. Update doc strings for shared usage across IPInterfaceProvider and RawMessageProvider.
  • Add stub impls in all platform crates (linux kernel, linux userland, LVBS, Windows userland) and the mock.

Split from #743.

Add SendError::Io(i32) and ReceiveError::{ProtocolError, Eof} variants.
Introduce RawMessageProvider trait for direct guest-broker byte-stream
messaging (bypassing IP stack), with default stubs. Add Provider
supertrait bound. Implement (empty defaults) for all platform crates.
Update net/phy.rs to match on new error variants.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 7, 2026

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure trait_added_supertrait: non-sealed trait added new supertraits ---

Description:
A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#generic-bounds-tighten
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.47.0/src/lints/trait_added_supertrait.ron

Failed in:
  trait litebox::platform::Provider gained RawMessageProvider in file /home/runner/work/litebox/litebox/litebox/src/platform/mod.rs:43

@jaybosamiya-ms jaybosamiya-ms added the expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment. label Apr 11, 2026
Copy link
Copy Markdown
Member

@jaybosamiya-ms jaybosamiya-ms left a comment

Choose a reason for hiding this comment

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

Currently, neither the implementations on the platform sides, nor the implementations on the shim sides of how this interface will be used have shown up. So it is a little hard to actually confirm if this is the right design. As a concrete alternative design, maybe IpInterfaceProvider should be changed to be a StreamProvider that has send/recv but takes an extra StreamType::IP or StreamType::Raw? I am not sure whether the current design or that design is the nicer one, and it is hard to tell without seeing more.

Nonetheless for this interface this cleanup can be done in the future too, so I don't see any particular reason to block it on figuring the above bits up.

I would like to see the nicer version of the i32 though, since that is unacceptable to merge, so currently marking it as "request changes" but it is quite close to an "approve" right now.

Comment on lines +390 to +392
/// The underlying device returned an I/O error. The packet was not sent.
#[error("I/O error on send: errno {0}")]
Io(i32),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As mentioned on #743, hardcoding an i32 here is wrong; pick actually relevant errors

Comment on lines +413 to +414
/// When available, this provides a fast path for protocols like 9P that would
/// otherwise pay the overhead of traversing two smoltcp stacks.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: "network stacks" not "smoltcp stacks". Doc strings should not promise unnecessary internal details.

Comment on lines +416 to +417
/// The default implementation returns [`ReceiveError::WouldBlock`] /
/// [`SendError::Unavailable`], indicating the channel is not available.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the default should be Unavailable for both, because otherwise a shim has no way to know if it tries to recv first whether it is just that something has not shown up (so it should try again) or whether it is never going to become available.

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

Labels

expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants