diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-03-07 16:46:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-03-07 16:46:31 +0000 |
| commit | 871d5649c23d840923732e592dbb92baa02bc2fc (patch) | |
| tree | 1a327326c93292df73375ebfef42ef8ddd46decc /nova/virt | |
| parent | d8324bb3d089acd444bd1639a3efc07e89556f69 (diff) | |
| parent | ec20076d24455860b38fd9a143910f75741ac8f6 (diff) | |
Merge "bug 944145: race condition causes VM's state to be SHUTOFF"
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/host.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 4069c484a..8de7a722a 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -23,6 +23,7 @@ import logging import json import random +from nova.compute import vm_states from nova import context from nova import db from nova import exception @@ -73,17 +74,22 @@ class Host(object): instance = db.instance_get_by_uuid(ctxt, uuid) vm_counter = vm_counter + 1 + dest = _host_find(ctxt, self._session, host, host_ref) + db.instance_update(ctxt, instance.id, + {'host': dest, + 'vm_state': vm_states.MIGRATING}) self._session.call_xenapi('VM.pool_migrate', vm_ref, host_ref, {}) - new_host = _host_find(ctxt, self._session, - host, host_ref) - db.instance_update(ctxt, - instance.id, {'host': new_host}) migrations_counter = migrations_counter + 1 + db.instance_update(ctxt, instance.id, + {'vm_state': vm_states.ACTIVE}) break except self.XenAPI.Failure: LOG.exception('Unable to migrate VM %(vm_ref)s' 'from %(host)s' % locals()) + db.instance_update(ctxt, instance.id, + {'host': host, + 'vm_state': vm_states.ACTIVE}) if vm_counter == migrations_counter: return 'on_maintenance' else: |
