settings: fix volume resize
- use MiB instead of MB - do not allow root volume resize for template-based VMs - do not resize if nothing was changed (use int, not float)
This commit is contained in:
parent
861d7c5413
commit
da23873b47
@ -295,15 +295,14 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
self.networking_groupbox.setEnabled(False)
|
self.networking_groupbox.setEnabled(False)
|
||||||
|
|
||||||
#max priv storage
|
#max priv storage
|
||||||
self.priv_img_size = self.vm.volumes['private'].size / 10**6
|
self.priv_img_size = self.vm.volumes['private'].size // 1024**2
|
||||||
self.max_priv_storage.setMinimum(self.priv_img_size)
|
self.max_priv_storage.setMinimum(self.priv_img_size)
|
||||||
self.max_priv_storage.setValue(self.priv_img_size)
|
self.max_priv_storage.setValue(self.priv_img_size)
|
||||||
|
|
||||||
self.root_img_size = self.vm.volumes['root'].size / 10**6
|
self.root_img_size = self.vm.volumes['root'].size // 1024**2
|
||||||
self.root_resize.setValue(self.root_img_size)
|
self.root_resize.setValue(self.root_img_size)
|
||||||
self.root_resize.setMinimum(self.root_img_size)
|
self.root_resize.setMinimum(self.root_img_size)
|
||||||
# self.root_resize.setEnabled(hasattr(self.vm, 'resize_root_img') and
|
self.root_resize.setEnabled(self.vm.volumes['root'].save_on_stop)
|
||||||
# not self.vm.template)
|
|
||||||
self.root_resize_label.setEnabled(self.root_resize.isEnabled())
|
self.root_resize_label.setEnabled(self.root_resize.isEnabled())
|
||||||
|
|
||||||
def __apply_basic_tab__(self):
|
def __apply_basic_tab__(self):
|
||||||
@ -366,7 +365,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
priv_size = self.max_priv_storage.value()
|
priv_size = self.max_priv_storage.value()
|
||||||
if self.priv_img_size != priv_size:
|
if self.priv_img_size != priv_size:
|
||||||
try:
|
try:
|
||||||
self.vm.volumes['private'].resize(priv_size * 10**6)
|
self.vm.volumes['private'].resize(priv_size * 1024**2)
|
||||||
self.anything_changed = True
|
self.anything_changed = True
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
msg.append(str(ex))
|
msg.append(str(ex))
|
||||||
@ -375,7 +374,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
|
|||||||
sys_size = self.root_resize.value()
|
sys_size = self.root_resize.value()
|
||||||
if self.root_img_size != sys_size:
|
if self.root_img_size != sys_size:
|
||||||
try:
|
try:
|
||||||
self.vm.volumes['root'].resize(priv_size * 10**6)
|
self.vm.volumes['root'].resize(priv_size * 1024**2)
|
||||||
self.anything_changed = True
|
self.anything_changed = True
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
msg.append(str(ex))
|
msg.append(str(ex))
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string>MB</string>
|
<string>MiB</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>1048576</number>
|
<number>1048576</number>
|
||||||
@ -131,7 +131,7 @@
|
|||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string>MB</string>
|
<string>MiB</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
Loading…
Reference in New Issue
Block a user