mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-04-01 20:04:37 +00:00
vmm: Expose counters from virtio devices to API
Collate the virtio device counters in DeviceManager for each device that exposes any and expose it through the recently added HTTP API. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
9b7afd4aac
commit
d983c0a680
@ -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<String, HashMap<&'static str, Wrapping<u64>>> {
|
||||
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")]
|
||||
|
@ -994,7 +994,7 @@ impl Vm {
|
||||
}
|
||||
|
||||
pub fn counters(&self) -> Result<HashMap<String, HashMap<&'static str, Wrapping<u64>>>> {
|
||||
Ok(HashMap::new())
|
||||
Ok(self.device_manager.lock().unwrap().counters())
|
||||
}
|
||||
|
||||
fn os_signal_handler(signals: Signals, console_input_clone: Arc<Console>, on_tty: bool) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user