mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: Rename address translation function for more clarity
Renaming translate() to translate_gva() to clarify we want to translate a GVA address into a GPA. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -94,19 +94,18 @@ impl fmt::Display for VirtioDeviceType {
|
||||
/// Trait for devices with access to data in memory being limited and/or
|
||||
/// translated.
|
||||
pub trait AccessPlatform: Send + Sync + Debug {
|
||||
/// Provide a way to translate address ranges.
|
||||
fn translate(&self, base: u64, size: u64) -> std::result::Result<u64, std::io::Error>;
|
||||
/// Provide a way to translate GVA address ranges into GPAs.
|
||||
fn translate_gva(&self, base: u64, size: u64) -> std::result::Result<u64, std::io::Error>;
|
||||
}
|
||||
|
||||
pub trait Translatable {
|
||||
#[must_use]
|
||||
fn translate(&self, access_platform: Option<&Arc<dyn AccessPlatform>>, len: usize) -> Self;
|
||||
fn translate_gva(&self, access_platform: Option<&Arc<dyn AccessPlatform>>, len: usize) -> Self;
|
||||
}
|
||||
|
||||
impl Translatable for GuestAddress {
|
||||
fn translate(&self, access_platform: Option<&Arc<dyn AccessPlatform>>, len: usize) -> Self {
|
||||
fn translate_gva(&self, access_platform: Option<&Arc<dyn AccessPlatform>>, len: usize) -> Self {
|
||||
if let Some(access_platform) = access_platform {
|
||||
GuestAddress(access_platform.translate(self.0, len as u64).unwrap())
|
||||
GuestAddress(access_platform.translate_gva(self.0, len as u64).unwrap())
|
||||
} else {
|
||||
*self
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user