mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
virtio-devices, vmm: Move to ExternalDmaMapping from vm-device
Now that ExternalDmaMapping is defined in vm-device, let's use it from there. This commit also defines the function get_host_address_range() to move away from the vfio-ioctls dependency. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
5bd05b1af0
commit
aee1155870
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1420,7 +1420,6 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"vfio-ioctls",
|
||||
"vhost",
|
||||
"virtio-bindings",
|
||||
"vm-allocator",
|
||||
|
@ -25,7 +25,6 @@ seccomp = { git = "https://github.com/firecracker-microvm/firecracker", tag = "v
|
||||
serde = ">=1.0.27"
|
||||
serde_derive = ">=1.0.27"
|
||||
serde_json = ">=1.0.9"
|
||||
vfio-ioctls = { git = "https://github.com/cloud-hypervisor/vfio-ioctls", branch = "ch" }
|
||||
vhost_rs = { git = "https://github.com/rust-vmm/vhost", branch = "master", package = "vhost", features = ["vhost-user-master", "vhost-user-slave"] }
|
||||
virtio-bindings = { version = "0.1", features = ["virtio-v5_0_0"]}
|
||||
vm-allocator = { path = "../vm-allocator" }
|
||||
|
@ -22,7 +22,7 @@ use std::result;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::{Arc, Barrier, RwLock};
|
||||
use std::thread;
|
||||
use vfio_ioctls::ExternalDmaMapping;
|
||||
use vm_device::dma_mapping::ExternalDmaMapping;
|
||||
use vm_memory::{
|
||||
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic,
|
||||
GuestMemoryError, GuestMemoryMmap,
|
||||
|
@ -59,6 +59,7 @@ pub use self::pmem::*;
|
||||
pub use self::rng::*;
|
||||
pub use self::vsock::*;
|
||||
pub use self::watchdog::*;
|
||||
use vm_memory::{GuestAddress, GuestMemory};
|
||||
use vm_virtio::{queue::*, VirtioDeviceType};
|
||||
|
||||
const DEVICE_INIT: u32 = 0x00;
|
||||
@ -125,3 +126,19 @@ pub enum Error {
|
||||
NetQueuePair(::net_util::NetQueuePairError),
|
||||
ApplySeccompFilter(seccomp::Error),
|
||||
}
|
||||
|
||||
/// Convert an absolute address into an address space (GuestMemory)
|
||||
/// to a host pointer and verify that the provided size define a valid
|
||||
/// range within a single memory region.
|
||||
/// Return None if it is out of bounds or if addr+size overlaps a single region.
|
||||
pub fn get_host_address_range<M: GuestMemory>(
|
||||
mem: &M,
|
||||
addr: GuestAddress,
|
||||
size: usize,
|
||||
) -> Option<*mut u8> {
|
||||
if mem.check_range(addr, size) {
|
||||
Some(mem.get_host_address(addr).unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,12 @@
|
||||
|
||||
use super::super::{Descriptor, Queue};
|
||||
use super::{Error, Result};
|
||||
use crate::{VirtioInterrupt, VirtioInterruptType};
|
||||
use crate::{get_host_address_range, VirtioInterrupt, VirtioInterruptType};
|
||||
use libc::EFD_NONBLOCK;
|
||||
use std::convert::TryInto;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::sync::Arc;
|
||||
use std::vec::Vec;
|
||||
use vfio_ioctls::get_host_address_range;
|
||||
use vhost_rs::vhost_user::{Master, VhostUserMaster};
|
||||
use vhost_rs::{VhostBackend, VhostUserMemoryRegionInfo, VringConfigData};
|
||||
use vm_memory::{Address, Error as MmapError, GuestMemory, GuestMemoryMmap, GuestMemoryRegion};
|
||||
|
@ -17,10 +17,9 @@
|
||||
///
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
|
||||
use super::super::DescriptorChain;
|
||||
use super::defs;
|
||||
use super::{Result, VsockError};
|
||||
use vfio_ioctls::get_host_address_range;
|
||||
use crate::{get_host_address_range, DescriptorChain};
|
||||
|
||||
// The vsock packet header is defined by the C struct:
|
||||
//
|
||||
|
@ -79,13 +79,15 @@ use std::path::PathBuf;
|
||||
use std::result;
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
#[cfg(feature = "kvm")]
|
||||
use vfio_ioctls::{VfioContainer, VfioDevice, VfioDmaMapping};
|
||||
use vfio_ioctls::{VfioContainer, VfioDevice};
|
||||
use virtio_devices::transport::VirtioPciDevice;
|
||||
use virtio_devices::transport::VirtioTransport;
|
||||
use virtio_devices::vhost_user::VhostUserConfig;
|
||||
use virtio_devices::{DmaRemapping, IommuMapping};
|
||||
use virtio_devices::{VirtioSharedMemory, VirtioSharedMemoryList};
|
||||
use vm_allocator::SystemAllocator;
|
||||
#[cfg(feature = "kvm")]
|
||||
use vm_device::dma_mapping::vfio::VfioDmaMapping;
|
||||
use vm_device::interrupt::{
|
||||
InterruptIndex, InterruptManager, LegacyIrqGroupConfig, MsiIrqGroupConfig,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user