Skip to content

Commit

Permalink
bitmap/GuestMemory: fix false positive in read_from
Browse files Browse the repository at this point in the history
Before, if we didn't succeed to read all `len` bytes, we would've
marked as dirty more bytes than needed.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
  • Loading branch information
lauralt committed Jun 8, 2021
1 parent 5bd7138 commit a55d00e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/guest_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,16 @@ impl<T: GuestMemory> Bytes<GuestAddress> for T {
// record the dirty status of the written range below.
let start = caddr.raw_value() as usize;
let end = start + len;
let result = loop {
let bytes_read = loop {
match src.read(&mut dst[start..end]) {
Ok(n) => break Ok(n),
Ok(n) => break n,
Err(ref e) if e.kind() == std::io::ErrorKind::Interrupted => continue,
Err(e) => break Err(Error::IOError(e)),
Err(e) => return Err(Error::IOError(e)),
}
};

region.bitmap().mark_dirty(start, len);
result
region.bitmap().mark_dirty(start, bytes_read);
Ok(bytes_read)
} else {
let len = std::cmp::min(len, MAX_ACCESS_CHUNK);
let mut buf = vec![0u8; len].into_boxed_slice();
Expand Down

0 comments on commit a55d00e

Please sign in to comment.