Comment 17 for bug 1251590

diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index bf7609f..6a1591c 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=cache_name,
+ 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 = swap_mb * unit.Mi
+ swap_mb=swap_mb)
+ else:
+ image.cache(fetch_func=libvirt_utils.fetch_image,
                             context=context,
                             filename=cache_name,
                             image_id=instance['image_ref'],