addhardware: Move video model list to virtinst

And make it smart about the hypervisor
This commit is contained in:
Cole Robinson 2018-09-06 14:43:45 -04:00
parent 7baa296aed
commit 7994dc90c8
4 changed files with 28 additions and 15 deletions

View File

@ -485,8 +485,8 @@ class AddHardware(uiutils.UITestCase):
# Add video
self._open_addhw_window(details)
tab = self._select_hw(addhw, "Video", "video-tab")
tab.find("Model:", "combo box").click()
tab.find("QXL", "menu item").click()
tab.find("Model:", "combo box").click_combo_entry()
tab.find("Virtio", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)

View File

@ -1051,16 +1051,6 @@
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkComboBox" id="video-model">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label23">
<property name="visible">True</property>
@ -1075,6 +1065,22 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="video-model">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="has_entry">True</property>
<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 internal-child="accessible">
<object class="AtkObject" id="table5-atkobject">
<property name="AtkObject::accessible-name">video-tab</property>

View File

@ -596,8 +596,10 @@ class vmmAddHardware(vmmGObjectUI):
@staticmethod
def build_video_combo(vm, combo):
values = []
for m in DeviceVideo.MODELS:
for m in DeviceVideo.get_recommended_models(vm.xmlobj):
values.append([m, DeviceVideo.pretty_model(m)])
if not values:
values.append([None, _("Hypervisor default")])
default = DeviceVideo.default_model(vm.xmlobj)
_build_combo(combo, values, default_value=default)

View File

@ -12,8 +12,13 @@ from ..xmlbuilder import XMLProperty
class DeviceVideo(Device):
XML_NAME = "video"
# Default models list
MODELS = ["cirrus", "vga", "vmvga", "xen", "qxl", "virtio"]
@staticmethod
def get_recommended_models(guest):
if guest.conn.is_xen():
return ["xen", "vga"]
if guest.conn.is_qemu() or guest.conn.is_test():
return ["vga", "qxl", "virtio"]
return []
@staticmethod
def pretty_model(model):