Permalink
Browse files

Make possible to store snapshots not in /tmp directory

Add option libvirt_snapshots_directory which specifies path
where snapshots will be stored before libvirt driver uploads
them to the image service.

VM disk snapshot can be quite large,
so keeping them in /tmp is not desirable. Fedora 18 will move /tmp
to tmpfs in RAM, so snapshot functionality will become unusable with
current nova behavior.

Default path for snapshots directory is set to $instances_path/snapshots
in this patch. In case, when shared filesystem is used to hold instances,
option value can be adjusted to improve performance.

Change-Id: I9458a2a26a619a01fa1ddb6955c0220ca747e64d
  • Loading branch information...
1 parent 1a7d6a0 commit 70129ed19db187cc90f74abd5c93c86098d29c27 @frenzykryger frenzykryger committed Jul 2, 2012
Showing with 9 additions and 2 deletions.
  1. +2 −1 nova/tests/test_virt_drivers.py
  2. +7 −1 nova/virt/libvirt/driver.py
@@ -79,7 +79,8 @@ def _setup_fakelibvirt(self):
self.flags(firewall_driver=nova.virt.libvirt.firewall.drivers[0],
rescue_image_id="2",
rescue_kernel_id="3",
- rescue_ramdisk_id=None)
+ rescue_ramdisk_id=None,
+ libvirt_snapshots_directory='./')
def fake_extend(image, size):
pass
@@ -176,6 +176,10 @@
help='Set to a named libvirt CPU model (see names listed '
'in /usr/share/libvirt/cpu_map.xml). Only has effect if '
'libvirt_cpu_mode="custom" and libvirt_type="kvm|qemu"'),
+ cfg.StrOpt('libvirt_snapshots_directory',
+ default='$instances_path/snapshots',
+ help='Location where libvirt driver will store snapshots '
+ 'before uploading them to image service'),
]
FLAGS = flags.FLAGS
@@ -791,7 +795,9 @@ def snapshot(self, context, instance, image_href):
libvirt_utils.create_snapshot(disk_path, snapshot_name)
# Export the snapshot to a raw image
- with utils.tempdir() as tmpdir:
+ snapshot_directory = FLAGS.libvirt_snapshots_directory
+ libvirt_utils.ensure_tree(snapshot_directory)
+ with utils.tempdir(dir=snapshot_directory) as tmpdir:
try:
out_path = os.path.join(tmpdir, snapshot_name)
libvirt_utils.extract_snapshot(disk_path, source_format,

0 comments on commit 70129ed

Please sign in to comment.