Skip to content

Commit e04cdfe

Browse files
committed
chore: adjust to api changes in rust-vmm crates
vm-memory: GuestMemoryIterator is gone kvm-ioctls: DeviceFd::get_device_attr is now unsafe. Signed-off-by: Patrick Roy <[email protected]>
1 parent b358ad0 commit e04cdfe

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/vmm/src/arch/aarch64/gic/gicv2/regs/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ pub fn restore_state(fd: &DeviceFd, mpidrs: &[u64], state: &GicState) -> Result<
4141

4242
#[cfg(test)]
4343
mod tests {
44+
#![allow(clippy::undocumented_unsafe_blocks)]
45+
4446
use kvm_ioctls::Kvm;
4547

4648
use super::*;
@@ -79,7 +81,9 @@ mod tests {
7981
addr: &val as *const u32 as u64,
8082
flags: 0,
8183
};
82-
gic_fd.get_device_attr(&mut gic_dist_attr).unwrap();
84+
unsafe {
85+
gic_fd.get_device_attr(&mut gic_dist_attr).unwrap();
86+
}
8387

8488
// The second value from the list of distributor registers is the value of the GICD_STATUSR
8589
// register. We assert that the one saved in the bitmap is the same with the one we

src/vmm/src/arch/aarch64/gic/gicv3/regs/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ pub fn restore_state(fd: &DeviceFd, mpidrs: &[u64], state: &GicState) -> Result<
4646

4747
#[cfg(test)]
4848
mod tests {
49+
#![allow(clippy::undocumented_unsafe_blocks)]
50+
4951
use kvm_ioctls::Kvm;
5052

5153
use super::*;
@@ -81,7 +83,9 @@ mod tests {
8183
addr: &val as *const u32 as u64,
8284
flags: 0,
8385
};
84-
gic_fd.get_device_attr(&mut gic_dist_attr).unwrap();
86+
unsafe {
87+
gic_fd.get_device_attr(&mut gic_dist_attr).unwrap();
88+
}
8589

8690
// The second value from the list of distributor registers is the value of the GICD_STATUSR
8791
// register. We assert that the one saved in the bitmap is the same with the one we

src/vmm/src/arch/aarch64/gic/regs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ pub(crate) trait VgicRegEngine {
8181
let mut data = Vec::with_capacity(reg.iter::<Self::RegChunk>().count());
8282
for offset in reg.iter::<Self::RegChunk>() {
8383
let mut val = Self::RegChunk::default();
84-
fd.get_device_attr(&mut Self::kvm_device_attr(offset, &mut val, mpidr))
85-
.map_err(|err| GicError::DeviceAttribute(err, false, Self::group()))?;
84+
// SAFETY: `val` is a mutable memory location sized correctly for the attribute we're
85+
// requesting
86+
unsafe {
87+
fd.get_device_attr(&mut Self::kvm_device_attr(offset, &mut val, mpidr))
88+
.map_err(|err| GicError::DeviceAttribute(err, false, Self::group()))?;
89+
}
8690
data.push(val);
8791
}
8892

src/vmm/src/devices/virtio/queue.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,6 @@ mod verification {
700700
use std::mem::ManuallyDrop;
701701
use std::num::Wrapping;
702702

703-
use vm_memory::guest_memory::GuestMemoryIterator;
704703
use vm_memory::{GuestMemoryRegion, MemoryRegionAddress};
705704

706705
use super::*;
@@ -717,13 +716,8 @@ mod verification {
717716
the_region: vm_memory::GuestRegionMmap,
718717
}
719718

720-
impl<'a> GuestMemoryIterator<'a, vm_memory::GuestRegionMmap> for ProofGuestMemory {
721-
type Iter = std::iter::Once<&'a vm_memory::GuestRegionMmap>;
722-
}
723-
724719
impl GuestMemory for ProofGuestMemory {
725720
type R = vm_memory::GuestRegionMmap;
726-
type I = Self;
727721

728722
fn num_regions(&self) -> usize {
729723
1
@@ -735,7 +729,7 @@ mod verification {
735729
.map(|_| &self.the_region)
736730
}
737731

738-
fn iter(&self) -> <Self::I as GuestMemoryIterator<Self::R>>::Iter {
732+
fn iter(&self) -> impl Iterator<Item = &Self::R> {
739733
std::iter::once(&self.the_region)
740734
}
741735

0 commit comments

Comments
 (0)