From bc874a9b6f2049111fb9db3cdf422b342cbfe4ea Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Mon, 23 Mar 2020 11:07:17 +0100 Subject: [PATCH] vm-virtio: Add update_memory() to VirtioDevice trait The virtio devices backed by a vhost-user backend must send an update to the associated backend with the new file descriptors corresponding to the memory regions. This patch allows such devices to be notified when such update needs to happen. Signed-off-by: Sebastien Boeuf --- vm-virtio/src/device.rs | 6 +++++- vm-virtio/src/lib.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vm-virtio/src/device.rs b/vm-virtio/src/device.rs index 27d22d51d..a5d7699f8 100644 --- a/vm-virtio/src/device.rs +++ b/vm-virtio/src/device.rs @@ -6,7 +6,7 @@ // // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause -use super::*; +use crate::{ActivateResult, Error, Queue}; use std::sync::Arc; use vm_memory::{GuestAddress, GuestMemoryAtomic, GuestMemoryMmap, GuestUsize}; use vmm_sys_util::eventfd::EventFd; @@ -106,6 +106,10 @@ pub trait VirtioDevice: Send { /// every device as part of shutting down the VM. Acting on the device /// after a shutdown() can lead to unpredictable results. fn shutdown(&mut self) {} + + fn update_memory(&mut self, _mem: &GuestMemoryMmap) -> std::result::Result<(), Error> { + Ok(()) + } } /// Trait providing address translation the same way a physical DMA remapping diff --git a/vm-virtio/src/lib.rs b/vm-virtio/src/lib.rs index 7d0bb2794..b96ced73a 100755 --- a/vm-virtio/src/lib.rs +++ b/vm-virtio/src/lib.rs @@ -175,4 +175,5 @@ pub enum Error { EpollCtl(io::Error), EpollWait(io::Error), FailedSignalingDriver(io::Error), + VhostUserUpdateMemory(vhost_user::Error), }