mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vhost_user_backend: Provide some default trait implementations
We cannot expect every backend to support GET_CONFIG and SET_CONFIG commands. That's why this patch adds some default implementations for the trait VhostUserBackend regarding both get_config() and set_config() functions. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -85,10 +85,18 @@ pub trait VhostUserBackend: Send + Sync + 'static {
|
|||||||
) -> result::Result<u32, io::Error>;
|
) -> result::Result<u32, io::Error>;
|
||||||
|
|
||||||
/// Get virtio device configuration.
|
/// Get virtio device configuration.
|
||||||
fn get_config(&self, offset: u32, size: u32) -> Vec<u8>;
|
/// A default implementation is provided as we cannot expect all backends
|
||||||
|
/// to implement this function.
|
||||||
|
fn get_config(&self, offset: u32, size: u32) -> Vec<u8> {
|
||||||
|
Vec::new()
|
||||||
|
}
|
||||||
|
|
||||||
/// Set virtio device configuration.
|
/// Set virtio device configuration.
|
||||||
fn set_config(&mut self, offset: u32, buf: &[u8]) -> result::Result<(), io::Error>;
|
/// A default implementation is provided as we cannot expect all backends
|
||||||
|
/// to implement this function.
|
||||||
|
fn set_config(&mut self, offset: u32, buf: &[u8]) -> result::Result<(), io::Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This structure is the public API the backend is allowed to interact with
|
/// This structure is the public API the backend is allowed to interact with
|
||||||
|
|||||||
Reference in New Issue
Block a user