Skip to content

Commit

Permalink
q-dev: Fix detecting already assigned devices on setting apply
Browse files Browse the repository at this point in the history
Device with specific device_id doesn't equal device with wildcard
device_id, so `dev in old_devs` check cannot be used.
Fix this by using DeviceAssignment.matches method. A side effect is
getting old assignment earlier.

QubesOS/qubes-issues#9325
  • Loading branch information
marmarek committed Nov 16, 2024
1 parent 00cec57 commit 12ff450
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions qubesmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,9 @@ def __apply_devices_tab__(self):
for i in range(self.dev_list.selected_list.count())]

for dev in new_devs:
if dev not in old_devs:
old_assignments = [old for old in old_devs
if old.matches(dev)]
if not old_assignments:
options = {}
if dev.port_id in self.new_strict_reset_list:
options['no-strict-reset'] = True
Expand All @@ -1282,18 +1284,7 @@ def __apply_devices_tab__(self):
self.vm.devices['pci'].assign(ass)
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.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.port_id)
continue

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

current_assignment.options['no-strict-reset'] = \
Expand Down

0 comments on commit 12ff450

Please sign in to comment.