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 <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2020-03-23 11:07:17 +01:00 committed by Rob Bradford
parent 93becca82a
commit bc874a9b6f
2 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -175,4 +175,5 @@ pub enum Error {
EpollCtl(io::Error),
EpollWait(io::Error),
FailedSignalingDriver(io::Error),
VhostUserUpdateMemory(vhost_user::Error),
}