Fix arithmetic in init/max mem ratio correction

Qubes Manager seems to try to guarantee that 10*init_mem is at
least max_mem by automatically adjusting init_mem to max_mem/10 if
inappropriate values are set. However, this may not guarantee that
10*init_mem >= max_mem due to rounding errors. This change fixes
these edge cases by basically rounding up the result of division
by 10.
This commit is contained in:
Aras Ergus 2019-08-17 15:42:36 +02:00
parent dde21e39ce
commit bbe14f524d
No known key found for this signature in database
GPG Key ID: 9AEA4479724BCBB2

View File

@ -551,7 +551,7 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
self.tr("Initial memory can not be less than one tenth "
"Max memory.<br>Setting initial memory to the minimum "
"allowed value."))
self.init_mem.setValue(self.max_mem_size.value() / 10)
self.init_mem.setValue((self.max_mem_size.value() + 9) // 10)
def check_warn_dispvmnetvm(self):
if not hasattr(self.vm, 'default_dispvm'):