mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user