vmm_vhost: remove more unnecessary &mut self

Follow up to https://crrev.com/c/5064382.

Change-Id: I0d723f765be4b846b0feb679d8e86d423d56345a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068396
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
This commit is contained in:
Frederick Mayle 2023-11-28 12:52:22 -08:00 committed by crosvm LUCI
parent 93bb2d9058
commit 620687c9dc
4 changed files with 11 additions and 14 deletions

View file

@ -287,10 +287,7 @@ impl<R: Req> Endpoint<R> {
/// * - (number of bytes received, buf, [received files]) on success.
/// * - backend specific errors
#[cfg(test)]
pub fn recv_into_buf(
&mut self,
buf_size: usize,
) -> Result<(usize, Vec<u8>, Option<Vec<File>>)> {
pub fn recv_into_buf(&self, buf_size: usize) -> Result<(usize, Vec<u8>, Option<Vec<File>>)> {
let mut buf = vec![0u8; buf_size];
let mut slices = [IoSliceMut::new(buf.as_mut_slice())];
let (bytes, files) = self.0.recv_into_bufs(&mut slices, true /* allow_fd */)?;
@ -307,7 +304,7 @@ impl<R: Req> Endpoint<R> {
/// * - PartialMessage: received a partial message.
/// * - InvalidMessage: received a invalid message.
/// * - backend specific errors
pub fn recv_header(&mut self) -> Result<(VhostUserMsgHeader<R>, Option<Vec<File>>)> {
pub fn recv_header(&self) -> Result<(VhostUserMsgHeader<R>, Option<Vec<File>>)> {
let mut hdr = VhostUserMsgHeader::default();
let (bytes, files) = self.0.recv_into_bufs(
&mut [IoSliceMut::new(hdr.as_bytes_mut())],

View file

@ -285,7 +285,7 @@ mod tests {
let mut listener = SocketListener::new(&path, true).unwrap();
listener.set_nonblocking(true).unwrap();
let master = Endpoint::<MasterReq>::connect(&path).unwrap();
let mut slave = listener.accept().unwrap().unwrap();
let slave = listener.accept().unwrap().unwrap();
let buf1 = [0x1, 0x2, 0x3, 0x4];
let mut len = master.send_slice(IoSlice::new(&buf1[..]), None).unwrap();
@ -312,7 +312,7 @@ mod tests {
let mut listener = SocketListener::new(&path, true).unwrap();
listener.set_nonblocking(true).unwrap();
let master = Endpoint::<MasterReq>::connect(&path).unwrap();
let mut slave = listener.accept().unwrap().unwrap();
let slave = listener.accept().unwrap().unwrap();
let mut fd = tempfile().unwrap();
write!(fd, "test").unwrap();
@ -485,7 +485,7 @@ mod tests {
let mut listener = SocketListener::new(&path, true).unwrap();
listener.set_nonblocking(true).unwrap();
let master = Endpoint::<MasterReq>::connect(&path).unwrap();
let mut slave = listener.accept().unwrap().unwrap();
let slave = listener.accept().unwrap().unwrap();
let mut hdr1 =
VhostUserMsgHeader::new(MasterReq::GET_FEATURES, 0, mem::size_of::<u64>() as u32);

View file

@ -204,7 +204,7 @@ mod tests {
#[test]
fn send_data() {
let (master, mut slave) = create_pair();
let (master, slave) = create_pair();
let buf1 = vec![0x1, 0x2, 0x3, 0x4];
let len = master.send_slice(IoSlice::new(&buf1[..]), None).unwrap();
@ -216,7 +216,7 @@ mod tests {
#[test]
fn send_fd() {
let (master, mut slave) = create_pair();
let (master, slave) = create_pair();
let mut file = tempfile().unwrap();
write!(file, "test").unwrap();
@ -301,7 +301,7 @@ mod tests {
#[test]
fn send_recv() {
let (master, mut slave) = create_pair();
let (master, slave) = create_pair();
let mut hdr1 =
VhostUserMsgHeader::new(MasterReq::GET_FEATURES, 0, mem::size_of::<u64>() as u32);

View file

@ -713,7 +713,7 @@ mod tests {
#[test]
fn create_master() {
let (master, mut slave) = create_pair();
let (master, slave) = create_pair();
assert!(master.main_sock.as_raw_descriptor() != INVALID_DESCRIPTOR);
// Send two messages continuously
@ -735,7 +735,7 @@ mod tests {
#[test]
fn test_features() {
let (mut master, mut peer) = create_pair();
let (mut master, peer) = create_pair();
master.set_owner().unwrap();
let (hdr, rfds) = peer.recv_header().unwrap();
@ -769,7 +769,7 @@ mod tests {
#[test]
fn test_protocol_features() {
let (mut master, mut peer) = create_pair();
let (mut master, peer) = create_pair();
master.set_owner().unwrap();
let (hdr, rfds) = peer.recv_header().unwrap();