Skip to content

Commit 66b0e73

Browse files
committed
q-dev: Fix detecting already assigned devices on setting apply
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
1 parent d0f8b83 commit 66b0e73

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

qubesmanager/settings.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,10 @@ def __apply_devices_tab__(self):
12681268
for i in range(self.dev_list.selected_list.count())]
12691269

12701270
for dev in new_devs:
1271-
if dev not in old_devs:
1272-
options = {}
1271+
old_assignments[0] = [old for old in old_devs
1272+
if old.matches(dev)]
1273+
if not old_assignments:
1274+
options = old_assignments[0].options.clone()
12731275
if dev.port_id in self.new_strict_reset_list:
12741276
options['no-strict-reset'] = True
12751277
ass = device_protocol.DeviceAssignment.new(
@@ -1282,18 +1284,7 @@ def __apply_devices_tab__(self):
12821284
self.vm.devices['pci'].assign(ass)
12831285
elif (dev.port_id in self.current_strict_reset_list) != \
12841286
(dev.port_id in self.new_strict_reset_list):
1285-
current_assignment = None
1286-
for assignment in self.vm.devices[
1287-
'pci'].get_assigned_devices(required_only=True):
1288-
if assignment.port_id == dev.port_id:
1289-
current_assignment = assignment
1290-
break
1291-
if current_assignment is None:
1292-
# it would be very weird if this happened
1293-
msg.append(self.tr("Error re-assigning device ") +
1294-
dev.port_id)
1295-
continue
1296-
1287+
current_assignment = old_assignments[0]
12971288
self.vm.devices['pci'].unassign(current_assignment)
12981289

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

0 commit comments

Comments
 (0)