expose ability to no compress qcow

This commit is contained in:
Carlos Meza 2018-02-11 22:01:14 +00:00
parent f05c2650d1
commit d31cc3a34c
3 changed files with 6 additions and 3 deletions

View file

@ -16,6 +16,8 @@ def get_shrink_type(plugins):
shrink_type = 'vmware-vdiskmanager'
elif shrink_type is False:
shrink_type = None
elif shrink_type == 'qemu-img-no-compression':
shrink_type = 'qemu-img'
return shrink_type

View file

@ -8,7 +8,7 @@ properties:
shrink:
anyOf:
- type: boolean
- enum: [vmware-vdiskmanager, qemu-img]
- enum: [vmware-vdiskmanager, qemu-img, qemu-img-no-compression]
zerofree:
type: boolean
apt:

View file

@ -71,8 +71,9 @@ class ShrinkVolumeWithQemuImg(Task):
def run(cls, info):
tmp_name = os.path.join(info.workspace, 'shrunk.' + info.volume.extension)
shrink_cmd = ['qemu-img', 'convert', '-O', info.volume.extension, info.volume.image_path, tmp_name]
# Compress QCOW2 image when shrinking
if info.volume.extension == 'qcow2':
# Compress QCOW2 image when shrinking except when explicitly set not to
if (info.volume.extension == 'qcow2' and
info.manifest.plugins['minimize_size']['shrink'] != 'qemu-img-no-compression'):
# '-c' indicates that target image must be compressed (qcow format only)
shrink_cmd.insert(4, '-c')
log_check_call(shrink_cmd)