diff --git a/XenAdmin/Controls/Ballooning/VMMemoryControlsAdvanced.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsAdvanced.cs index fa748281b..eeb0cf89e 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsAdvanced.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsAdvanced.cs @@ -98,7 +98,7 @@ namespace XenAdmin.Controls.Ballooning private void SetIncrements() { - memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = memorySpinnerStatMax.Increment = CalcIncrement(memorySpinnerDynMax.Units); + memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = memorySpinnerStatMax.Increment = CalcIncrement(static_max, memorySpinnerDynMax.Units); } private void Spinners_ValueChanged(object sender, EventArgs e) diff --git a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs index 8b20d3ee8..c807255a8 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsBasic.cs @@ -175,7 +175,7 @@ namespace XenAdmin.Controls.Ballooning private void SetIncrements() { - vmShinyBar.Increment = memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = memorySpinnerFixed.Increment = CalcIncrement(memorySpinnerDynMax.Units); + vmShinyBar.Increment = memorySpinnerDynMin.Increment = memorySpinnerDynMax.Increment = memorySpinnerFixed.Increment = CalcIncrement(static_max, memorySpinnerDynMax.Units); } private void DynamicSpinners_ValueChanged(object sender, EventArgs e) diff --git a/XenAdmin/Controls/Ballooning/VMMemoryControlsEdit.cs b/XenAdmin/Controls/Ballooning/VMMemoryControlsEdit.cs index 6e9584065..686b4236c 100644 --- a/XenAdmin/Controls/Ballooning/VMMemoryControlsEdit.cs +++ b/XenAdmin/Controls/Ballooning/VMMemoryControlsEdit.cs @@ -214,14 +214,15 @@ namespace XenAdmin.Controls.Ballooning } } - protected double CalcIncrement(string units) + public static double CalcIncrement(double static_max, string units) { if (units == "MB") { - // Calculate a suitable increment for dynamic_min and dynamic_max, if static_max small - int i; - for (i = 1; i < static_max / Util.BINARY_MEGA / 8 && i < 128; i *= 2) - ; + // Calculate a suitable increment if the static_max is small + int i = 1; + while (i < static_max / Util.BINARY_MEGA / 8 && i < 128) + i *= 2; + return i * Util.BINARY_MEGA; } else diff --git a/XenAdmin/Wizards/NewVMWizard/Page_CpuMem.cs b/XenAdmin/Wizards/NewVMWizard/Page_CpuMem.cs index 117e76ecf..5f1488e46 100644 --- a/XenAdmin/Wizards/NewVMWizard/Page_CpuMem.cs +++ b/XenAdmin/Wizards/NewVMWizard/Page_CpuMem.cs @@ -109,7 +109,7 @@ namespace XenAdmin.Wizards.NewVMWizard comboBoxTopology.Populate(Template.VCPUs_at_startup, Template.VCPUs_max, Template.CoresPerSocket, Template.MaxCoresPerSocket); PopulateVCPUs(Template.MaxVCPUsAllowed, Template.VCPUs_at_startup); - SetSpinnerLimits(); + SetSpinnerLimitsAndIncrement(); ValuesUpdated(); @@ -153,8 +153,10 @@ namespace XenAdmin.Wizards.NewVMWizard spinnerStatMax.SetRange(0, maxMemAllowed); } - private void SetSpinnerLimits() + private void SetSpinnerLimitsAndIncrement() { + spinnerDynMin.Increment = spinnerDynMax.Increment = spinnerStatMax.Increment = VMMemoryControlsEdit.CalcIncrement(Template.memory_static_max, spinnerDynMin.Units); + long maxMemAllowed = MaxMemAllowed; double min = Template.memory_static_min; if (memoryMode == 1) @@ -329,7 +331,7 @@ namespace XenAdmin.Wizards.NewVMWizard if (initialising) return; - SetSpinnerLimits(); + SetSpinnerLimitsAndIncrement(); ValuesUpdated(); }