diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 7e1843815..fce8cb231 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -3134,6 +3134,19 @@ impl DeviceManager { let (device, iommu_attached, id) = self.make_virtio_vsock_device(vsock_cfg)?; self.hotplug_virtio_pci_device(device, iommu_attached, id) } + + pub fn counters(&self) -> HashMap>> { + let mut counters = HashMap::new(); + + for (virtio_device, _, id) in &self.virtio_devices { + let virtio_device = virtio_device.lock().unwrap(); + if let Some(device_counters) = virtio_device.counters() { + counters.insert(id.clone(), device_counters.clone()); + } + } + + counters + } } #[cfg(feature = "acpi")] diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index ec1335ee3..a7cd204d8 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -994,7 +994,7 @@ impl Vm { } pub fn counters(&self) -> Result>>> { - Ok(HashMap::new()) + Ok(self.device_manager.lock().unwrap().counters()) } fn os_signal_handler(signals: Signals, console_input_clone: Arc, on_tty: bool) {