details: Add support for disk discard option
This commit is contained in:
parent
6f301ba0aa
commit
d13b793bfa
|
@ -255,6 +255,30 @@
|
|||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label-storage-discard">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Discard mod_e:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">storage-discard</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="storage-discard">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
|
|
|
@ -3788,6 +3788,37 @@
|
|||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label-disk-discard">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="label" translatable="yes">Discard mod_e:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">discardmode-entry-box</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="disk-discard">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="has_entry">True</property>
|
||||
<signal name="changed" handler="on_disk_discard_combo_changed" swapped="no"/>
|
||||
<child internal-child="entry">
|
||||
<object class="GtkEntry" id="discardmode-entry-box">
|
||||
<property name="can_focus">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
|
|
|
@ -193,6 +193,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
self.build_disk_bus_combo(self.vm, self.widget("storage-bustype"))
|
||||
self._build_disk_device_combo()
|
||||
self.build_disk_cache_combo(self.vm, self.widget("storage-cache"))
|
||||
self.build_disk_discard_combo(self.vm, self.widget("storage-discard"))
|
||||
self.build_network_model_combo(self.vm, self.widget("net-model"))
|
||||
self._build_input_combo()
|
||||
self.build_sound_combo(self.vm, self.widget("sound-model"))
|
||||
|
@ -447,6 +448,13 @@ class vmmAddHardware(vmmGObjectUI):
|
|||
values.append([m, m])
|
||||
_build_combo(combo, values, sort=False)
|
||||
|
||||
@staticmethod
|
||||
def build_disk_discard_combo(_vm, combo):
|
||||
values = [[None, _("Hypervisor default")]]
|
||||
for m in DeviceDisk.discard_types:
|
||||
values.append([m, m])
|
||||
_build_combo(combo, values, sort=False)
|
||||
|
||||
@staticmethod
|
||||
def build_disk_bus_combo(_vm, combo):
|
||||
_build_combo(combo, [])
|
||||
|
|
|
@ -56,6 +56,7 @@ from .graphwidgets import Sparkline
|
|||
EDIT_DISK_REMOVABLE,
|
||||
EDIT_DISK_CACHE,
|
||||
EDIT_DISK_IO,
|
||||
EDIT_DISK_DISCARD,
|
||||
EDIT_DISK_BUS,
|
||||
EDIT_DISK_SERIAL,
|
||||
EDIT_DISK_FORMAT,
|
||||
|
@ -94,7 +95,7 @@ from .graphwidgets import Sparkline
|
|||
|
||||
EDIT_FS,
|
||||
|
||||
EDIT_HOSTDEV_ROMBAR) = range(1, 51)
|
||||
EDIT_HOSTDEV_ROMBAR) = range(1, 52)
|
||||
|
||||
|
||||
# Columns in hw list model
|
||||
|
@ -538,6 +539,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
"on_disk_removable_changed": lambda *x: self.enable_apply(x, EDIT_DISK_REMOVABLE),
|
||||
"on_disk_cache_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_CACHE),
|
||||
"on_disk_io_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_IO),
|
||||
"on_disk_discard_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_DISCARD),
|
||||
"on_disk_bus_combo_changed": lambda *x: self.enable_apply(x, EDIT_DISK_BUS),
|
||||
"on_disk_format_changed": self.disk_format_changed,
|
||||
"on_disk_serial_changed": lambda *x: self.enable_apply(x, EDIT_DISK_SERIAL),
|
||||
|
@ -1016,6 +1018,10 @@ class vmmDetails(vmmGObjectUI):
|
|||
model.append([m, m])
|
||||
combo.set_active(0)
|
||||
|
||||
# Discard combo
|
||||
combo = self.widget("disk-discard")
|
||||
vmmAddHardware.build_disk_discard_combo(self.vm, combo)
|
||||
|
||||
# Disk bus combo
|
||||
disk_bus = self.widget("disk-bus")
|
||||
vmmAddHardware.build_disk_bus_combo(self.vm, disk_bus)
|
||||
|
@ -2113,6 +2119,10 @@ class vmmDetails(vmmGObjectUI):
|
|||
if self.edited(EDIT_DISK_IO):
|
||||
kwargs["io"] = uiutil.get_list_selection(self.widget("disk-io"))
|
||||
|
||||
if self.edited(EDIT_DISK_DISCARD):
|
||||
kwargs["discard"] = uiutil.get_list_selection(
|
||||
self.widget("disk-discard"))
|
||||
|
||||
if self.edited(EDIT_DISK_FORMAT):
|
||||
kwargs["driver_type"] = self.widget("disk-format").get_text()
|
||||
|
||||
|
@ -2646,6 +2656,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
removable = disk.removable
|
||||
cache = disk.driver_cache
|
||||
io = disk.driver_io
|
||||
discard = disk.driver_discard
|
||||
driver_type = disk.driver_type or ""
|
||||
serial = disk.serial
|
||||
|
||||
|
@ -2688,6 +2699,7 @@ class vmmDetails(vmmGObjectUI):
|
|||
self.widget("disk-size").set_text(size)
|
||||
uiutil.set_list_selection(self.widget("disk-cache"), cache)
|
||||
uiutil.set_list_selection(self.widget("disk-io"), io)
|
||||
uiutil.set_list_selection(self.widget("disk-discard"), discard)
|
||||
|
||||
self.widget("disk-format").set_text(driver_type)
|
||||
self.widget("disk-format-warn").hide()
|
||||
|
|
|
@ -676,7 +676,8 @@ class vmmDomain(vmmLibvirtObject):
|
|||
def define_disk(self, devobj, do_hotplug,
|
||||
path=_SENTINEL, readonly=_SENTINEL, serial=_SENTINEL,
|
||||
shareable=_SENTINEL, removable=_SENTINEL, cache=_SENTINEL,
|
||||
io=_SENTINEL, driver_type=_SENTINEL, bus=_SENTINEL, addrstr=_SENTINEL,
|
||||
io=_SENTINEL, discard=_SENTINEL,
|
||||
driver_type=_SENTINEL, bus=_SENTINEL, addrstr=_SENTINEL,
|
||||
sgio=_SENTINEL):
|
||||
xmlobj = self._make_xmlobj_to_define()
|
||||
editdev = self._lookup_device_to_define(xmlobj, devobj, do_hotplug)
|
||||
|
@ -725,6 +726,8 @@ class vmmDomain(vmmLibvirtObject):
|
|||
editdev.driver_cache = cache or None
|
||||
if io != _SENTINEL:
|
||||
editdev.driver_io = io or None
|
||||
if discard != _SENTINEL:
|
||||
editdev.driver_discard = discard or None
|
||||
if driver_type != _SENTINEL:
|
||||
editdev.driver_type = driver_type or None
|
||||
if serial != _SENTINEL:
|
||||
|
|
Loading…
Reference in New Issue