mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-22 07:51:16 +00:00
virtio-devices: mem: Discard unplugged ranges only on activate()
In order to support correctly the snapshot/restore and migration use cases, we must be careful with the ranges that we discard by punching holes. On restore, there might be some ranges already plugged in, meaning they should not be discarded. That's why we loop over the list of blocks to discard only the ranges that are marked as unplugged. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
e390775bcb
commit
0fb24ea3ae
@ -997,7 +997,6 @@ impl VirtioDevice for Mem {
|
|||||||
) -> ActivateResult {
|
) -> ActivateResult {
|
||||||
self.common.activate(&queues, &queue_evts, &interrupt_cb)?;
|
self.common.activate(&queues, &queue_evts, &interrupt_cb)?;
|
||||||
let (kill_evt, pause_evt) = self.common.dup_eventfds();
|
let (kill_evt, pause_evt) = self.common.dup_eventfds();
|
||||||
let config = self.config.lock().unwrap();
|
|
||||||
let mut handler = MemEpollHandler {
|
let mut handler = MemEpollHandler {
|
||||||
host_addr: self.host_addr,
|
host_addr: self.host_addr,
|
||||||
host_fd: self.host_fd,
|
host_fd: self.host_fd,
|
||||||
@ -1014,12 +1013,20 @@ impl VirtioDevice for Mem {
|
|||||||
dma_mapping_handlers: Arc::clone(&self.dma_mapping_handlers),
|
dma_mapping_handlers: Arc::clone(&self.dma_mapping_handlers),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let unplugged_memory_ranges = self.blocks_state.lock().unwrap().memory_ranges(0, false);
|
||||||
|
for range in unplugged_memory_ranges.regions() {
|
||||||
handler
|
handler
|
||||||
.discard_memory_range(0, config.region_size)
|
.discard_memory_range(range.gpa, range.length)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
error!("failed discarding memory range: {:?}", e);
|
error!(
|
||||||
|
"failed discarding memory range [0x{:x}-0x{:x}]: {:?}",
|
||||||
|
range.gpa,
|
||||||
|
range.gpa + range.length - 1,
|
||||||
|
e
|
||||||
|
);
|
||||||
ActivateError::BadActivate
|
ActivateError::BadActivate
|
||||||
})?;
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
let paused = self.common.paused.clone();
|
let paused = self.common.paused.clone();
|
||||||
let paused_sync = self.common.paused_sync.clone();
|
let paused_sync = self.common.paused_sync.clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user