virtio: console: clarify process_transmit_queue

Used tx buffers are returned to the driver with 0 bytes written by the
device. The current code makes it look like we return the number of
received bytes, even though this is not the case since
process_transmit_request always returns 0 for some reason.

Make this more clear by explicitly setting 0 bytes used, and making
process_transmit_request return nothing.

BUG=b:228912920
TEST=cargo build

Change-Id: I9094f7a43847d7e29d5390f274d6650ca5ec7c4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600164
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
Alexandre Courbot 2022-04-06 11:18:54 +09:00 committed by Chromeos LUCI
parent c29271e168
commit e8d53e8ee6

View file

@ -130,15 +130,12 @@ pub fn process_transmit_queue<I: SignalableInterrupt>(
}
};
let len = match process_transmit_request(reader, output) {
Ok(written) => written,
Err(e) => {
error!("console: process_transmit_request failed: {}", e);
0
}
};
match process_transmit_request(reader, output) {
Ok(()) => (),
Err(e) => error!("console: process_transmit_request failed: {}", e),
}
transmit_queue.add_used(mem, desc_index, len);
transmit_queue.add_used(mem, desc_index, 0);
needs_interrupt = true;
}
@ -223,13 +220,13 @@ pub fn spawn_input_thread(
///
/// * `reader` - The Reader with the data we want to write.
/// * `output` - The output sink we are going to write the data to.
pub fn process_transmit_request(mut reader: Reader, output: &mut dyn io::Write) -> io::Result<u32> {
pub fn process_transmit_request(mut reader: Reader, output: &mut dyn io::Write) -> io::Result<()> {
let len = reader.available_bytes();
let mut data = vec![0u8; len];
reader.read_exact(&mut data)?;
output.write_all(&data)?;
output.flush()?;
Ok(0)
Ok(())
}
impl Worker {