Merge pull request #9918 from hashicorp/fix_7408

skip compaction when backing file is used, to prevent conversion that…
This commit is contained in:
Megan Marsh 2020-09-14 13:09:13 -07:00 committed by GitHub
commit e00f6afff8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -174,7 +174,9 @@ type Config struct {
// and format is qcow2, set this option to true to create a new QCOW2
// file that uses the file located at iso_url as a backing file. The new file
// will only contain blocks that have changed compared to the backing file, so
// enabling this option can significantly reduce disk usage.
// enabling this option can significantly reduce disk usage. If true, Packer
// will force the `skip_compaction` also to be true as well to skip disk
// conversion which would render the backing file feature useless.
UseBackingFile bool `mapstructure:"use_backing_file" required:"false"`
// The type of machine emulation to use. Run your qemu binary with the
// flags `-machine help` to list available types for your system. This
@ -505,9 +507,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
b.config.DiskCompression = false
}
if b.config.UseBackingFile && !(b.config.DiskImage && b.config.Format == "qcow2") {
errs = packer.MultiErrorAppend(
errs, errors.New("use_backing_file can only be enabled for QCOW2 images and when disk_image is true"))
if b.config.UseBackingFile {
b.config.SkipCompaction = true
if !(b.config.DiskImage && b.config.Format == "qcow2") {
errs = packer.MultiErrorAppend(
errs, errors.New("use_backing_file can only be enabled for QCOW2 images and when disk_image is true"))
}
}
if b.config.DiskImage && len(b.config.AdditionalDiskSize) > 0 {

View file

@ -96,7 +96,9 @@
and format is qcow2, set this option to true to create a new QCOW2
file that uses the file located at iso_url as a backing file. The new file
will only contain blocks that have changed compared to the backing file, so
enabling this option can significantly reduce disk usage.
enabling this option can significantly reduce disk usage. If true, Packer
will force the `skip_compaction` also to be true as well to skip disk
conversion which would render the backing file feature useless.
- `machine_type` (string) - The type of machine emulation to use. Run your qemu binary with the
flags `-machine help` to list available types for your system. This