diff options
| author | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-02-02 16:35:49 -0800 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@gmail.com> | 2012-02-07 15:32:15 -0800 |
| commit | 8f7bc2ee6c14fe6dc16d27353869a7a35f4931f0 (patch) | |
| tree | 62e6fc362a94fe835024d76b3352d17750c9f287 | |
| parent | 16882ad36b630fe8cc6c80a51cebf1a7f8f7cbf9 (diff) | |
| download | nova-8f7bc2ee6c14fe6dc16d27353869a7a35f4931f0.tar.gz nova-8f7bc2ee6c14fe6dc16d27353869a7a35f4931f0.tar.xz nova-8f7bc2ee6c14fe6dc16d27353869a7a35f4931f0.zip | |
Make swap default to vdb if there is no ephemeral
* Fixes bug 912066
Change-Id: Ie463a8953fd0ac07a9def0dd86379d06d9259bc5
| -rw-r--r-- | nova/virt/libvirt/connection.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 37ad07736..5400a4fbd 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -210,8 +210,8 @@ class LibvirtConnection(driver.ComputeDriver): else: self._disk_prefix = disk_prefix_map.get(FLAGS.libvirt_type, 'vd') self.default_root_device = self._disk_prefix + 'a' - self.default_ephemeral_device = self._disk_prefix + 'b' - self.default_swap_device = self._disk_prefix + 'c' + self.default_second_device = self._disk_prefix + 'b' + self.default_third_device = self._disk_prefix + 'c' self.image_cache_manager = imagecache.ImageCacheManager() @@ -988,7 +988,8 @@ class LibvirtConnection(driver.ComputeDriver): ephemeral_gb = instance['ephemeral_gb'] if ephemeral_gb and not self._volume_in_mapping( - self.default_ephemeral_device, block_device_info): + self.default_second_device, block_device_info): + swap_device = self.default_third_device fn = functools.partial(self._create_ephemeral, fs_label='ephemeral0', os_type=instance.os_type) @@ -998,6 +999,8 @@ class LibvirtConnection(driver.ComputeDriver): ("0", ephemeral_gb, instance.os_type), cow=FLAGS.use_cow_images, ephemeral_size=ephemeral_gb) + else: + swap_device = self.default_second_device for eph in driver.block_device_info_get_ephemerals(block_device_info): fn = functools.partial(self._create_ephemeral, @@ -1016,8 +1019,7 @@ class LibvirtConnection(driver.ComputeDriver): if driver.swap_is_usable(swap): swap_mb = swap['swap_size'] elif (inst_type['swap'] > 0 and - not self._volume_in_mapping(self.default_swap_device, - block_device_info)): + not self._volume_in_mapping(swap_device, block_device_info)): swap_mb = inst_type['swap'] if swap_mb > 0: @@ -1187,13 +1189,13 @@ class LibvirtConnection(driver.ComputeDriver): block_device_info) ephemeral_device = False - if not (self._volume_in_mapping(self.default_ephemeral_device, + if not (self._volume_in_mapping(self.default_second_device, block_device_info) or 0 in [eph['num'] for eph in driver.block_device_info_get_ephemerals( block_device_info)]): if instance['ephemeral_gb'] > 0: - ephemeral_device = self.default_ephemeral_device + ephemeral_device = self.default_second_device ephemerals = [] for eph in driver.block_device_info_get_ephemerals(block_device_info): @@ -1234,22 +1236,25 @@ class LibvirtConnection(driver.ComputeDriver): {'root_device_name': '/dev/' + self.default_root_device}) if ephemeral_device: + swap_device = self.default_third_device db.instance_update( nova_context.get_admin_context(), instance['id'], {'default_ephemeral_device': - '/dev/' + self.default_ephemeral_device}) + '/dev/' + self.default_second_device}) + else: + swap_device = self.default_second_device swap = driver.block_device_info_get_swap(block_device_info) if driver.swap_is_usable(swap): xml_info['swap_device'] = block_device.strip_dev( swap['device_name']) elif (inst_type['swap'] > 0 and - not self._volume_in_mapping(self.default_swap_device, + not self._volume_in_mapping(swap_device, block_device_info)): - xml_info['swap_device'] = self.default_swap_device + xml_info['swap_device'] = swap_device db.instance_update( nova_context.get_admin_context(), instance['id'], - {'default_swap_device': '/dev/' + self.default_swap_device}) + {'default_swap_device': '/dev/' + swap_device}) config_drive = False if instance.get('config_drive') or instance.get('config_drive_id'): |
