mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: vhost_user: Shutdown communication after migration
During a migration, the vhost-user device talks to the backend to retrieve the dirty pages. Once done with this, a snapshot will be taken, meaning there's no need to communicate with the backend anymore. Closing the communication is needed to let the destination VM being able to connect to the same backend. That's why we shutdown the communication with the backend in case a migration has been started and we're asked for a snapshot. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -116,6 +116,7 @@ pub struct Net {
|
||||
epoll_thread: Option<thread::JoinHandle<()>>,
|
||||
seccomp_action: SeccompAction,
|
||||
vu_num_queues: usize,
|
||||
migration_started: bool,
|
||||
}
|
||||
|
||||
impl Net {
|
||||
@@ -208,6 +209,7 @@ impl Net {
|
||||
epoll_thread: None,
|
||||
seccomp_action,
|
||||
vu_num_queues,
|
||||
migration_started: false,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -495,7 +497,13 @@ impl Snapshottable for Net {
|
||||
}
|
||||
|
||||
fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> {
|
||||
Snapshot::new_from_versioned_state(&self.id(), &self.state())
|
||||
let snapshot = Snapshot::new_from_versioned_state(&self.id(), &self.state())?;
|
||||
|
||||
if self.migration_started {
|
||||
self.shutdown();
|
||||
}
|
||||
|
||||
Ok(snapshot)
|
||||
}
|
||||
|
||||
fn restore(&mut self, snapshot: Snapshot) -> std::result::Result<(), MigratableError> {
|
||||
@@ -507,6 +515,7 @@ impl Transportable for Net {}
|
||||
|
||||
impl Migratable for Net {
|
||||
fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.migration_started = true;
|
||||
if let Some(vu) = &self.vu {
|
||||
if let Some(guest_memory) = &self.guest_memory {
|
||||
let last_ram_addr = guest_memory.memory().last_addr().raw_value();
|
||||
@@ -530,6 +539,7 @@ impl Migratable for Net {
|
||||
}
|
||||
|
||||
fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.migration_started = false;
|
||||
if let Some(vu) = &self.vu {
|
||||
vu.lock().unwrap().stop_dirty_log().map_err(|e| {
|
||||
MigratableError::StopDirtyLog(anyhow!(
|
||||
|
||||
Reference in New Issue
Block a user