Skip to content

Commit be25600

Browse files
committed
q-dev: update device_protocol.py
1 parent cc65d08 commit be25600

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

qubes/device_protocol.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def __eq__(self, other):
255255
def __lt__(self, other):
256256
if isinstance(other, Port):
257257
return (self.backend_name, self.devclass, self.port_id) < \
258-
(self.backend_name, other.devclass, other.port_id)
258+
(other.backend_name, other.devclass, other.port_id)
259259
raise TypeError(f"Comparing instances of 'Port' and '{type(other)}' "
260260
"is not supported")
261261

@@ -1167,13 +1167,14 @@ def device_id(self) -> str:
11671167
def devices(self) -> List[DeviceInfo]:
11681168
"""Get DeviceInfo objects corresponding to this DeviceAssignment"""
11691169
if self.port_id != '*':
1170-
# could return UnknownDevice
1171-
return [self.backend_domain.devices[self.devclass][self.port_id]]
1170+
dv = self.backend_domain.devices[self.devclass][self.port_id]
1171+
if isinstance(dv, UnknownDevice) or dv.device_id == self.device_id:
1172+
return [dv]
11721173
result = []
11731174
if self.device_id == "0000:0000::?******":
11741175
return result
11751176
for dev in self.backend_domain.devices[self.devclass]:
1176-
if dev.device_id == self.device_id:
1177+
if self.matches(dev):
11771178
result.append(dev)
11781179
return result
11791180

0 commit comments

Comments
 (0)