addhardware: Allow settings USB removable setting

We need to update addstorage when the user changes the bus setting

Fixes: #148

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-09-13 18:12:13 -04:00
parent 6657e23a7a
commit 64222783d2
4 changed files with 24 additions and 9 deletions

View File

@ -159,6 +159,14 @@ class AddHardware(lib.testcase.UITestCase):
tab.find("GiB", "spin button").set_text("1.5")
self._finish(addhw, check=details)
# USB disk with removable setting
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Storage", "storage-tab")
tab.combo_select("Bus type:", "USB")
tab.find("Advanced options", "toggle button").click_expander()
tab.find("Removable:", "check box").click()
self._finish(addhw, check=details)
# Managed storage tests
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Storage", "storage-tab")

View File

@ -199,6 +199,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<signal name="changed" handler="on_storage_bustype_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>

View File

@ -91,6 +91,7 @@ class vmmAddHardware(vmmGObjectUI):
"on_hw_list_changed": self._hw_selected_cb,
"on_storage_devtype_changed": self._change_storage_devtype,
"on_storage_bustype_changed": self._storage_bus_changed_cb,
"on_mac_address_clicked": self._change_macaddr_use,
@ -1081,6 +1082,11 @@ class vmmAddHardware(vmmGObjectUI):
if not allow_create:
self.addstorage.widget("storage-select").set_active(True)
def _storage_bus_changed_cb(self, src):
bus = uiutil.get_list_selection(
self.widget("storage-bustype"))
self.addstorage.set_disk_bus(bus)
def _change_macaddr_use(self, ignore=None):
if self.widget("mac-address").get_active():
self.widget("create-mac-address").set_sensitive(True)

View File

@ -244,6 +244,9 @@ class vmmAddStorage(vmmGObjectUI):
disk.shareable = vals.get("shareable")
if vals.get("serial") is not None:
disk.serial = vals.get("serial")
if (vals.get("removable") is not None and
self.widget("disk-removable").get_visible()):
disk.removable = vals.get("removable")
if disk.wants_storage_creation():
pool = disk.get_parent_pool()
@ -290,6 +293,11 @@ class vmmAddStorage(vmmGObjectUI):
# Device editing #
##################
def set_disk_bus(self, bus):
show_removable = (bus == "usb")
uiutil.set_grid_row_visible(
self.widget("disk-removable"), show_removable)
def set_dev(self, disk):
cache = disk.driver_cache
discard = disk.driver_discard
@ -299,13 +307,7 @@ class vmmAddStorage(vmmGObjectUI):
removable = disk.removable
serial = disk.serial
is_usb = (disk.bus == "usb")
can_set_removable = (is_usb and (self.conn.is_qemu() or
self.conn.is_test()))
if removable is None:
removable = False
else:
can_set_removable = True
self.set_disk_bus(disk.bus)
uiutil.set_list_selection(self.widget("disk-cache"), cache)
uiutil.set_list_selection(self.widget("disk-discard"), discard)
@ -317,8 +319,6 @@ class vmmAddStorage(vmmGObjectUI):
self.widget("disk-readonly").set_sensitive(not disk.is_cdrom())
self.widget("disk-shareable").set_active(share)
self.widget("disk-removable").set_active(removable)
uiutil.set_grid_row_visible(
self.widget("disk-removable"), can_set_removable)
# This comes last
self._active_edits = []