mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user