Fix rebuild with volumes attached

This patch assumes that the correct behavior for instance rebuild is to
maintain attached volumes across a rebuild operation.

Two important changes are:

1) Detaching all volumes during a rebuild so that they won't be 'in-use'
   when prep_block_devices is called to reattach them.

2) xenapi: Allowing additional volumes, not just root volumes, to be
   attached before boot. To handle this, we cycle through all
   block-device-mappings, not just the root-device, create the VDI, and
   later, create the VBD.

Small changes include:

* Using `connection_data` instead of `dev_params` (to match other parts of
  the code base)

* Renaming `get_vdis_for_boot_from_vol` to `get_vdi_uuid_for_volume` to
  reflect its more general and simpler semantics.

Fixes bug 1071547

Change-Id: Ie54a16be4bae2a718ed7d506f32777d0847b9089
This commit is contained in:
Rick Harris
2013-01-29 07:26:48 +00:00
parent 0657cd3e20
commit 462008ea13
2 changed files with 20 additions and 23 deletions

View File

@@ -149,23 +149,20 @@ def match_device(device):
return match.groups()
def volume_in_mapping(mount_device, block_device_info, strip=strip_dev):
# FIXME(sirp): xen uses strip_prefix to be mountpoint agnostic. There is
# probably a better way to handle this so that strip_dev can be used
# exclusively.
block_device_list = [strip(vol['mount_device'])
def volume_in_mapping(mount_device, block_device_info):
block_device_list = [strip_dev(vol['mount_device'])
for vol in
driver.block_device_info_get_mapping(
block_device_info)]
swap = driver.block_device_info_get_swap(block_device_info)
if driver.swap_is_usable(swap):
block_device_list.append(strip(swap['device_name']))
block_device_list.append(strip_dev(swap['device_name']))
block_device_list += [strip(ephemeral['device_name'])
block_device_list += [strip_dev(ephemeral['device_name'])
for ephemeral in
driver.block_device_info_get_ephemerals(
block_device_info)]
LOG.debug(_("block_device_list %s"), block_device_list)
return strip(mount_device) in block_device_list
return strip_dev(mount_device) in block_device_list