mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vm-migration: Add start_migration() to Migratable trait
In order to clearly decouple when the migration is started compared to when the dirty logging is started, we introduce a new method to the Migratable trait. This clarifies the semantics as we don't end up using start_dirty_log() for identifying when the migration has been started. And similarly, we rely on the already existing complete_migration() method to know when the migration has been ended. A bug was reported when running a local migration with a vhost-user-net device in server mode. The reason was because the migration_started variable was never set to "true", since the start_dirty_log() function was never invoked. Signed-off-by: lizhaoxin1 <Lxiaoyouling@163.com> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
committed by
Sebastien Boeuf
parent
a061bc32e4
commit
a45e458c50
@@ -4221,6 +4221,15 @@ impl Migratable for DeviceManager {
|
||||
Ok(MemoryRangeTable::new_from_tables(tables))
|
||||
}
|
||||
|
||||
fn start_migration(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
for (_, device_node) in self.device_tree.lock().unwrap().iter() {
|
||||
if let Some(migratable) = &device_node.migratable {
|
||||
migratable.lock().unwrap().start_migration()?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn complete_migration(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
for (_, device_node) in self.device_tree.lock().unwrap().iter() {
|
||||
if let Some(migratable) = &device_node.migratable {
|
||||
|
||||
@@ -1100,6 +1100,9 @@ impl Vmm {
|
||||
)));
|
||||
}
|
||||
|
||||
// Let every Migratable object know about the migration being started.
|
||||
vm.start_migration()?;
|
||||
|
||||
if send_data_migration.local {
|
||||
// Now pause VM
|
||||
vm.pause()?;
|
||||
|
||||
@@ -2675,6 +2675,11 @@ impl Migratable for Vm {
|
||||
]))
|
||||
}
|
||||
|
||||
fn start_migration(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.memory_manager.lock().unwrap().start_migration()?;
|
||||
self.device_manager.lock().unwrap().start_migration()
|
||||
}
|
||||
|
||||
fn complete_migration(&mut self) -> std::result::Result<(), MigratableError> {
|
||||
self.memory_manager.lock().unwrap().complete_migration()?;
|
||||
self.device_manager.lock().unwrap().complete_migration()
|
||||
|
||||
Reference in New Issue
Block a user