mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
Fix VolatileSlice calls in all modules
The VolatileSlice API changed, but some callers were not updated to match. Fix them up so that builds with additional features enabled (e.g. kokoro) pass again. BUG=None TEST=cargo test -p disk --features=composite-disk TEST=docker/wrapped_smoke_test.sh Change-Id: I97b3cd04549af30b7dc1515245f025d9439669bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216399 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
f0fa242b92
commit
ddd8180a13
3 changed files with 14 additions and 15 deletions
|
@ -16,7 +16,6 @@ use std::panic;
|
|||
use std::rc::Rc;
|
||||
use std::usize;
|
||||
|
||||
use data_model::*;
|
||||
use gpu_display::*;
|
||||
use gpu_renderer::RendererFlags;
|
||||
use resources::Alloc;
|
||||
|
@ -467,7 +466,7 @@ impl Backend for VirtioGfxStreamBackend {
|
|||
let mut backing_iovecs: Vec<iovec> = Vec::new();
|
||||
|
||||
for (addr, len) in vecs {
|
||||
let slice = mem.get_slice(addr.offset(), len as u64).unwrap();
|
||||
let slice = mem.get_slice_at_addr(addr, len).unwrap();
|
||||
backing_iovecs.push(iovec {
|
||||
iov_base: slice.as_ptr() as *mut c_void,
|
||||
iov_len: len as usize,
|
||||
|
|
|
@ -246,10 +246,10 @@ impl FileReadWriteAtVolatile for CompositeDiskFile {
|
|||
fn read_at_volatile(&mut self, slice: VolatileSlice, offset: u64) -> io::Result<usize> {
|
||||
let cursor_location = offset;
|
||||
let disk = self.disk_at_offset(cursor_location)?;
|
||||
let subslice = if cursor_location + slice.size() > disk.offset + disk.length {
|
||||
let subslice = if cursor_location + slice.size() as u64 > disk.offset + disk.length {
|
||||
let new_size = disk.offset + disk.length - cursor_location;
|
||||
slice
|
||||
.sub_slice(0, new_size)
|
||||
.sub_slice(0, new_size as usize)
|
||||
.map_err(|e| io::Error::new(ErrorKind::InvalidData, format!("{:?}", e)))?
|
||||
} else {
|
||||
slice
|
||||
|
@ -260,10 +260,10 @@ impl FileReadWriteAtVolatile for CompositeDiskFile {
|
|||
fn write_at_volatile(&mut self, slice: VolatileSlice, offset: u64) -> io::Result<usize> {
|
||||
let cursor_location = offset;
|
||||
let disk = self.disk_at_offset(cursor_location)?;
|
||||
let subslice = if cursor_location + slice.size() > disk.offset + disk.length {
|
||||
let subslice = if cursor_location + slice.size() as u64 > disk.offset + disk.length {
|
||||
let new_size = disk.offset + disk.length - cursor_location;
|
||||
slice
|
||||
.sub_slice(0, new_size)
|
||||
.sub_slice(0, new_size as usize)
|
||||
.map_err(|e| io::Error::new(ErrorKind::InvalidData, format!("{:?}", e)))?
|
||||
} else {
|
||||
slice
|
||||
|
@ -392,12 +392,12 @@ mod tests {
|
|||
};
|
||||
let mut composite = CompositeDiskFile::new(vec![disk_part]).unwrap();
|
||||
let mut input_memory = [55u8; 5];
|
||||
let input_volatile_memory = &mut input_memory[..];
|
||||
let input_volatile_memory = VolatileSlice::new(&mut input_memory[..]);
|
||||
composite
|
||||
.write_all_at_volatile(input_volatile_memory.get_slice(0, 5).unwrap(), 0)
|
||||
.unwrap();
|
||||
let mut output_memory = [0u8; 5];
|
||||
let output_volatile_memory = &mut output_memory[..];
|
||||
let output_volatile_memory = VolatileSlice::new(&mut output_memory[..]);
|
||||
composite
|
||||
.read_exact_at_volatile(output_volatile_memory.get_slice(0, 5).unwrap(), 0)
|
||||
.unwrap();
|
||||
|
@ -455,12 +455,12 @@ mod tests {
|
|||
let mut composite =
|
||||
CompositeDiskFile::new(vec![disk_part1, disk_part2, disk_part3]).unwrap();
|
||||
let mut input_memory = [55u8; 200];
|
||||
let input_volatile_memory = &mut input_memory[..];
|
||||
let input_volatile_memory = VolatileSlice::new(&mut input_memory[..]);
|
||||
composite
|
||||
.write_all_at_volatile(input_volatile_memory.get_slice(0, 200).unwrap(), 50)
|
||||
.unwrap();
|
||||
let mut output_memory = [0u8; 200];
|
||||
let output_volatile_memory = &mut output_memory[..];
|
||||
let output_volatile_memory = VolatileSlice::new(&mut output_memory[..]);
|
||||
composite
|
||||
.read_exact_at_volatile(output_volatile_memory.get_slice(0, 200).unwrap(), 50)
|
||||
.unwrap();
|
||||
|
@ -490,13 +490,13 @@ mod tests {
|
|||
let mut composite =
|
||||
CompositeDiskFile::new(vec![disk_part1, disk_part2, disk_part3]).unwrap();
|
||||
let mut input_memory = [55u8; 300];
|
||||
let input_volatile_memory = &mut input_memory[..];
|
||||
let input_volatile_memory = VolatileSlice::new(&mut input_memory[..]);
|
||||
composite
|
||||
.write_all_at_volatile(input_volatile_memory.get_slice(0, 300).unwrap(), 0)
|
||||
.unwrap();
|
||||
composite.punch_hole(50, 200).unwrap();
|
||||
let mut output_memory = [0u8; 300];
|
||||
let output_volatile_memory = &mut output_memory[..];
|
||||
let output_volatile_memory = VolatileSlice::new(&mut output_memory[..]);
|
||||
composite
|
||||
.read_exact_at_volatile(output_volatile_memory.get_slice(0, 300).unwrap(), 0)
|
||||
.unwrap();
|
||||
|
@ -530,7 +530,7 @@ mod tests {
|
|||
let mut composite =
|
||||
CompositeDiskFile::new(vec![disk_part1, disk_part2, disk_part3]).unwrap();
|
||||
let mut input_memory = [55u8; 300];
|
||||
let input_volatile_memory = &mut input_memory[..];
|
||||
let input_volatile_memory = VolatileSlice::new(&mut input_memory[..]);
|
||||
composite
|
||||
.write_all_at_volatile(input_volatile_memory.get_slice(0, 300).unwrap(), 0)
|
||||
.unwrap();
|
||||
|
@ -541,7 +541,7 @@ mod tests {
|
|||
.unwrap();
|
||||
}
|
||||
let mut output_memory = [0u8; 300];
|
||||
let output_volatile_memory = &mut output_memory[..];
|
||||
let output_volatile_memory = VolatileSlice::new(&mut output_memory[..]);
|
||||
composite
|
||||
.read_exact_at_volatile(output_volatile_memory.get_slice(0, 300).unwrap(), 0)
|
||||
.unwrap();
|
||||
|
|
|
@ -202,7 +202,7 @@ impl Drop for Buffer {
|
|||
|
||||
impl Buffer {
|
||||
fn as_volatile_slice(&self) -> VolatileSlice {
|
||||
unsafe { VolatileSlice::new(self.segment_info.shmaddr as *mut _, self.size as u64) }
|
||||
unsafe { VolatileSlice::from_raw_parts(self.segment_info.shmaddr as *mut _, self.size) }
|
||||
}
|
||||
|
||||
fn stride(&self) -> usize {
|
||||
|
|
Loading…
Reference in a new issue