virtio-devices: console: Use 0 as the 'len' for the transmit queue

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 <avagin@google.com>
This commit is contained in:
Andrei Vagin
2026-03-07 01:24:32 +00:00
committed by Wei Liu
parent 9f569c7b8d
commit 49156c720c

View File

@@ -265,7 +265,7 @@ impl ConsoleEpollHandler {
out.flush().map_err(Error::OutputFlush)?;
}
trans_queue
.add_used(desc_chain.memory(), desc_chain.head_index(), desc.len())
.add_used(desc_chain.memory(), desc_chain.head_index(), 0)
.map_err(Error::QueueAddUsed)?;
used_descs = true;
}