diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-06-12 23:29:28 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-06-12 23:29:28 +0000 |
| commit | 5dc070343cfc9356673ee792f3b1691f4e62fd0e (patch) | |
| tree | eae8d694726d4558838e339eb9fb40e7fe1d3f82 /nova/virt | |
| parent | 28e6bc7e82fc028899e1b83f4da760c5f4d98492 (diff) | |
| parent | 10c46619479e41e85b14343bd32159efda32775b (diff) | |
Merge "Fix race conditions with xenstore"
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index bf8aa3e52..0a21c0b5c 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -1095,6 +1095,7 @@ class VMOps(object): def inject_instance_metadata(self, instance, vm_ref): """Inject instance metadata into xenstore.""" + @utils.synchronized('xenstore-' + instance['uuid']) def store_meta(topdir, data_list): for item in data_list: key = self._sanitize_xenstore_key(item['key']) @@ -1108,9 +1109,8 @@ class VMOps(object): def change_instance_metadata(self, instance, diff): """Apply changes to instance metadata to xenstore.""" vm_ref = self._get_vm_opaque_ref(instance) - for key, change in diff.items(): - key = self._sanitize_xenstore_key(key) - location = 'vm-data/user-metadata/%s' % key + + def process_change(location, change): if change[0] == '-': self._remove_from_param_xenstore(vm_ref, location) try: @@ -1129,6 +1129,14 @@ class VMOps(object): # catch KeyError for domid if instance isn't running pass + @utils.synchronized('xenstore-' + instance['uuid']) + def update_meta(): + for key, change in diff.items(): + key = self._sanitize_xenstore_key(key) + location = 'vm-data/user-metadata/%s' % key + process_change(location, change) + update_meta() + def _find_root_vdi_ref(self, vm_ref): """Find and return the root vdi ref for a VM.""" if not vm_ref: @@ -1531,19 +1539,22 @@ class VMOps(object): vm_ref = vm_ref or self._get_vm_opaque_ref(instance) LOG.debug(_("Injecting network info to xenstore"), instance=instance) - for vif in network_info: - xs_data = self._vif_xenstore_data(vif) - location = ('vm-data/networking/%s' % - vif['address'].replace(':', '')) - self._add_to_param_xenstore(vm_ref, - location, - jsonutils.dumps(xs_data)) - try: - self._write_to_xenstore(instance, location, xs_data, - vm_ref=vm_ref) - except KeyError: - # catch KeyError for domid if instance isn't running - pass + @utils.synchronized('xenstore-' + instance['uuid']) + def update_nwinfo(): + for vif in network_info: + xs_data = self._vif_xenstore_data(vif) + location = ('vm-data/networking/%s' % + vif['address'].replace(':', '')) + self._add_to_param_xenstore(vm_ref, + location, + jsonutils.dumps(xs_data)) + try: + self._write_to_xenstore(instance, location, xs_data, + vm_ref=vm_ref) + except KeyError: + # catch KeyError for domid if instance isn't running + pass + update_nwinfo() def _create_vifs(self, vm_ref, instance, network_info): """Creates vifs for an instance.""" |
