After setting not_wait_for_migration the kvm_vm.migration method returns control to parent function immediately after sending of migration command to qemu monitor. Signed-off-by: Jiří Župka <jzupka@xxxxxxxxxx> --- client/virt/kvm_vm.py | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py index 19d016f..62d9ce9 100644 --- a/client/virt/kvm_vm.py +++ b/client/virt/kvm_vm.py @@ -1784,7 +1784,8 @@ class VM(virt_vm.BaseVM): def migrate(self, timeout=MIGRATE_TIMEOUT, protocol="tcp", cancel_delay=None, offline=False, stable_check=False, clean=True, save_path="/tmp", dest_host="localhost", - remote_port=None, fd_src=None, fd_dst=None): + remote_port=None, not_wait_for_migration=False, + fd_src=None, fd_dst=None,): """ Migrate the VM. @@ -1805,6 +1806,8 @@ class VM(virt_vm.BaseVM): @save_path: The path for state files. @param dest_host: Destination host (defaults to 'localhost'). @param remote_port: Port to use for remote migration. + @param not_wait_for_migration: If True migration start but not wait till + the end of migration. @param fd_s: File descriptor for migration to which source VM write data. Descriptor is closed during the migration. @param fd_d: File descriptor for migration from which destination @@ -1818,7 +1821,7 @@ class VM(virt_vm.BaseVM): def mig_finished(): o = self.monitor.info("migrate") if isinstance(o, str): - return "status: active" not in o + return not "status: active" in o else: return o.get("status") != "active" @@ -1894,6 +1897,8 @@ class VM(virt_vm.BaseVM): logging.info("Migrating to %s", uri) self.monitor.migrate(uri) + if not_wait_for_migration: + return clone if cancel_delay: time.sleep(cancel_delay) @@ -1955,9 +1960,10 @@ class VM(virt_vm.BaseVM): finally: # If we're doing remote migration and it's completed successfully, # self points to a dead VM object - if self.is_alive(): - self.monitor.cmd("cont") - clone.destroy(gracefully=False) + if not not_wait_for_migration: + if self.is_alive(): + self.monitor.cmd("cont") + clone.destroy(gracefully=False) @error.context_aware -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html