Skip to content

Commit

Permalink
fix pre_block_migration() interaction with libvirt cache
Browse files Browse the repository at this point in the history
Fixes bug 932179

* nova/virt/libvirt/connection (pre_block_migration):
Don't pass the 'ephemeral_gb' attribute as the size,
since this has the wrong units and is the wrong quantity
to pass anyway.  Also don't check for file existence,
or create the cow image as this is done within _cache_image()

Change-Id: Id723ec8d119dacd4660e88e546e05af417c736fc
  • Loading branch information
Pádraig Brady committed Feb 17, 2012
1 parent 55bc3d9 commit 4289b64
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions nova/virt/libvirt/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,24 +1909,19 @@ def pre_block_migration(self, ctxt, instance_ref, disk_info_json):
info['disk_size'])
else:
# Creating backing file follows same way as spawning instances.
backing_file = os.path.join(FLAGS.instances_path,
'_base', info['backing_file'])

cache_name = os.path.basename(info['backing_file'])
# Remove any size tags which the cache manages
cached_file = info['backing_file'].split('_')[0]

if not os.path.exists(backing_file):
self._cache_image(fn=libvirt_utils.fetch_image,
context=ctxt,
target=info['path'],
fname=cached_file,
cow=FLAGS.use_cow_images,
image_id=instance_ref['image_ref'],
user_id=instance_ref['user_id'],
project_id=instance_ref['project_id'],
size=instance_ref['ephemeral_gb'])

libvirt_utils.create_cow_image(backing_file, instance_disk)
cache_name = cache_name.split('_')[0]

self._cache_image(fn=libvirt_utils.fetch_image,
context=ctxt,
target=instance_disk,
fname=cache_name,
cow=FLAGS.use_cow_images,
image_id=instance_ref['image_ref'],
user_id=instance_ref['user_id'],
project_id=instance_ref['project_id'],
size=info['disk_size'])

# if image has kernel and ramdisk, just download
# following normal way.
Expand Down

0 comments on commit 4289b64

Please sign in to comment.