arch: use libc::getrandom() instead of rand crate

This removes the last use of rand in our tree and the removal of several
dependencies.

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford
2021-02-22 15:43:48 +00:00
parent 24922ce1e3
commit ade5097878
3 changed files with 10 additions and 67 deletions

View File

@@ -84,10 +84,6 @@ pub fn set_lint(vcpu: &Arc<dyn hypervisor::Vcpu>) -> Result<()> {
#[cfg(test)]
#[cfg(feature = "kvm")]
mod tests {
extern crate rand;
use self::rand::Rng;
use super::*;
const KVM_APIC_REG_SIZE: usize = 0x400;
@@ -111,8 +107,15 @@ mod tests {
#[test]
fn test_apic_delivery_mode() {
let mut rng = rand::thread_rng();
let mut v: Vec<u32> = (0..20).map(|_| rng.gen::<u32>()).collect();
let mut v: Vec<u32> = Vec::new();
v.resize(20, 0);
unsafe {
assert_eq!(
libc::getrandom(v.as_mut_ptr() as *mut _ as *mut libc::c_void, 80, 0),
80
);
}
v.iter_mut()
.for_each(|x| *x = set_apic_delivery_mode(*x, 2));