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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-06-24 10:43:58 +01:00 committed by Samuel Ortiz
parent 2b4a0358de
commit dd54883a07

View File

@ -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<UserspaceMapping> {
Vec::new()
}
/// Return the counters that this device exposes
fn counters(&self) -> Option<HashMap<&'static str, Wrapping<u64>>> {
None
}
}
/// Trait providing address translation the same way a physical DMA remapping