From 4289b6459707b656e61ff06669a3ed4baf2433e0 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Wed, 15 Feb 2012 15:44:29 +0000 Subject: fix pre_block_migration() interaction with libvirt cache 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 --- nova/virt/libvirt/connection.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index b89b67372..60527a5ee 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -1909,24 +1909,19 @@ class LibvirtConnection(driver.ComputeDriver): 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. -- cgit