mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-04 04:25:45 +00:00
vm-virtio: Implement userspace_mappings() for virtio-fs
This will help when we will implement the hot-unplug of the virtio-fs device, as we will have to remove correctly the userspace mappings associated with the device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
3fb0a02fa2
commit
b0353992d6
@ -6,8 +6,8 @@ use super::Error as DeviceError;
|
||||
use super::{Error, Result};
|
||||
use crate::vhost_user::handler::{VhostUserEpollConfig, VhostUserEpollHandler};
|
||||
use crate::{
|
||||
ActivateError, ActivateResult, Queue, VirtioDevice, VirtioDeviceType, VirtioInterrupt,
|
||||
VirtioSharedMemoryList, VIRTIO_F_VERSION_1,
|
||||
ActivateError, ActivateResult, Queue, UserspaceMapping, VirtioDevice, VirtioDeviceType,
|
||||
VirtioInterrupt, VirtioSharedMemoryList, VIRTIO_F_VERSION_1,
|
||||
};
|
||||
use libc::{self, c_void, off64_t, pread64, pwrite64, EFD_NONBLOCK};
|
||||
use std::cmp;
|
||||
@ -567,6 +567,21 @@ impl VirtioDevice for Fs {
|
||||
fn update_memory(&mut self, mem: &GuestMemoryMmap) -> std::result::Result<(), crate::Error> {
|
||||
update_mem_table(&mut self.vu, mem).map_err(crate::Error::VhostUserUpdateMemory)
|
||||
}
|
||||
|
||||
fn userspace_mappings(&self) -> Vec<UserspaceMapping> {
|
||||
let mut mappings = Vec::new();
|
||||
if let Some(cache) = self.cache.as_ref() {
|
||||
mappings.push(UserspaceMapping {
|
||||
host_addr: cache.0.host_addr,
|
||||
mem_slot: cache.0.mem_slot,
|
||||
addr: cache.0.addr,
|
||||
len: cache.0.len,
|
||||
mergeable: false,
|
||||
})
|
||||
}
|
||||
|
||||
mappings
|
||||
}
|
||||
}
|
||||
|
||||
virtio_pausable!(Fs);
|
||||
|
Loading…
Reference in New Issue
Block a user