diff --git a/client-common/vm.py b/client-common/vm.py index 1afb1e53..33d30e2a 100644 --- a/client-common/vm.py +++ b/client-common/vm.py @@ -425,6 +425,9 @@ def move_vm(zk_conn, domain, target_node): common.stopZKConnection(zk_conn) return False, 'ERROR: VM "{}" is already running on node "{}".'.format(domain, current_node) + if not target_node: + return False, 'ERROR: Could not find a valid migration target for VM "{}".'.format(domain) + current_vm_state = zkhandler.readdata(zk_conn, '/domains/{}/state'.format(dom_uuid)) if current_vm_state == 'start': zkhandler.writedata(zk_conn, { @@ -485,6 +488,9 @@ def migrate_vm(zk_conn, domain, target_node, force_migrate, is_cli=False): common.stopZKConnection(zk_conn) return False, 'ERROR: VM "{}" is already running on node "{}".'.format(domain, current_node) + if not target_node: + return False, 'ERROR: Could not find a valid migration target for VM "{}".'.format(domain) + # Don't overwrite an existing last_node when using force_migrate if last_node and force_migrate: current_node = last_node