Merge pull request #461 from CMeza99/compress_qcow-no

Ability to create non-compressed QCOW
This commit is contained in:
Anders Ingemann 2018-02-12 08:27:06 +01:00 committed by GitHub
commit 3f58a35d95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 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)

View file

@ -0,0 +1,48 @@
---
name: debian-{system.release}-{system.architecture}-{%Y}{%m}{%d}
provider:
name: kvm
virtio:
- virtio
- virtio_pci
- virtio_balloon
- virtio_blk
- virtio_net
- virtio_ring
console: virtual
bootstrapper:
workspace: /target
system:
release: stretch
architecture: amd64
bootloader: grub
charmap: UTF-8
locale: en_US
timezone: UTC
packages:
components:
- main
- contrib
- non-free
install_standard: true
install:
- task-ssh-server
- cloud-init
- cloud-utils
volume:
backing: qcow2
partitions:
type: msdos
root:
filesystem: ext4
size: 2GiB
mountopts:
- defaults
- noatime
- errors=remount-ro
plugins:
minimize_size:
zerofree: true
shrink: qemu-img
apt:
autoclean: true