summary refs log tree commit diff
path: root/arch
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-02-13 19:39:20 +0000
committerAlyssa Ross <hi@alyssa.is>2020-06-15 09:36:06 +0000
commit83c9638a44fb1d4b6952fad6ab77992d902576ea (patch)
tree105cb2a92f60934dd31af49bdb522cab6ba740be /arch
parentb8f316251bc594cb7d12e4bf0e383362944b5da3 (diff)
downloadcrosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.tar
crosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.tar.gz
crosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.tar.bz2
crosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.tar.lz
crosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.tar.xz
crosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.tar.zst
crosvm-83c9638a44fb1d4b6952fad6ab77992d902576ea.zip
arch: add public API for creating GuestMemory
For inter-guest communication, other processes need to be able to
access guest memory, without creating a VM.  GuestMemory, with its
list of memory regions, can't derive MsgOnSocket.  This means that
GuestMemory structs can't (easily) be shared over a socket.  However,
all that is required to create a GuestMemory is a size, and on x86_64,
a boolean has_bios field.

The architecture differences can be encapsulated in a struct.  It can
be opaque outside of architecture-specific crates, so the rest of the
code can remain architecture-independent.
Diffstat (limited to 'arch')
-rw-r--r--arch/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index 6dc3ab5..db31a9d 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -89,6 +89,14 @@ pub struct VirtioDeviceStub {
 pub trait LinuxArch {
     type Error: StdError;
 
+    /// Parameters affecting the accessible memory layouts for this architecture.
+    /// What exactly those parameters are should be considered an implementation
+    /// detail.
+    ///
+    /// `MemoryParams` is created from 'VmComponents`, but unlike `VmComponents` it
+    /// is `MsgOnSocket`, so it can be sent to device controller processes.
+    type MemoryParams;
+
     /// Takes `VmComponents` and generates a `RunnableLinuxVm`.
     ///
     /// # Arguments
@@ -113,6 +121,8 @@ pub trait LinuxArch {
             &EventFd,
         ) -> Result<Vec<(Box<dyn PciDevice>, Option<Minijail>)>, E>,
         E: StdError + 'static;
+
+    fn setup_memory(params: Self::MemoryParams) -> Result<GuestMemory, Self::Error>;
 }
 
 /// Errors for device manager.