Skip disk compaction for plain disks
This commit is contained in:
parent
52d4514d6a
commit
b3c6ef9f6b
|
@ -114,6 +114,12 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
errs, errors.New("disk_type can only be expand, or plain"))
|
||||
}
|
||||
|
||||
if b.config.DiskType == "plain" && !b.config.SkipCompaction {
|
||||
b.config.SkipCompaction = true
|
||||
warnings = append(warnings,
|
||||
"'skip_compaction' is enforced to be true for plain disks.")
|
||||
}
|
||||
|
||||
if b.config.HardDriveInterface != "ide" && b.config.HardDriveInterface != "sata" && b.config.HardDriveInterface != "scsi" {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, errors.New("hard_drive_interface can only be ide, sata, or scsi"))
|
||||
|
|
|
@ -134,7 +134,7 @@ func TestBuilderPrepare_DiskType(t *testing.T) {
|
|||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Test a default boot_wait
|
||||
// Test a default disk_type
|
||||
delete(config, "disk_type")
|
||||
warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
|
@ -159,8 +159,21 @@ func TestBuilderPrepare_DiskType(t *testing.T) {
|
|||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test with a good
|
||||
// Test with plain disk with wrong setting for compaction
|
||||
config["disk_type"] = "plain"
|
||||
config["skip_compaction"] = false
|
||||
b = Builder{}
|
||||
warns, err = b.Prepare(config)
|
||||
if len(warns) == 0 {
|
||||
t.Fatalf("should have warning")
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
// Test with plain disk with correct setting for compaction
|
||||
config["disk_type"] = "plain"
|
||||
config["skip_compaction"] = true
|
||||
b = Builder{}
|
||||
warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
|
@ -169,6 +182,7 @@ func TestBuilderPrepare_DiskType(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_HardDriveInterface(t *testing.T) {
|
||||
|
|
|
@ -110,7 +110,8 @@ builder.
|
|||
image file is small initially and grows in size as you add data to it, and
|
||||
`plain` (plain disk) that the image file has a fixed size from the moment it
|
||||
is created (i.e the space is allocated for the drive fully). Plain disks
|
||||
perform faster than expanding disks.
|
||||
perform faster than expanding disks. `skip_compaction` will be set to true
|
||||
automatically for plain disks.
|
||||
|
||||
- `floppy_files` (array of strings) - A list of files to place onto a floppy
|
||||
disk that is attached when the VM is booted. This is most useful for
|
||||
|
@ -225,9 +226,10 @@ builder.
|
|||
"5m", or five minutes.
|
||||
|
||||
- `skip_compaction` (boolean) - Virtual disk image is compacted at the end of
|
||||
the build process using `prl_disk_tool` utility. In certain rare cases, this
|
||||
might corrupt the resulting disk image. If you find this to be the case,
|
||||
you can disable compaction using this configuration value.
|
||||
the build process using `prl_disk_tool` utility (except for the case that
|
||||
`disk_type` is set to `plain`). In certain rare cases, this might corrupt
|
||||
the resulting disk image. If you find this to be the case, you can disable
|
||||
compaction using this configuration value.
|
||||
|
||||
- `vm_name` (string) - This is the name of the PVM directory for the new
|
||||
virtual machine, without the file extension. By default this is
|
||||
|
|
Loading…
Reference in New Issue