Skip to content

Commit

Permalink
chore: adjust to api changes in rust-vmm crates
Browse files Browse the repository at this point in the history
vm-memory: GuestMemoryIterator is gone
kvm-ioctls: DeviceFd::get_device_attr is now unsafe.

Signed-off-by: Patrick Roy <[email protected]>
  • Loading branch information
roypat committed Oct 29, 2024
1 parent 1bc168e commit 05f783a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/vmm/src/arch/aarch64/gic/gicv2/regs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub fn restore_state(fd: &DeviceFd, mpidrs: &[u64], state: &GicState) -> Result<

#[cfg(test)]
mod tests {
#![allow(clippy::undocumented_unsafe_blocks)]

use kvm_ioctls::Kvm;

use super::*;
Expand Down
2 changes: 2 additions & 0 deletions src/vmm/src/arch/aarch64/gic/gicv3/regs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub fn restore_state(fd: &DeviceFd, mpidrs: &[u64], state: &GicState) -> Result<

#[cfg(test)]
mod tests {
#![allow(clippy::undocumented_unsafe_blocks)]

use kvm_ioctls::Kvm;

use super::*;
Expand Down
8 changes: 6 additions & 2 deletions src/vmm/src/arch/aarch64/gic/regs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ pub(crate) trait VgicRegEngine {
let mut data = Vec::with_capacity(reg.iter::<Self::RegChunk>().count());
for offset in reg.iter::<Self::RegChunk>() {
let mut val = Self::RegChunk::default();
fd.get_device_attr(&mut Self::kvm_device_attr(offset, &mut val, mpidr))
.map_err(|err| GicError::DeviceAttribute(err, false, Self::group()))?;
// SAFETY: `val` is a mutable memory location sized correctly for the attribute we're
// requesting
unsafe {
fd.get_device_attr(&mut Self::kvm_device_attr(offset, &mut val, mpidr))
.map_err(|err| GicError::DeviceAttribute(err, false, Self::group()))?;
}
data.push(val);
}

Expand Down
8 changes: 1 addition & 7 deletions src/vmm/src/devices/virtio/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ mod verification {
use std::mem::ManuallyDrop;
use std::num::Wrapping;

use vm_memory::guest_memory::GuestMemoryIterator;
use vm_memory::{GuestMemoryRegion, MemoryRegionAddress};

use super::*;
Expand All @@ -717,13 +716,8 @@ mod verification {
the_region: vm_memory::GuestRegionMmap,
}

impl<'a> GuestMemoryIterator<'a, vm_memory::GuestRegionMmap> for ProofGuestMemory {
type Iter = std::iter::Once<&'a vm_memory::GuestRegionMmap>;
}

impl GuestMemory for ProofGuestMemory {
type R = vm_memory::GuestRegionMmap;
type I = Self;

fn num_regions(&self) -> usize {
1
Expand All @@ -735,7 +729,7 @@ mod verification {
.map(|_| &self.the_region)
}

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

Expand Down

0 comments on commit 05f783a

Please sign in to comment.