mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
@@ -151,7 +151,7 @@ impl BalloonEpollHandler {
|
||||
libc::fallocate64(
|
||||
f_off.file().as_raw_fd(),
|
||||
libc::FALLOC_FL_PUNCH_HOLE | libc::FALLOC_FL_KEEP_SIZE,
|
||||
(offset as u64 + f_off.start()) as libc::off64_t,
|
||||
(offset + f_off.start()) as libc::off64_t,
|
||||
range_len as libc::off64_t,
|
||||
)
|
||||
};
|
||||
|
||||
@@ -229,7 +229,7 @@ impl BlockEpollHandler {
|
||||
.map_err(Error::RequestStatus)?;
|
||||
|
||||
queue
|
||||
.add_used(mem.deref(), desc_index as u16, len)
|
||||
.add_used(mem.deref(), desc_index, len)
|
||||
.map_err(Error::QueueAddUsed)?;
|
||||
used_descs = true;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ impl ConsoleEpollHandler {
|
||||
|
||||
while let Some(mut desc_chain) = recv_queue.pop_descriptor_chain(self.mem.memory()) {
|
||||
let desc = desc_chain.next().ok_or(Error::DescriptorChainTooShort)?;
|
||||
let len = cmp::min(desc.len() as u32, in_buffer.len() as u32);
|
||||
let len = cmp::min(desc.len(), in_buffer.len() as u32);
|
||||
let source_slice = in_buffer.drain(..len as usize).collect::<Vec<u8>>();
|
||||
|
||||
desc_chain
|
||||
|
||||
@@ -246,7 +246,7 @@ impl VirtioMemConfig {
|
||||
size,
|
||||
self.region_size
|
||||
)));
|
||||
} else if size % (self.block_size as u64) != 0 {
|
||||
} else if size % self.block_size != 0 {
|
||||
return Err(Error::ResizeError(anyhow!(
|
||||
"new size 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
size,
|
||||
|
||||
@@ -140,7 +140,7 @@ impl Blk {
|
||||
}
|
||||
|
||||
let config_len = mem::size_of::<VirtioBlockConfig>();
|
||||
let config_space: Vec<u8> = vec![0u8; config_len as usize];
|
||||
let config_space: Vec<u8> = vec![0u8; config_len];
|
||||
let (_, config_space) = vu
|
||||
.socket_handle()
|
||||
.get_config(
|
||||
|
||||
@@ -232,20 +232,13 @@ impl VhostUserMasterReqHandler for SlaveReqHandler {
|
||||
pwrite64(
|
||||
fd.as_raw_fd(),
|
||||
ptr as *const c_void,
|
||||
len as usize,
|
||||
len,
|
||||
foffset as off64_t,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
debug!("read: foffset={}, len={}", foffset, len);
|
||||
unsafe {
|
||||
pread64(
|
||||
fd.as_raw_fd(),
|
||||
ptr as *mut c_void,
|
||||
len as usize,
|
||||
foffset as off64_t,
|
||||
)
|
||||
}
|
||||
unsafe { pread64(fd.as_raw_fd(), ptr as *mut c_void, len, foffset as off64_t) }
|
||||
};
|
||||
|
||||
if ret < 0 {
|
||||
|
||||
@@ -68,7 +68,7 @@ impl VhostUserHandle {
|
||||
|
||||
let vhost_user_net_reg = VhostUserMemoryRegionInfo {
|
||||
guest_phys_addr: region.start_addr().raw_value(),
|
||||
memory_size: region.len() as u64,
|
||||
memory_size: region.len(),
|
||||
userspace_addr: region.as_ptr() as u64,
|
||||
mmap_offset,
|
||||
mmap_handle,
|
||||
@@ -92,7 +92,7 @@ impl VhostUserHandle {
|
||||
|
||||
let region = VhostUserMemoryRegionInfo {
|
||||
guest_phys_addr: region.start_addr().raw_value(),
|
||||
memory_size: region.len() as u64,
|
||||
memory_size: region.len(),
|
||||
userspace_addr: region.as_ptr() as u64,
|
||||
mmap_offset,
|
||||
mmap_handle,
|
||||
|
||||
@@ -647,7 +647,7 @@ where
|
||||
/// buffer.
|
||||
///
|
||||
fn peer_avail_credit(&self) -> usize {
|
||||
(Wrapping(self.peer_buf_alloc as u32) - (self.rx_cnt - self.peer_fwd_cnt)).0 as usize
|
||||
(Wrapping(self.peer_buf_alloc) - (self.rx_cnt - self.peer_fwd_cnt)).0 as usize
|
||||
}
|
||||
|
||||
/// Prepare a packet header for transmission to our peer.
|
||||
@@ -1118,7 +1118,7 @@ mod tests {
|
||||
// CONN_TX_BUF_SIZE - CONN_CREDIT_UPDATE_THRESHOLD, we initialize
|
||||
// fwd_cnt at 6 bytes below the threshold.
|
||||
let initial_fwd_cnt =
|
||||
csm_defs::CONN_TX_BUF_SIZE as u32 - csm_defs::CONN_CREDIT_UPDATE_THRESHOLD as u32 - 6;
|
||||
csm_defs::CONN_TX_BUF_SIZE - csm_defs::CONN_CREDIT_UPDATE_THRESHOLD - 6;
|
||||
ctx.conn.fwd_cnt = Wrapping(initial_fwd_cnt);
|
||||
|
||||
// Use a 4-byte packet for triggering the credit update threshold.
|
||||
|
||||
@@ -285,9 +285,9 @@ mod tests {
|
||||
pub fn create_epoll_handler_context(&self) -> EpollHandlerContext {
|
||||
const QSIZE: u16 = 2;
|
||||
|
||||
let guest_rxvq = GuestQ::new(GuestAddress(0x0010_0000), &self.mem, QSIZE as u16);
|
||||
let guest_txvq = GuestQ::new(GuestAddress(0x0020_0000), &self.mem, QSIZE as u16);
|
||||
let guest_evvq = GuestQ::new(GuestAddress(0x0030_0000), &self.mem, QSIZE as u16);
|
||||
let guest_rxvq = GuestQ::new(GuestAddress(0x0010_0000), &self.mem, QSIZE);
|
||||
let guest_txvq = GuestQ::new(GuestAddress(0x0020_0000), &self.mem, QSIZE);
|
||||
let guest_evvq = GuestQ::new(GuestAddress(0x0030_0000), &self.mem, QSIZE);
|
||||
let rxvq = guest_rxvq.create_queue();
|
||||
let txvq = guest_txvq.create_queue();
|
||||
let evvq = guest_evvq.create_queue();
|
||||
|
||||
@@ -881,7 +881,7 @@ mod tests {
|
||||
peer_port: u32,
|
||||
data: &[u8],
|
||||
) -> &mut VsockPacket {
|
||||
assert!(data.len() <= self.pkt.buf().unwrap().len() as usize);
|
||||
assert!(data.len() <= self.pkt.buf().unwrap().len());
|
||||
self.init_pkt(local_port, peer_port, uapi::VSOCK_OP_RW)
|
||||
.set_len(data.len() as u32);
|
||||
self.pkt.buf_mut().unwrap()[..data.len()].copy_from_slice(data);
|
||||
|
||||
Reference in New Issue
Block a user