From 6acdb9d1488be7425cac9f992ae58693554c908c Mon Sep 17 00:00:00 2001 From: Patrick Lang Date: Thu, 21 Sep 2017 14:51:38 -0700 Subject: [PATCH] Disabling automatic checkpoints Signed-off-by: Patrick Lang --- common/powershell/hyperv/hyperv.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/powershell/hyperv/hyperv.go b/common/powershell/hyperv/hyperv.go index 6e2b9dc7e..09a5ae373 100644 --- a/common/powershell/hyperv/hyperv.go +++ b/common/powershell/hyperv/hyperv.go @@ -213,10 +213,27 @@ New-VM -Name $vmName -Path $path -MemoryStartupBytes $memoryStartupBytes -NewVHD return err } + err = DisableAutomaticCheckpoints(vmName) + + if err != nil { + return err + } + return DeleteAllDvdDrives(vmName) } } +func DisableAutomaticCheckpoints(vmName string) error { + var script = ` +param([string]$vmName) +if ((Get-Command Set-Vm).Parameters["AutomaticCheckpointsEnabled"]) { + Set-Vm -Name $vmName -AutomaticCheckpointsEnabled $false } +` + var ps powershell.PowerShellCmd + err := ps.Run(script, vmName) + return err +} + func SetVirtualMachineCpuCount(vmName string, cpu uint) error { var script = `