Skip to content

Commit

Permalink
q-dev: assignment.devices
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 14, 2024
1 parent b589bf6 commit 26c0ca0
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions qubesusbproxy/core3ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,28 +504,22 @@ def on_domain_init_load(self, vm, event):

async def attach_and_notify(self, vm, assignment):
# bypass DeviceCollection logic preventing double attach
try:
identity = assignment.device_id
device = assignment.device
if identity not in ('*', device.device_id):
print("Unrecognized identity, skipping attachment of device "
f"from the port {assignment}", file=sys.stderr)
raise qubes.devices.UnrecognizedDevice(
f"Device presented identity {device.device_id} "
f"does not match expected {identity}"
)

identity = assignment.device_id
for device in assignment.devices:
if not assignment.matches(device):
print(
"Unrecognized identity, skipping attachment of device "
f"from the port {assignment}", file=sys.stderr)
continue
if assignment.mode.value == "ask-to-attach":
if vm.name != utils.confirm_device_attachment(
device, {vm: assignment}):
return

await self.on_device_attach_usb(
vm, 'device-pre-attach:usb', device, assignment.options)
except UnrecognizedDevice:
return
await vm.fire_event_async(
'device-attach:usb', device=device, options=assignment.options)
await vm.fire_event_async(
'device-attach:usb', device=device, options=assignment.options)

@qubes.ext.handler('domain-qdb-change:/qubes-usb-devices')
def on_qdb_change(self, vm, event, path):
Expand Down

0 comments on commit 26c0ca0

Please sign in to comment.