Skip to content

Commit 0223542

Browse files
committed
refactor: delete unused code
with_virtio_device_with_id was never used in the mmio device manager. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent e4cea05 commit 0223542

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

src/vmm/src/device_manager/mmio.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use crate::arch::{RTC_MEM_START, SERIAL_MEM_START};
2525
#[cfg(target_arch = "aarch64")]
2626
use crate::devices::legacy::{RTCDevice, SerialDevice};
2727
use crate::devices::pseudo::BootTimer;
28-
use crate::devices::virtio::device::VirtioDevice;
2928
use crate::devices::virtio::transport::mmio::MmioTransport;
3029
use crate::vstate::bus::{Bus, BusError};
3130
#[cfg(target_arch = "x86_64")]
@@ -41,12 +40,6 @@ pub enum MmioError {
4140
BusInsert(#[from] BusError),
4241
/// Failed to allocate requested resourc: {0}
4342
Cmdline(#[from] linux_loader::cmdline::Error),
44-
/// Failed to find the device on the bus.
45-
DeviceNotFound,
46-
/// Invalid device type found on the MMIO bus.
47-
InvalidDeviceType,
48-
/// {0}
49-
InternalDeviceError(String),
5043
/// Could not create IRQ for MMIO device: {0}
5144
CreateIrq(#[from] std::io::Error),
5245
/// Invalid MMIO IRQ configuration.
@@ -407,31 +400,6 @@ impl MMIODeviceManager {
407400
Ok(())
408401
}
409402

410-
/// Run fn `f()` for the virtio device matching `virtio_type` and `id`.
411-
pub fn with_virtio_device_with_id<T, F>(
412-
&self,
413-
virtio_type: u32,
414-
id: &str,
415-
f: F,
416-
) -> Result<(), MmioError>
417-
where
418-
T: VirtioDevice + 'static + Debug,
419-
F: FnOnce(&mut T) -> Result<(), String>,
420-
{
421-
if let Some(device) = self.get_virtio_device(virtio_type, id) {
422-
let virtio_device = device.inner.lock().expect("Poisoned lock").device();
423-
let mut dev = virtio_device.lock().expect("Poisoned lock");
424-
f(dev
425-
.as_mut_any()
426-
.downcast_mut::<T>()
427-
.ok_or(MmioError::InvalidDeviceType)?)
428-
.map_err(MmioError::InternalDeviceError)?;
429-
} else {
430-
return Err(MmioError::DeviceNotFound);
431-
}
432-
Ok(())
433-
}
434-
435403
#[cfg(target_arch = "aarch64")]
436404
pub fn virtio_device_info(&self) -> Vec<&MMIODeviceInfo> {
437405
let mut device_info = Vec::new();

0 commit comments

Comments
 (0)