vmm: Share the guest memory instead of cloning it

The VMM guest memory was cloned (copied) everywhere the code needed to
have ownership of it. In order to clean the code, and in anticipation
for future support of modifying this guest memory instance at runtime,
it is important that every part of the code share the same instance.

Because VirtioDevice implementations need to have access to it from
different threads, that's why Arc must be used in this case.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2019-08-20 14:12:00 -07:00
committed by Rob Bradford
parent f4d41d600b
commit ec0b5567c8
11 changed files with 40 additions and 32 deletions
+2 -2
View File
@@ -54,7 +54,7 @@ unsafe impl ByteValued for VirtioConsoleConfig {}
struct ConsoleEpollHandler {
queues: Vec<Queue>,
mem: GuestMemoryMmap,
mem: Arc<GuestMemoryMmap>,
interrupt_cb: Arc<VirtioInterrupt>,
in_buffer: Arc<Mutex<VecDeque<u8>>>,
out: Box<dyn io::Write + Send>,
@@ -432,7 +432,7 @@ impl VirtioDevice for Console {
fn activate(
&mut self,
mem: GuestMemoryMmap,
mem: Arc<GuestMemoryMmap>,
interrupt_cb: Arc<VirtioInterrupt>,
queues: Vec<Queue>,
mut queue_evts: Vec<EventFd>,