mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
pci: vfio: Add trait for accessing VFIO PCI device config
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
9e0f402e27
commit
349dbb9aac
@@ -245,15 +245,35 @@ pub struct MmioRegion {
|
|||||||
mmap_size: Option<usize>,
|
mmap_size: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VfioPciConfig {
|
trait VfioPciConfig {
|
||||||
|
fn read_config_byte(&self, _offset: u32) -> u8 {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_config_word(&self, _offset: u32) -> u16 {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_config_dword(&self, _offset: u32) -> u32 {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_config_dword(&self, _buf: u32, _offset: u32) {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VfioPciDeviceConfig {
|
||||||
device: Arc<VfioDevice>,
|
device: Arc<VfioDevice>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VfioPciConfig {
|
impl VfioPciDeviceConfig {
|
||||||
fn new(device: Arc<VfioDevice>) -> Self {
|
fn new(device: Arc<VfioDevice>) -> Self {
|
||||||
VfioPciConfig { device }
|
Self { device }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VfioPciConfig for VfioPciDeviceConfig {
|
||||||
fn read_config_byte(&self, offset: u32) -> u8 {
|
fn read_config_byte(&self, offset: u32) -> u8 {
|
||||||
let mut data: [u8; 1] = [0];
|
let mut data: [u8; 1] = [0];
|
||||||
self.device
|
self.device
|
||||||
@@ -295,7 +315,7 @@ pub struct VfioPciDevice {
|
|||||||
vm: Arc<dyn hypervisor::Vm>,
|
vm: Arc<dyn hypervisor::Vm>,
|
||||||
device: Arc<VfioDevice>,
|
device: Arc<VfioDevice>,
|
||||||
container: Arc<VfioContainer>,
|
container: Arc<VfioContainer>,
|
||||||
vfio_pci_configuration: VfioPciConfig,
|
vfio_pci_configuration: VfioPciDeviceConfig,
|
||||||
configuration: PciConfiguration,
|
configuration: PciConfiguration,
|
||||||
mmio_regions: Vec<MmioRegion>,
|
mmio_regions: Vec<MmioRegion>,
|
||||||
interrupt: Interrupt,
|
interrupt: Interrupt,
|
||||||
@@ -328,7 +348,7 @@ impl VfioPciDevice {
|
|||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
let vfio_pci_configuration = VfioPciConfig::new(Arc::clone(&device));
|
let vfio_pci_configuration = VfioPciDeviceConfig::new(Arc::clone(&device));
|
||||||
|
|
||||||
let mut vfio_pci_device = VfioPciDevice {
|
let mut vfio_pci_device = VfioPciDevice {
|
||||||
vm: vm.clone(),
|
vm: vm.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user