mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-02 09:47:16 +03:00
addhardware: tweak mdev inactive UI
- Move tooltip to the tree row instead of the finish button - Some style cleanups - Add a hack so we can hit it in the test suite Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
a4c02b1aed
commit
a39bd561b0
@ -3678,6 +3678,19 @@ ba</description>
|
||||
</capability>
|
||||
</device>
|
||||
|
||||
<device>
|
||||
<name>mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110-fakeinactive</name>
|
||||
<path>/sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110-fakeinactive</path>
|
||||
<parent>css_0_0_0023</parent>
|
||||
<driver>
|
||||
<name>vfio_mdev</name>
|
||||
</driver>
|
||||
<capability type='mdev'>
|
||||
<type id='vfio_ccw-io'/>
|
||||
<iommuGroup number='0'/>
|
||||
</capability>
|
||||
</device>
|
||||
|
||||
<device>
|
||||
<name>ap_matrix</name>
|
||||
<path>/sys/devices/vfio_ap/matrix</path>
|
||||
|
@ -753,32 +753,22 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
def _build_hostdev_treeview(self):
|
||||
host_dev = self.widget("host-device")
|
||||
# [ xmlobj, label]
|
||||
host_dev_model = Gtk.ListStore(object, str, bool)
|
||||
# [ xmlobj, label, sensitive, tooltip]
|
||||
host_dev_model = Gtk.ListStore(object, str, bool, str)
|
||||
host_dev.set_model(host_dev_model)
|
||||
host_col = Gtk.TreeViewColumn()
|
||||
text = Gtk.CellRendererText()
|
||||
host_col.pack_start(text, True)
|
||||
host_col.add_attribute(text, 'text', 1)
|
||||
host_col.add_attribute(text, 'sensitive', 2)
|
||||
host_dev.set_tooltip_column(3)
|
||||
host_dev_model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
||||
host_dev.append_column(host_col)
|
||||
|
||||
|
||||
def _hostdev_row_selected_cb(self, selection):
|
||||
model, treeiter = selection.get_selected()
|
||||
|
||||
if treeiter is None:
|
||||
return
|
||||
|
||||
row = model[treeiter]
|
||||
tooltip = None
|
||||
sensitive = row[2]
|
||||
if row[0] and sensitive is False:
|
||||
tooltip = (_("%s is not active in the host system.\n"
|
||||
"Please start the mdev in the host system before adding it to the guest.")
|
||||
% row[1])
|
||||
self.widget("create-finish").set_tooltip_text(tooltip)
|
||||
sensitive = treeiter and model[treeiter][2] or False
|
||||
self.widget("create-finish").set_sensitive(sensitive)
|
||||
|
||||
|
||||
@ -809,15 +799,21 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
prettyname = "%s %s" % (
|
||||
parentdev.pretty_name(), prettyname)
|
||||
|
||||
model.append([dev.xmlobj, prettyname, dev.is_active()])
|
||||
tooltip = None
|
||||
sensitive = dev.is_active()
|
||||
if not sensitive:
|
||||
tooltip = _("%s is not active in the host system.\n"
|
||||
"Please start the mdev in the host system before "
|
||||
"adding it to the guest.") % prettyname
|
||||
model.append([dev.xmlobj, prettyname, sensitive, tooltip])
|
||||
|
||||
if len(model) == 0:
|
||||
model.append([None, _("No Devices Available"), False])
|
||||
model.append([None, _("No Devices Available"), False, None])
|
||||
|
||||
uiutil.set_list_selection_by_number(devlist, 0)
|
||||
|
||||
devlist.get_selection().connect("changed",
|
||||
self._hostdev_row_selected_cb)
|
||||
devlist.get_selection().connect(
|
||||
"changed", self._hostdev_row_selected_cb)
|
||||
devlist.get_selection().emit("changed")
|
||||
|
||||
|
||||
|
@ -66,6 +66,11 @@ class vmmNodeDevice(vmmLibvirtObject):
|
||||
is_active = True
|
||||
if self.conn.support.nodedev_isactive(self._backend):
|
||||
is_active = self._backend.isActive() # pragma: no cover
|
||||
|
||||
if self.conn.is_test() and self.xmlobj.name.endswith("-fakeinactive"):
|
||||
# Testsuite hack to mock inactive device
|
||||
is_active = False
|
||||
|
||||
return (is_active and
|
||||
self._STATUS_ACTIVE or
|
||||
self._STATUS_INACTIVE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user