Skip to content

Commit 82b116d

Browse files
committed
q-dev: fix detaching
1 parent 487b8d6 commit 82b116d

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

qubesusbproxy/core3ext.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ def on_domain_init_load(self, vm, event):
512512

513513
async def attach_and_notify(self, vm, assignment):
514514
# bypass DeviceCollection logic preventing double attach
515-
identity = assignment.device_id
516515
for device in assignment.devices:
517516
if not assignment.matches(device):
518517
print(
@@ -567,7 +566,6 @@ def on_device_get_usb(self, vm, event, port_id):
567566
if not vm.is_running():
568567
return
569568

570-
print(port_id, file=sys.stderr)
571569
if vm.untrusted_qdb.list(
572570
'/qubes-usb-devices/' + port_id.replace('.', '_')):
573571
yield USBDevice(vm, port_id)
@@ -676,14 +674,14 @@ async def on_device_detach_usb(self, vm, event, port):
676674

677675
# update the cache before the call, to avoid sending duplicated events
678676
# (one on qubesdb watch and the other by the caller of this method)
679-
backend = attached
680-
self.devices_cache[backend][attached.port_id] = None
677+
backend = attached.backend_domain
678+
self.devices_cache[backend.name][attached.port_id] = None
681679

682680
try:
683-
await backend.backend_domain.run_service_for_stdio(
681+
await backend.run_service_for_stdio(
684682
'qubes.USBDetach',
685683
user='root',
686-
input='{}\n'.format(backend.port_id).encode())
684+
input='{}\n'.format(attached.port_id).encode())
687685
except subprocess.CalledProcessError as e:
688686
# TODO: sanitize and include stdout
689687
raise QubesUSBException('Device detach failed')

0 commit comments

Comments
 (0)