mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-11-04 19:11:11 +00:00
virtio-devices: rng: correctly indicate number of bytes written
Reads from the random file may only be partial, e.g., if the random file is an ordinary text file. When that happens, the device needs to signal to the driver that only parts of the buffer have been overwritten. Signed-off-by: Markus Napierkowski <markus.napierkowski@cyberus-technology.de>
This commit is contained in:
parent
31dfe3d02a
commit
b49f8b9248
@ -58,17 +58,13 @@ impl RngEpollHandler {
|
|||||||
// Drivers can only read from the random device.
|
// Drivers can only read from the random device.
|
||||||
if desc.is_write_only() {
|
if desc.is_write_only() {
|
||||||
// Fill the read with data from the random device on the host.
|
// Fill the read with data from the random device on the host.
|
||||||
if desc_chain
|
if let Ok(number_of_bytes) = desc_chain.memory().read_from(
|
||||||
.memory()
|
desc.addr()
|
||||||
.read_from(
|
.translate_gva(self.access_platform.as_ref(), desc.len() as usize),
|
||||||
desc.addr()
|
&mut self.random_file,
|
||||||
.translate_gva(self.access_platform.as_ref(), desc.len() as usize),
|
desc.len() as usize,
|
||||||
&mut self.random_file,
|
) {
|
||||||
desc.len() as usize,
|
len = number_of_bytes as u32;
|
||||||
)
|
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
len = desc.len();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user