addhardware: Move controller list logic to virtinst

And tweak the UI defaults a bit, preferring virtio-scsi and
usb3
This commit is contained in:
Cole Robinson 2018-09-06 16:05:12 -04:00
parent 7994dc90c8
commit a09a46289a
4 changed files with 37 additions and 29 deletions

View File

@ -43,7 +43,7 @@ class AddHardware(uiutils.UITestCase):
# Default SCSI
tab = self._select_hw(addhw, "Controller", "controller-tab")
typ = tab.find("Type:", "combo box")
typ.click()
typ.click_combo_entry()
tab.find("SCSI", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
@ -51,7 +51,7 @@ class AddHardware(uiutils.UITestCase):
# Virtio SCSI
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Controller", "controller-tab")
typ.click()
typ.click_combo_entry()
tab.find("SCSI", "menu item").click()
tab.find("Model:", "combo box").click_combo_entry()
tab.find("VirtIO SCSI", "menu item").click()
@ -61,7 +61,7 @@ class AddHardware(uiutils.UITestCase):
# USB 2
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Controller", "controller-tab")
typ.click()
typ.click_combo_entry()
tab.find("USB", "menu item").click()
tab.find("Model:", "combo box").click_combo_entry()
tab.find("USB 2", "menu item").click()
@ -71,7 +71,7 @@ class AddHardware(uiutils.UITestCase):
# USB 3
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Controller", "controller-tab")
typ.click()
typ.click_combo_entry()
tab.find("^USB$", "menu item").click()
tab.find("Model:", "combo box").click_combo_entry()
tab.find("USB 3", "menu item").click()

View File

@ -404,17 +404,6 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="controller-type">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="changed" handler="on_controller_type_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkImage" id="controller-tooltip">
<property name="visible">True</property>
@ -442,6 +431,23 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="controller-type">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<signal name="changed" handler="on_controller_type_changed" swapped="no"/>
<child internal-child="entry">
<object class="GtkEntry">
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>

View File

@ -708,11 +708,7 @@ class vmmAddHardware(vmmGObjectUI):
def _build_controller_type_combo(self):
values = []
for t in DeviceController.TYPES:
if t in [DeviceController.TYPE_IDE,
DeviceController.TYPE_PCI,
DeviceController.TYPE_FDC]:
continue
for t in DeviceController.get_recommended_types(self.vm.xmlobj):
values.append([t, DeviceController.pretty_type(t)])
_build_combo(self.widget("controller-type"), values,
@ -723,14 +719,17 @@ class vmmAddHardware(vmmGObjectUI):
model = combo.get_model()
model.clear()
model.append([None, _("Hypervisor default")])
rows = []
if controller_type == DeviceController.TYPE_USB:
model.append(["ich9-ehci1", "USB 2"])
model.append(["nec-xhci", "USB 3"])
rows.append(["nec-xhci", "USB 3"])
rows.append(["ich9-ehci1", "USB 2"])
elif controller_type == DeviceController.TYPE_SCSI:
model.append(["virtio-scsi", "VirtIO SCSI"])
rows.append(["virtio-scsi", "VirtIO SCSI"])
rows.append([None, _("Hypervisor default")])
combo.set_active(0)
for row in rows:
model.append(row)
uiutil.set_list_selection(combo, rows[0][0])

View File

@ -20,10 +20,13 @@ class DeviceController(Device):
TYPE_USB = "usb"
TYPE_PCI = "pci"
TYPE_CCID = "ccid"
TYPES = [TYPE_IDE, TYPE_FDC,
TYPE_SCSI, TYPE_SATA,
TYPE_VIRTIOSERIAL, TYPE_USB,
TYPE_PCI, TYPE_CCID]
@staticmethod
def get_recommended_types(_guest):
return [DeviceController.TYPE_SCSI,
DeviceController.TYPE_USB,
DeviceController.TYPE_VIRTIOSERIAL,
DeviceController.TYPE_CCID]
@staticmethod
def pretty_type(ctype):