summary refs log tree commit diff
path: root/kernel_loader
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-01-11 16:25:37 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-01-13 03:23:13 -0800
commit4adfdc03227a076b485d8b37fc8f227c08897696 (patch)
tree56291e9f77020b423e511bd6f36da00c4bb6f4b3 /kernel_loader
parentf3d39e2f1b8c21337f1a971a73e57013a31ff054 (diff)
downloadcrosvm-4adfdc03227a076b485d8b37fc8f227c08897696.tar
crosvm-4adfdc03227a076b485d8b37fc8f227c08897696.tar.gz
crosvm-4adfdc03227a076b485d8b37fc8f227c08897696.tar.bz2
crosvm-4adfdc03227a076b485d8b37fc8f227c08897696.tar.lz
crosvm-4adfdc03227a076b485d8b37fc8f227c08897696.tar.xz
crosvm-4adfdc03227a076b485d8b37fc8f227c08897696.tar.zst
crosvm-4adfdc03227a076b485d8b37fc8f227c08897696.zip
memory: Add methods to return error on short writes and reads
Add GuestMemory::write_all_at_addr, GuestMemory::read_exact_at_addr
which return error if the entire write or read cannot be completed.

Also rename write_slice_at_addr to write_at_addr, read_slice_at_addr to
read_at_addr to make the entire set of four methods consistent in naming
with the methods of std::io::Write and std::io::Read.

Context:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1387624/16/devices/src/virtio/tpm.rs#75

TEST=cargo test

Change-Id: Ia0775b75281ccf8030c84b41f9018a511204b8c9
Reviewed-on: https://chromium-review.googlesource.com/1407156
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'kernel_loader')
-rw-r--r--kernel_loader/src/lib.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel_loader/src/lib.rs b/kernel_loader/src/lib.rs
index 42b43de..13ada13 100644
--- a/kernel_loader/src/lib.rs
+++ b/kernel_loader/src/lib.rs
@@ -163,7 +163,7 @@ pub fn load_cmdline(
     }
 
     guest_mem
-        .write_slice_at_addr(cmdline.to_bytes_with_nul(), guest_addr)
+        .write_at_addr(cmdline.to_bytes_with_nul(), guest_addr)
         .map_err(|_| Error::CommandLineCopy)?;
 
     Ok(())