diff options
author | Cole Robinson <crobinso@redhat.com> | 2020-09-13 18:12:13 -0400 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2020-09-13 18:12:13 -0400 |
commit | 64222783d2d7f79d52ba83036c82de68c2e6ef3f (patch) | |
tree | c544c056d1455e1f0bba46fe1fd27f36d7a86271 | |
parent | 6657e23a7abd735650b4e3af3d61920d2fc6c318 (diff) | |
download | virt-manager-64222783d2d7f79d52ba83036c82de68c2e6ef3f.tar.gz |
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>
-rw-r--r-- | tests/uitests/test_addhardware.py | 8 | ||||
-rw-r--r-- | ui/addhardware.ui | 1 | ||||
-rw-r--r-- | virtManager/addhardware.py | 6 | ||||
-rw-r--r-- | virtManager/device/addstorage.py | 18 |
4 files changed, 24 insertions, 9 deletions
diff --git a/tests/uitests/test_addhardware.py b/tests/uitests/test_addhardware.py index 815b3d94..83c5486c 100644 --- a/tests/uitests/test_addhardware.py +++ b/tests/uitests/test_addhardware.py @@ -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") diff --git a/ui/addhardware.ui b/ui/addhardware.ui index 7719853c..2444341c 100644 --- a/ui/addhardware.ui +++ b/ui/addhardware.ui @@ -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> diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index e84f6066..8d814eab 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -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) diff --git a/virtManager/device/addstorage.py b/virtManager/device/addstorage.py index d0fcc587..155ee1c5 100644 --- a/virtManager/device/addstorage.py +++ b/virtManager/device/addstorage.py @@ -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 = [] |