virtio-devices: net: Report correct used length on TX and ctrl

The virtio spec says the used-ring length is bytes the device wrote to
device writable descriptors. The net TX descriptors are device readable
only (the device wrote nothing back) so the length needs to be 0. On the
ctrl queue the number of bytes reported was wrongly the size of the
status descriptor not the number of bytes written (the descriptor is
permitted to be larger).

Signed-off-by: Rob Bradford <rbradford@meta.com>
This commit is contained in:
Rob Bradford
2026-04-18 11:13:57 +01:00
parent 305451cce4
commit 2a089db269
2 changed files with 10 additions and 9 deletions

View File

@@ -174,12 +174,10 @@ impl CtrlQueue {
.map_err(|e| Error::GuestMemory(GuestMemoryError::IOError(e)))?,
)
.map_err(Error::GuestMemory)?;
// Per virtio spec 2.6.8, used_len is the number of bytes written
// to device-writable descriptors. Only the status byte is written.
let len = status_desc.len();
// Per the virtio spec the used length is bytes the device wrote
// to device-writable descriptors; here just the 1-byte ack.
queue
.add_used(desc_chain.memory(), desc_chain.head_index(), len)
.add_used(desc_chain.memory(), desc_chain.head_index(), 1)
.map_err(Error::QueueAddUsed)?;
if !queue