Skip to content

Commit be60dac

Browse files
committed
Fix fail to start on assignemnt of nonexistent device
Make sure global config tolerates weird phantom devices well. fixes QubesOS/qubes-issues#10080
1 parent 7b9d91e commit be60dac

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

qubes_config/global_config/device_attachments.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
DeviceInfo,
2929
Port,
3030
DeviceInterface,
31+
ProtocolError,
3132
)
3233

3334
from ..widgets.gtk_widgets import TokenName
@@ -668,8 +669,16 @@ def __init__(self, device: DeviceWrapper):
668669
def new_from_existing(cls, assignments: List[DeviceAssignment]):
669670
"""Create new AssignmentWrapper from a list of DeviceAssignments;
670671
this assumes the DeviceAssignments are appropriately grouped"""
671-
device = assignments[0].device
672-
wrapped_device = DeviceWrapper.new_from_device_info(device_info=device)
672+
try:
673+
device = assignments[0].device
674+
wrapped_device = DeviceWrapper.new_from_device_info(device_info=device)
675+
except ProtocolError:
676+
wrapped_device = DeviceWrapper(
677+
assignments[0].devclass, assignments[0].backend_domain
678+
)
679+
wrapped_device.device_id = assignments[0].device_id
680+
wrapped_device.port = assignments[0].port
681+
wrapped_device.port_id = assignments[0].port_id
673682

674683
aw = cls(wrapped_device)
675684
aw.assignments = assignments

0 commit comments

Comments
 (0)