vm-virtio: Remove virtio-pci dependency from VirtioDevice

This patch cleans up the VirtioDevice trait. Since some function are PCI
specific and since they are not even used, it makes sense to remove them
from the trait definition.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2019-08-05 16:53:27 -07:00 committed by Samuel Ortiz
parent e2b38cc050
commit e0fda0611c
2 changed files with 0 additions and 27 deletions

View File

@ -7,7 +7,6 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
use super::*; use super::*;
use pci::{PciBarConfiguration, PciCapability};
use std::sync::Arc; use std::sync::Arc;
use vm_memory::{GuestAddress, GuestMemoryMmap, GuestUsize}; use vm_memory::{GuestAddress, GuestMemoryMmap, GuestUsize};
use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::eventfd::EventFd;
@ -80,16 +79,6 @@ pub trait VirtioDevice: Send {
None None
} }
/// Returns any additional BAR configuration required by the device.
fn get_device_bars(&self) -> Vec<PciBarConfiguration> {
Vec::new()
}
/// Returns any additional capabilities required by the device.
fn get_device_caps(&self) -> Vec<Box<dyn PciCapability>> {
Vec::new()
}
/// Returns the list of shared memory regions required by the device. /// Returns the list of shared memory regions required by the device.
fn get_shm_regions(&self) -> Option<VirtioSharedMemoryList> { fn get_shm_regions(&self) -> Option<VirtioSharedMemoryList> {
None None

View File

@ -559,22 +559,6 @@ impl PciDevice for VirtioPciDevice {
// Once the BARs are allocated, the capabilities can be added to the PCI configuration. // Once the BARs are allocated, the capabilities can be added to the PCI configuration.
self.add_pci_capabilities(virtio_pci_bar)?; self.add_pci_capabilities(virtio_pci_bar)?;
// Allocate the device specific BARs.
for config in self.device.get_device_bars() {
let device_bar_addr = allocator
.allocate_mmio_addresses(None, config.get_size(), None)
.ok_or_else(|| PciDeviceError::IoAllocationFailed(config.get_size()))?;
config.set_address(device_bar_addr.raw_value());
let _device_bar = self.configuration.add_pci_bar(&config).map_err(|e| {
PciDeviceError::IoRegistrationFailed(device_bar_addr.raw_value(), e)
})?;
ranges.push((
device_bar_addr,
config.get_size(),
PciBarRegionType::Memory64BitRegion,
));
}
Ok(ranges) Ok(ranges)
} }