From 83c9638a44fb1d4b6952fad6ab77992d902576ea Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Thu, 13 Feb 2020 19:39:20 +0000 Subject: 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. --- arch/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'arch') 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, Option)>, E>, E: StdError + 'static; + + fn setup_memory(params: Self::MemoryParams) -> Result; } /// Errors for device manager. -- cgit 1.4.1