summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorRafi Khardalian <rafi@metacloud.com>2013-01-30 02:39:18 +0000
committerRafi Khardalian <rafi@metacloud.com>2013-01-30 15:32:27 +0000
commitb216ed51914986087ea7dee57bc29904fda001a0 (patch)
treeb6f96b913d7b3e9faaa0abc30dfeed0d6c5b8d62 /nova
parent05751bb7861892b949dedeccc283ce48abee0d16 (diff)
Add support for compressing qcow2 snapshots
Fixes bug 1109923 Adds a new configuration option: libvirt_snapshot_compression=False (Default) When set to True and the snapshot output format is qcow2, we pass the -c option into qemu-img, which enables compression. This patch also refactors the extract_image function to make construction of the whole qemu-img command more dynamic. Change-Id: I7a7ebcf41a91a8a9cb14be79e9bb79c22acb136e Flags: DocImpact
Diffstat (limited to 'nova')
-rwxr-xr-x[-rw-r--r--]nova/virt/libvirt/utils.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
index bd4ec685c..7bcc82f2b 100644..100755
--- a/nova/virt/libvirt/utils.py
+++ b/nova/virt/libvirt/utils.py
@@ -29,7 +29,15 @@ from nova.openstack.common import log as logging
from nova import utils
from nova.virt import images
+libvirt_opts = [
+ cfg.BoolOpt('libvirt_snapshot_compression',
+ default=False,
+ help='Compress snapshot images when possible. This '
+ 'currently applies exclusively to qcow2 images'),
+ ]
+
CONF = cfg.CONF
+CONF.register_opts(libvirt_opts)
CONF.import_opt('instances_path', 'nova.compute.manager')
LOG = logging.getLogger(__name__)
@@ -406,15 +414,18 @@ def extract_snapshot(disk_path, source_fmt, snapshot_name, out_path, dest_fmt):
if dest_fmt == 'iso':
dest_fmt = 'raw'
- qemu_img_cmd = ('qemu-img', 'convert', '-f', source_fmt, '-O',
- dest_fmt, '-s', snapshot_name, disk_path, out_path)
+ qemu_img_cmd = ('qemu-img', 'convert', '-f', source_fmt, '-O', dest_fmt)
+
+ # Conditionally enable compression of snapshots.
+ if CONF.libvirt_snapshot_compression and dest_fmt == "qcow2":
+ qemu_img_cmd += ('-c',)
# When snapshot name is omitted we do a basic convert, which
# is used by live snapshots.
- if snapshot_name is None:
- qemu_img_cmd = ('qemu-img', 'convert', '-f', source_fmt, '-O',
- dest_fmt, disk_path, out_path)
+ if snapshot_name is not None:
+ qemu_img_cmd += ('-s', snapshot_name)
+ qemu_img_cmd += (disk_path, out_path)
execute(*qemu_img_cmd)