Comment 6 for bug 1251590

Revision history for this message
Loganathan Parthipan (parthipan) wrote : Re: Live migration can leak root disk into ephemeral storage

{code}
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 440fe72..db7c6e6 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -4381,7 +4381,22 @@ class LibvirtDriver(driver.ComputeDriver):
                 image = self.image_backend.image(instance,
                                                  instance_disk,
                                                  CONF.libvirt.images_type)
- image.cache(fetch_func=libvirt_utils.fetch_image,
+ if cache_name.startswith('ephemeral'):
+ image.cache(fetch_func=self._create_ephemeral,
+ fs_label='ephemeral0',
+ os_type=instance["os_type"],
+ filename=cache_name,
+ size=info['virt_disk_size'],
+ ephemeral_size=instance['ephemeral_gb'])
+ elif cache_name.startswith('swap'):
+ inst_type = flavors.extract_flavor(instance)
+ swap_mb = inst_type['swap']
+ image.cache(fetch_func=self._create_swap,
+ filename="swap_%s" % swap_mb,
+ size=info['virt_disk_size'],
+ swap_mb=swap_mb)
+ else:
+ image.cache(fetch_func=libvirt_utils.fetch_image,
                             context=context,
                             filename=cache_name,
                             image_id=instance['image_ref'],
{code}