From e0fda0611cc8fb84c25b912697f41146e8f2801d Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 5 Aug 2019 16:53:27 -0700 Subject: [PATCH] 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 --- vm-virtio/src/device.rs | 11 ----------- vm-virtio/src/transport/pci_device.rs | 16 ---------------- 2 files changed, 27 deletions(-) diff --git a/vm-virtio/src/device.rs b/vm-virtio/src/device.rs index 6c4a79088..b2291b08e 100644 --- a/vm-virtio/src/device.rs +++ b/vm-virtio/src/device.rs @@ -7,7 +7,6 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause use super::*; -use pci::{PciBarConfiguration, PciCapability}; use std::sync::Arc; use vm_memory::{GuestAddress, GuestMemoryMmap, GuestUsize}; use vmm_sys_util::eventfd::EventFd; @@ -80,16 +79,6 @@ pub trait VirtioDevice: Send { None } - /// Returns any additional BAR configuration required by the device. - fn get_device_bars(&self) -> Vec { - Vec::new() - } - - /// Returns any additional capabilities required by the device. - fn get_device_caps(&self) -> Vec> { - Vec::new() - } - /// Returns the list of shared memory regions required by the device. fn get_shm_regions(&self) -> Option { None diff --git a/vm-virtio/src/transport/pci_device.rs b/vm-virtio/src/transport/pci_device.rs index fca7dbfe1..a72a3d872 100755 --- a/vm-virtio/src/transport/pci_device.rs +++ b/vm-virtio/src/transport/pci_device.rs @@ -559,22 +559,6 @@ impl PciDevice for VirtioPciDevice { // Once the BARs are allocated, the capabilities can be added to the PCI configuration. 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) }