From 9482f351fc3bb2e2c26b26f4dd138d1a48768174 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 13 Jun 2018 13:27:11 -0700 Subject: [PATCH] Validate maxmemory setting within Hyper-V provider Forces an error if maxmemory value is less than the configured minimum or startup memory. Fixes #9477 --- .../providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 b/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 index 7da5c5bf5..b555a0797 100644 --- a/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +++ b/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 @@ -368,6 +368,12 @@ function Set-VagrantVMMemory { } if($DynamicMemory) { + if($MemoryMaximumBytes < $MemoryMinimumBytes) { + throw "Maximum memory value is less than required minimum memory value." + } else if ($MemoryMaximumBytes < $MemoryStartupBytes) { + throw "Maximum memory value is less than configured startup memory value." + } + Hyper-V\Set-VM -VM $VM -DynamicMemory Hyper-V\Set-VM -VM $VM -MemoryMinimumBytes $MemoryMinimumBytes -MemoryMaximumBytes ` $MemoryMaximumBytes -MemoryStartupBytes $MemoryStartupBytes