Skip to content

[RFC] virtio-vsock: Introduce Reader/Writer support#392

Open
luigix25 wants to merge 6 commits into
rust-vmm:mainfrom
luigix25:fix_vsock
Open

[RFC] virtio-vsock: Introduce Reader/Writer support#392
luigix25 wants to merge 6 commits into
rust-vmm:mainfrom
luigix25:fix_vsock

Conversation

@luigix25
Copy link
Copy Markdown

@luigix25 luigix25 commented Mar 31, 2026

Summary of the PR

Linux can use more than 2 descriptor in a chain for a vsock packet and this crate does not handle it.
To fix it I'm using Reader/Writer helpers from the virtio-queue crate. This needs major (and breaking) changes.

I'm splitting the VsockPacket in Rx and Tx, because in the first one I need writers while in the second Readers.

I had to delete some tests because they no longer apply.

Since this PR involves major changes in the virtio-vsock crate I'd like some general feedback about the new architecture.

Fuzzing has not been modified yet, this is why CI it's failing. It requires massive changes and I'd like to get some feedback around the architecture first.

Fixes: #216

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@luigix25
Copy link
Copy Markdown
Author

luigix25 commented Mar 31, 2026

TODO:

  • Fix fuzzing
  • Improve commit messages

Add getter/setter methods directly on PacketHeader. This is preliminary
work for new APIs that will be introduced in a following commit.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
@luigix25 luigix25 force-pushed the fix_vsock branch 2 times, most recently from 247b503 to 15d7372 Compare May 20, 2026 10:23
@luigix25
Copy link
Copy Markdown
Author

luigix25 commented May 20, 2026

  • Restored old VsockPacket struct and marked it as deprecated.
  • Moved shared definitions between VsockPacket and VsockPacketRx/Tx to a common file
  • Fixed various clippy and cargo fmt problems.

TODO:

  • Add fuzzing for new VsockPacketRx/Tx

@luigix25
Copy link
Copy Markdown
Author

mmh not sure why fuzzing is failing. It's untouched.

@stefano-garzarella
Copy link
Copy Markdown
Member

mmh not sure why fuzzing is failing. It's untouched.

Is seemed more infra issue, restarting helped.

Copy link
Copy Markdown
Member

@epilys epilys left a comment

Choose a reason for hiding this comment

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

LGTM in general, will need to take another deep look once I have more time

Comment thread virtio-vsock/src/lib.rs Outdated
Comment thread virtio-vsock/src/packet_rw.rs Outdated
Comment thread virtio-vsock/src/packet_rw.rs Outdated
Comment thread virtio-vsock/src/packet_rw.rs Outdated
Comment thread virtio-vsock/src/packet_rw.rs Outdated
Comment thread virtio-vsock/src/packet_rw.rs
@luigix25
Copy link
Copy Markdown
Author

[@epilys]

  • Squashed commit
  • Fixed links and improved doc
  • dropped defs module. Moved everything to lib.rs

luigix25 added 5 commits May 25, 2026 17:15
Move PacketHeader, Error, Result, and PKT_HEADER_SIZE from the packet
module into lib.rs so they can be shared across the crate without
circular dependencies.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Add VsockPacketTx and VsockPacketRx in the new packet_rw module. These
use virtio_queue's Reader/Writer abstractions instead of raw VolatileSlice,
providing a cleaner and safer API for vsock packet handling.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Mark VsockPacket as deprecated in favor of the new VsockPacketTx/VsockPacketRx
API introduced earlier.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vsock: make the descriptor chain parsing more generic

3 participants