Skip to content

Commit fbe494a

Browse files
committed
Query attachments from cache
1 parent c607f41 commit fbe494a

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

qubesusbproxy/core3ext.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -653,26 +653,17 @@ def on_device_get_usb(self, vm, event, port_id):
653653
):
654654
yield USBDevice(Port(vm, port_id, "usb"))
655655

656-
@staticmethod
657-
def get_all_devices(app):
658-
for vm in app.domains:
659-
if not vm.is_running() or not hasattr(vm, "devices"):
660-
continue
661-
662-
for dev in vm.devices["usb"]:
663-
# there may be more than one USB-passthrough implementation
664-
if isinstance(dev, USBDevice):
665-
yield dev
666-
667656
@qubes.ext.handler("device-list-attached:usb")
668657
def on_device_list_attached(self, vm, event, **kwargs):
669658
# pylint: disable=unused-argument
670659
if not vm.is_running():
671660
return
672661

673-
for dev in self.get_all_devices(vm.app):
674-
if dev.attachment == vm:
675-
yield (dev, {})
662+
for ports in self.devices_cache.values():
663+
for port_id, attachment in ports.items():
664+
if attachment == vm:
665+
dev = USBDevice(Port(vm, port_id, "usb"))
666+
yield (dev, {})
676667

677668
@qubes.ext.handler("device-pre-attach:usb")
678669
async def on_device_attach_usb(self, vm, event, device, options):

0 commit comments

Comments
 (0)