From 70129ed19db187cc90f74abd5c93c86098d29c27 Mon Sep 17 00:00:00 2001 From: Boris Filippov Date: Mon, 2 Jul 2012 23:32:01 +0400 Subject: 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 --- nova/tests/test_virt_drivers.py | 3 ++- nova/virt/libvirt/driver.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index cafbd6818..2bd911907 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -79,7 +79,8 @@ class _FakeDriverBackendTestCase(test.TestCase): 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 diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 3a5a52b79..3a679af65 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -176,6 +176,10 @@ libvirt_opts = [ 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 @@ class LibvirtDriver(driver.ComputeDriver): 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, -- cgit