From dd54883a07110c0b656e5d3a578f88e095211b84 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Wed, 24 Jun 2020 10:43:58 +0100 Subject: [PATCH] vm-virtio: device: Extend the VirtioDevice trait to expose counters The counters are a hash of counter name to (wrapping) u64 value. The interpretation layer is responsible for converting this data into a rate. Signed-off-by: Rob Bradford --- vm-virtio/src/device.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vm-virtio/src/device.rs b/vm-virtio/src/device.rs index f149fafda..fe6726835 100644 --- a/vm-virtio/src/device.rs +++ b/vm-virtio/src/device.rs @@ -7,6 +7,8 @@ // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause use crate::{ActivateResult, Error, Queue}; +use std::collections::HashMap; +use std::num::Wrapping; use std::sync::Arc; use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryMmap, GuestUsize}; use vmm_sys_util::eventfd::EventFd; @@ -134,6 +136,11 @@ pub trait VirtioDevice: Send { fn userspace_mappings(&self) -> Vec { Vec::new() } + + /// Return the counters that this device exposes + fn counters(&self) -> Option>> { + None + } } /// Trait providing address translation the same way a physical DMA remapping