Thanks to visit codestin.com
Credit goes to github.com

Skip to content

virtio-devices: console: Fix descriptor chain processing - #7802

Merged
liuw merged 3 commits into
cloud-hypervisor:mainfrom
avagin:console-resize
Mar 9, 2026
Merged

liuw merged 3 commits into
cloud-hypervisor:mainfrom
avagin:console-resize

Conversation

@avagin

@avagin avagin commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Both process_input_queue and process_output_queue were only processing the first descriptor of a chain, leading to data loss if the driver used chained descriptors.

This change iterates through all descriptors in a chain. It also fixes the len field in the used ring for the transmit queue to be 0, as required by the virtio specification ((e.g., Section 2.6.8 in virtio 1.1).

@avagin
avagin requested a review from a team as a code owner March 6, 2026 19:25

@rbradford rbradford left a comment

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.

Fabulous, thanks!

Comment thread virtio-devices/src/console.rs Outdated
@rbradford
rbradford enabled auto-merge March 6, 2026 20:10
auto-merge was automatically disabled March 6, 2026 21:10

Head branch was pushed to by a user without write access

@avagin

avagin commented Mar 6, 2026

Copy link
Copy Markdown
Contributor Author

I have removed the unused DescriptorChainTooShort. This should fix ci failures.

@likebreath likebreath left a comment

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.

Thanks for the contribution! This is a good fix. I have left a couple of minor suggestions below.

Gentle reminder: As a first-time contributor, please take a moment to review our contribution guidelines.

Also, this inspired me to audit our other virtio devices for similar issues. I've opened a tracking issue here: #7803.

Comment thread virtio-devices/src/console.rs
Comment thread virtio-devices/src/console.rs Outdated
avagin added 3 commits March 7, 2026 16:40
The update_console_size method was using fetch_and on the acked_features
atomic, which modified the atomic and cleared other feature bits.
Changed it to use a non-destructive load and bitwise AND.

Signed-off-by: Andrei Vagin <[email protected]>
For a transmit queue (guest to host), the host only reads from the
guest-provided buffers and does not write to them. According to the
virtio specification (e.g., Section 2.6.8 in Virtio 1.1), the 'len'
field in the used ring has to be set to the number of bytes written to
the buffers. Therefore, it should be 0 for the console transmit queue.

Signed-off-by: Andrei Vagin <[email protected]>
Both process_input_queue and process_output_queue were only processing
the first descriptor of a chain, leading to data loss if the driver used
chained descriptors.

This change iterates through all descriptors in a chain. It also moves
the flush call out of the descriptor loops to improve performance.

Signed-off-by: Andrei Vagin <[email protected]>
@rbradford
rbradford enabled auto-merge March 8, 2026 10:27
@rbradford
rbradford added this pull request to the merge queue Mar 8, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 8, 2026
@liuw
liuw added this pull request to the merge queue Mar 9, 2026
Merged via the queue into cloud-hypervisor:main with commit 2698cfe Mar 9, 2026
37 checks passed
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants