virtManager: Only allow editing disk bus for new VM

This was proposed here:
https://www.redhat.com/archives/virt-tools-list/2019-June/msg00117.html

"""
* disk: bus editing: maybe keep this for the customize wizard, but
it should go away for existing disks, changing it for an existing VM is
definitely a 'shoot yourself in the foot' type of thing for most users
"""

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2020-01-25 16:04:12 -05:00
parent 7547905d79
commit 137b73df75
4 changed files with 157 additions and 149 deletions

View File

@ -227,15 +227,8 @@ class Details(uiutils.UITestCase):
tab.find("Shareable:", "check box").click()
tab.find("Readonly:", "check box").click()
tab.find("Advanced options", "toggle button").click_expander()
tab.find("Disk bus:", "text").text = "usb"
tab.find("Performance options", "toggle button").click_expander()
tab.find("Cache mode:", "text").text = "unsafe"
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)
# Device is now 'USB Disk 1'
c = hwlist.find("USB Disk 1", "table cell")
self.assertTrue(c.state_selected)
tab.find("Removable:", "check box").click()
tab.find("Discard mode:", "text").text = "unmap"
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)

View File

@ -195,6 +195,21 @@ class NewVM(uiutils.UITestCase):
addhw.find("Finish", "push button").click()
uiutils.check_in_loop(lambda: vmwindow.active)
# Select the new disk, change the bus to USB
vmwindow.find_fuzzy("IDE Disk 2", "table cell").click()
appl = vmwindow.find("config-apply", "push button")
hwlist = vmwindow.find("hw-list")
tab = vmwindow.find("disk-tab")
tab.find("Disk bus:", "text").text = "usb"
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)
# Device is now 'USB Disk 1'
c = hwlist.find("USB Disk 1", "table cell")
self.assertTrue(c.state_selected)
tab.find("Removable:", "check box").click()
appl.click()
uiutils.check_in_loop(lambda: not appl.sensitive)
# Start the install, close via the VM window
vmwindow.find_fuzzy("Begin Installation", "button").click()
uiutils.check_in_loop(lambda: newvm.showing is False)

View File

@ -2705,7 +2705,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -2719,7 +2719,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
@ -2732,7 +2732,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -2746,7 +2746,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">5</property>
</packing>
</child>
<child>
@ -2758,7 +2758,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
@ -2770,7 +2770,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
@ -2896,7 +2896,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
@ -2911,7 +2911,63 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">5</property>
<property name="top_attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="disk-bus-labeller">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Disk b_us:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">disk-bus-text</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkComboBox" id="disk-bus">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="has_entry">True</property>
<signal name="changed" handler="on_disk_bus_combo_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="disk-bus-text">
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="disk-bus-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">disk-bus-label</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
@ -2931,54 +2987,6 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkGrid" id="table11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">3</property>
<property name="column_spacing">8</property>
<child>
<object class="GtkLabel" id="label32">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Disk b_us:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">disk-bus-text</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="disk-bus">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<signal name="changed" handler="on_disk_bus_combo_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry" id="disk-bus-text">
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="expander8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="table19">
<property name="visible">True</property>
@ -3027,7 +3035,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
@ -3044,7 +3052,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
@ -3058,7 +3066,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
@ -3075,30 +3083,14 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label78">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Performance options</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
</object>

View File

@ -846,6 +846,12 @@ class vmmDetails(vmmGObjectUI):
# Disk bus combo
disk_bus = self.widget("disk-bus")
vmmAddHardware.build_disk_bus_combo(self.vm, disk_bus)
self.widget("disk-bus-label").set_visible(
not self.is_customize_dialog)
self.widget("disk-bus").set_visible(self.is_customize_dialog)
if not self.is_customize_dialog:
# Remove the mnemonic
self.widget("disk-bus-labeller").set_text(_("Disk bus:"))
# Network model
net_model = self.widget("network-model")
@ -2174,6 +2180,8 @@ class vmmDetails(vmmGObjectUI):
vmmAddHardware.populate_disk_bus_combo(self.vm, devtype,
self.widget("disk-bus").get_model())
uiutil.set_list_selection(self.widget("disk-bus"), bus)
self.widget("disk-bus-label").set_text(
vmmAddHardware.disk_pretty_bus(bus) or "-")
is_removable = disk.is_cdrom() or disk.is_floppy()
self.widget("disk-source-box").set_visible(is_removable)