From 6ba1c4318eb10d52766e09a2917ff6f7350311ed Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 16 Jul 2020 09:46:05 +0100 Subject: [PATCH] virtio-devices: Add default implementations for {read,write}_config Not every virtio device has any config fields that can be read and most have none that can be written to. Signed-off-by: Rob Bradford --- virtio-devices/src/device.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/virtio-devices/src/device.rs b/virtio-devices/src/device.rs index d1d42164d..7e5ac1be5 100644 --- a/virtio-devices/src/device.rs +++ b/virtio-devices/src/device.rs @@ -11,6 +11,7 @@ use std::collections::HashMap; use std::num::Wrapping; use std::sync::Arc; use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryMmap, GuestUsize}; +use vm_virtio::VirtioDeviceType; use vmm_sys_util::eventfd::EventFd; pub enum VirtioInterruptType { @@ -82,10 +83,20 @@ pub trait VirtioDevice: Send { } /// Reads this device configuration space at `offset`. - fn read_config(&self, offset: u64, data: &mut [u8]); + fn read_config(&self, _offset: u64, _data: &mut [u8]) { + warn!( + "No readable configuration fields for {}", + VirtioDeviceType::from(self.device_type()) + ); + } /// Writes to this device configuration space at `offset`. - fn write_config(&mut self, offset: u64, data: &[u8]); + fn write_config(&mut self, _offset: u64, _data: &[u8]) { + warn!( + "No writable configuration fields for {}", + VirtioDeviceType::from(self.device_type()) + ); + } /// Activates this device for real usage. fn activate(