Skip to content

Commit

Permalink
q-dev: implements device_id
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 14, 2024
1 parent 0964df6 commit 127beb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions qubesmanager/device_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def fill_device_list(self):

for i in range(self.dev_list.selected_list.count()):
text = self.dev_list.selected_list.item(i).text()
ident = self.dev_list.selected_list.item(i).dev.ident
port_id = self.dev_list.selected_list.item(i).dev.port_id
self.device_list.addItem(text)
self.ident_list[text] = ident
if ident in self.no_strict_reset_list:
self.ident_list[text] = port_id
if port_id in self.no_strict_reset_list:
self.device_list.item(self.device_list.count()-1).setSelected(
True)

Expand Down
22 changes: 11 additions & 11 deletions qubesmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ def __init_devices_tab__(self):
class DevListWidgetItem(QtWidgets.QListWidgetItem):
def __init__(self, dev, unknown=False, parent=None):
super().__init__(parent)
name = dev.ident.replace('_', ":") + ' ' + dev.description
name = dev.port_id.replace('_', ":") + ' ' + dev.description
if unknown:
name += ' (unknown)'
self.setText(name)
Expand Down Expand Up @@ -1270,32 +1270,32 @@ def __apply_devices_tab__(self):
for dev in new_devs:
if dev not in old_devs:
options = {}
if dev.ident in self.new_strict_reset_list:
if dev.port_id in self.new_strict_reset_list:
options['no-strict-reset'] = True
ass = devices.DeviceAssignment(
self.vm.app.domains['dom0'],
dev.ident, devclass='pci',
attach_automatically=True, required=True,
devices.Port(
self.vm.app.domains['dom0'], dev.port_id, 'pci'),
mode='required',
options=options)
self.vm.devices['pci'].assign(ass)
elif (dev.ident in self.current_strict_reset_list) != \
(dev.ident in self.new_strict_reset_list):
elif (dev.port_id in self.current_strict_reset_list) != \
(dev.port_id in self.new_strict_reset_list):
current_assignment = None
for assignment in self.vm.devices[
'pci'].get_assigned_devices(required_only=True):
if assignment.ident == dev.ident:
if assignment.port_id == dev.port_id:
current_assignment = assignment
break
if current_assignment is None:
# it would be very weird if this happened
msg.append(self.tr("Error re-assigning device ") +
dev.ident)
dev.port_id)
continue

self.vm.devices['pci'].unassign(current_assignment)

current_assignment.options['no-strict-reset'] = \
dev.ident in self.new_strict_reset_list
dev.port_id in self.new_strict_reset_list

self.vm.devices['pci'].assign(current_assignment)

Expand Down Expand Up @@ -1337,7 +1337,7 @@ def define_strict_reset_devices(self):
required_only=True):
if assignment.options.get('no-strict-reset', False):
self.current_strict_reset_list.append(
assignment.ident.replace('_', ':'))
assignment.port_id.replace('_', ':'))
self.new_strict_reset_list = self.current_strict_reset_list.copy()

def strict_reset_button_pressed(self):
Expand Down

0 comments on commit 127beb7

Please sign in to comment.