Skip to content

Commit ce94a3a

Browse files
committed
clean up: removed any leftover related to...
either vhost or vsock. Signed-off-by: Diana Popa <[email protected]>
1 parent 36a789b commit ce94a3a

File tree

2 files changed

+7
-60
lines changed

2 files changed

+7
-60
lines changed

sys_util/src/guest_memory.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -328,34 +328,6 @@ impl GuestMemory {
328328
})
329329
}
330330

331-
/// Convert a GuestAddress into a pointer in the address space of this
332-
/// process. This should only be necessary for giving addresses to the
333-
/// kernel, as with vhost ioctls. Normal reads/writes to guest memory should
334-
/// be done through `write_from_memory`, `read_obj_from_addr`, etc.
335-
///
336-
/// # Arguments
337-
/// * `guest_addr` - Guest address to convert.
338-
///
339-
/// # Examples
340-
///
341-
/// ```
342-
/// # use sys_util::{GuestAddress, GuestMemory};
343-
/// # fn test_host_addr() -> Result<(), ()> {
344-
/// let start_addr = GuestAddress(0x1000);
345-
/// let mut gm = GuestMemory::new(&vec![(start_addr, 0x500)]).map_err(|_| ())?;
346-
/// let addr = gm.get_host_address(GuestAddress(0x1200)).unwrap();
347-
/// println!("Host address is {:p}", addr);
348-
/// Ok(())
349-
/// # }
350-
/// ```
351-
pub fn get_host_address(&self, guest_addr: GuestAddress) -> Result<*const u8> {
352-
self.do_in_region(guest_addr, |mapping, offset| {
353-
// This is safe; `do_in_region` already checks that offset is in
354-
// bounds.
355-
Ok(unsafe { mapping.as_ptr().offset(offset as isize) } as *const u8)
356-
})
357-
}
358-
359331
pub fn do_in_region<F, T>(&self, guest_addr: GuestAddress, cb: F) -> Result<T>
360332
where
361333
F: FnOnce(&MemoryMapping, usize) -> Result<T>,
@@ -462,31 +434,6 @@ mod tests {
462434
assert_eq!(val2, num2);
463435
}
464436

465-
// Get the base address of the mapping for a GuestAddress.
466-
fn get_mapping(mem: &GuestMemory, addr: GuestAddress) -> Result<*const u8> {
467-
mem.do_in_region(addr, |mapping, _| Ok(mapping.as_ptr() as *const u8))
468-
}
469-
470-
#[test]
471-
fn guest_to_host() {
472-
let start_addr1 = GuestAddress(0x0);
473-
let start_addr2 = GuestAddress(0x100);
474-
let mem = GuestMemory::new(&vec![(start_addr1, 0x100), (start_addr2, 0x400)]).unwrap();
475-
476-
// Verify the host addresses match what we expect from the mappings.
477-
let addr1_base = get_mapping(&mem, start_addr1).unwrap();
478-
let addr2_base = get_mapping(&mem, start_addr2).unwrap();
479-
let host_addr1 = mem.get_host_address(start_addr1).unwrap();
480-
let host_addr2 = mem.get_host_address(start_addr2).unwrap();
481-
assert_eq!(host_addr1, addr1_base);
482-
assert_eq!(host_addr2, addr2_base);
483-
484-
// Check that a bad address returns an error.
485-
let bad_addr = GuestAddress(0x123456);
486-
assert!(mem.get_host_address(bad_addr).is_err());
487-
format!("{:?}", mem.get_host_address(bad_addr));
488-
}
489-
490437
#[test]
491438
fn write_and_read_slice() {
492439
let start_addr = GuestAddress(0x1000);

sys_util/src/ioctl.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ pub unsafe fn ioctl_with_mut_ptr<F: AsRawFd, T>(fd: &F, req: c_ulong, arg: *mut
115115
#[cfg(test)]
116116
mod tests {
117117
const TUNTAP: ::std::os::raw::c_uint = 0x54;
118-
const VHOST: ::std::os::raw::c_uint = 0xaf;
118+
const KVMIO: ::std::os::raw::c_uint = 0xAE;
119119

120-
ioctl_io_nr!(VHOST_SET_OWNER, VHOST, 0x01);
120+
ioctl_io_nr!(KVM_CREATE_VM, KVMIO, 0x01);
121121
ioctl_ior_nr!(TUNGETFEATURES, TUNTAP, 0xcf, ::std::os::raw::c_uint);
122122
ioctl_iow_nr!(TUNSETQUEUE, TUNTAP, 0xd9, ::std::os::raw::c_int);
123-
ioctl_iowr_nr!(VHOST_GET_VRING_BASE, VHOST, 0x12, ::std::os::raw::c_int);
123+
ioctl_iowr_nr!(KVM_GET_MSR_INDEX_LIST, KVMIO, 0x2, ::std::os::raw::c_int);
124124

125125
#[test]
126126
fn ioctl_macros() {
127-
assert_eq!(0x0000af01, VHOST_SET_OWNER());
128-
assert_eq!(0x800454cf, TUNGETFEATURES());
129-
assert_eq!(0x400454d9, TUNSETQUEUE());
130-
assert_eq!(0xc004af12, VHOST_GET_VRING_BASE());
127+
assert_eq!(0x0000AE01, KVM_CREATE_VM());
128+
assert_eq!(0x800454CF, TUNGETFEATURES());
129+
assert_eq!(0x400454D9, TUNSETQUEUE());
130+
assert_eq!(0xC004AE02, KVM_GET_MSR_INDEX_LIST());
131131
}
132132
}

0 commit comments

Comments
 (0)