mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
vfio: Move the PCI implementation to the PCI crate
There is a much stronger PCI dependency from vfio_pci.rs than a VFIO one from pci/src/vfio.rs. It seems more natural to have the PCI specific VFIO implementation in the PCI crate rather than the other way around. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
8f7dc73562
commit
53ce529875
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -683,15 +683,20 @@ dependencies = [
|
||||
"anyhow",
|
||||
"byteorder",
|
||||
"devices",
|
||||
"kvm-bindings",
|
||||
"kvm-ioctls",
|
||||
"libc",
|
||||
"log 0.4.8",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"vfio",
|
||||
"vfio-bindings",
|
||||
"vm-allocator",
|
||||
"vm-device",
|
||||
"vm-memory",
|
||||
"vm-migration",
|
||||
"vmm-sys-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1345,14 +1350,11 @@ version = "0.0.1"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"byteorder",
|
||||
"devices",
|
||||
"kvm-bindings",
|
||||
"kvm-ioctls",
|
||||
"libc",
|
||||
"log 0.4.8",
|
||||
"pci",
|
||||
"vfio-bindings",
|
||||
"vm-allocator",
|
||||
"vm-device",
|
||||
"vm-memory",
|
||||
"vmm-sys-util",
|
||||
|
@ -8,6 +8,10 @@ edition = "2018"
|
||||
anyhow = "1.0"
|
||||
byteorder = "1.3.4"
|
||||
devices = { path = "../devices" }
|
||||
kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch" }
|
||||
kvm-ioctls = { git = "https://github.com/cloud-hypervisor/kvm-ioctls", branch = "ch" }
|
||||
vfio = { path = "../vfio" }
|
||||
vmm-sys-util = ">=0.3.1"
|
||||
libc = "0.2.71"
|
||||
log = "0.4.8"
|
||||
serde = {version = ">=1.0.27", features = ["rc"] }
|
||||
@ -17,3 +21,7 @@ vm-allocator = { path = "../vm-allocator" }
|
||||
vm-device = { path = "../vm-device" }
|
||||
vm-memory = "0.2.1"
|
||||
vm-migration = { path = "../vm-migration" }
|
||||
|
||||
[dependencies.vfio-bindings]
|
||||
git = "https://github.com/rust-vmm/vfio-bindings"
|
||||
features = ["fam-wrappers"]
|
||||
|
@ -17,6 +17,7 @@ mod configuration;
|
||||
mod device;
|
||||
mod msi;
|
||||
mod msix;
|
||||
mod vfio;
|
||||
|
||||
pub use self::bus::{PciBus, PciConfigIo, PciConfigMmio, PciRoot, PciRootError};
|
||||
pub use self::configuration::{
|
||||
@ -29,6 +30,7 @@ pub use self::device::{
|
||||
};
|
||||
pub use self::msi::{msi_num_enabled_vectors, MsiCap, MsiConfig};
|
||||
pub use self::msix::{MsixCap, MsixConfig, MsixTableEntry, MSIX_TABLE_ENTRY_SIZE};
|
||||
pub use self::vfio::{VfioPciDevice, VfioPciError};
|
||||
|
||||
/// PCI has four interrupt pins A->D.
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -4,15 +4,13 @@
|
||||
//
|
||||
|
||||
extern crate devices;
|
||||
extern crate pci;
|
||||
extern crate vm_allocator;
|
||||
|
||||
use crate::vfio_device::VfioDevice;
|
||||
use byteorder::{ByteOrder, LittleEndian};
|
||||
use devices::BusDevice;
|
||||
use kvm_bindings::kvm_userspace_memory_region;
|
||||
use kvm_ioctls::*;
|
||||
use pci::{
|
||||
use crate::{
|
||||
msi_num_enabled_vectors, BarReprogrammingParams, MsiConfig, MsixCap, MsixConfig,
|
||||
PciBarConfiguration, PciBarRegionType, PciCapabilityID, PciClassCode, PciConfiguration,
|
||||
PciDevice, PciDeviceError, PciHeaderType, PciSubclass, MSIX_TABLE_ENTRY_SIZE,
|
||||
@ -22,6 +20,7 @@ use std::os::unix::io::AsRawFd;
|
||||
use std::ptr::null_mut;
|
||||
use std::sync::Arc;
|
||||
use std::{fmt, io, result};
|
||||
use vfio::{VfioDevice, VfioError};
|
||||
use vfio_bindings::bindings::vfio::*;
|
||||
use vm_allocator::SystemAllocator;
|
||||
use vm_device::interrupt::{
|
||||
@ -41,7 +40,7 @@ pub enum VfioPciError {
|
||||
SetGsiRouting(kvm_ioctls::Error),
|
||||
MsiNotConfigured,
|
||||
MsixNotConfigured,
|
||||
UpdateMemory(crate::VfioError),
|
||||
UpdateMemory(VfioError),
|
||||
UpdateMsiEventFd,
|
||||
UpdateMsixEventFd,
|
||||
}
|
@ -6,13 +6,10 @@ authors = ["The Cloud Hypervisor Authors"]
|
||||
[dependencies]
|
||||
arc-swap = ">=0.4.4"
|
||||
byteorder = "1.3.4"
|
||||
devices = { path = "../devices" }
|
||||
kvm-bindings = { git = "https://github.com/cloud-hypervisor/kvm-bindings", branch = "ch" }
|
||||
kvm-ioctls = { git = "https://github.com/cloud-hypervisor/kvm-ioctls", branch = "ch" }
|
||||
libc = "0.2.71"
|
||||
log = "0.4.8"
|
||||
pci = { path = "../pci" }
|
||||
vm-allocator = { path = "../vm-allocator" }
|
||||
vm-device = { path = "../vm-device" }
|
||||
vm-memory = { version = "0.2.1", features = ["backend-mmap"] }
|
||||
vmm-sys-util = ">=0.3.1"
|
||||
|
@ -7,14 +7,11 @@
|
||||
//! Virtual Function I/O (VFIO) API
|
||||
extern crate arc_swap;
|
||||
extern crate byteorder;
|
||||
extern crate devices;
|
||||
extern crate kvm_bindings;
|
||||
extern crate kvm_ioctls;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
extern crate pci;
|
||||
extern crate vfio_bindings;
|
||||
extern crate vm_allocator;
|
||||
extern crate vm_device;
|
||||
extern crate vm_memory;
|
||||
#[macro_use]
|
||||
@ -22,12 +19,10 @@ extern crate vmm_sys_util;
|
||||
|
||||
mod vfio_device;
|
||||
mod vfio_ioctls;
|
||||
mod vfio_pci;
|
||||
|
||||
use std::mem::size_of;
|
||||
|
||||
pub use vfio_device::{VfioContainer, VfioDevice, VfioDmaMapping, VfioError};
|
||||
pub use vfio_pci::{VfioPciDevice, VfioPciError};
|
||||
|
||||
// Returns a `Vec<T>` with a size in bytes at least as large as `size_in_bytes`.
|
||||
fn vec_with_size_in_bytes<T: Default>(size_in_bytes: usize) -> Vec<T> {
|
||||
|
@ -40,6 +40,7 @@ use libc::{MAP_NORESERVE, MAP_PRIVATE, MAP_SHARED, O_TMPFILE, PROT_READ, PROT_WR
|
||||
#[cfg(feature = "pci_support")]
|
||||
use pci::{
|
||||
DeviceRelocation, PciBarRegionType, PciBus, PciConfigIo, PciConfigMmio, PciDevice, PciRoot,
|
||||
VfioPciDevice,
|
||||
};
|
||||
use qcow::{self, ImageType, QcowFile};
|
||||
#[cfg(feature = "pci_support")]
|
||||
@ -54,7 +55,7 @@ use std::result;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tempfile::NamedTempFile;
|
||||
#[cfg(feature = "pci_support")]
|
||||
use vfio::{VfioDevice, VfioDmaMapping, VfioPciDevice, VfioPciError};
|
||||
use vfio::{VfioDevice, VfioDmaMapping};
|
||||
use vm_allocator::SystemAllocator;
|
||||
use vm_device::interrupt::{
|
||||
InterruptIndex, InterruptManager, LegacyIrqGroupConfig, MsiIrqGroupConfig,
|
||||
@ -215,11 +216,11 @@ pub enum DeviceManagerError {
|
||||
|
||||
/// Cannot create a VFIO PCI device
|
||||
#[cfg(feature = "pci_support")]
|
||||
VfioPciCreate(vfio::VfioPciError),
|
||||
VfioPciCreate(pci::VfioPciError),
|
||||
|
||||
/// Failed to map VFIO MMIO region.
|
||||
#[cfg(feature = "pci_support")]
|
||||
VfioMapRegion(VfioPciError),
|
||||
VfioMapRegion(pci::VfioPciError),
|
||||
|
||||
/// Failed to create the KVM device.
|
||||
CreateKvmDevice(kvm_ioctls::Error),
|
||||
@ -326,7 +327,7 @@ pub enum DeviceManagerError {
|
||||
|
||||
/// Failed updating guest memory for VFIO PCI device.
|
||||
#[cfg(feature = "pci_support")]
|
||||
UpdateMemoryForVfioPciDevice(VfioPciError),
|
||||
UpdateMemoryForVfioPciDevice(pci::VfioPciError),
|
||||
|
||||
/// Trying to use a directory for pmem but no size specified
|
||||
PmemWithDirectorySizeMissing,
|
||||
|
Loading…
x
Reference in New Issue
Block a user