Skip to content

Commit

Permalink
q-dev: fix loading devices in event handling
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrbartman committed Oct 14, 2024
1 parent a5da230 commit fe4f02b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions qubesadmin/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import qubesadmin.config
import qubesadmin.exc
from qubesadmin.device_protocol import VirtualDevice, Port
from qubesadmin.device_protocol import VirtualDevice, Port, UnknownDevice


class EventsDispatcher(object):
Expand Down Expand Up @@ -239,8 +239,17 @@ def handle(self, subject, event, **kwargs):
devclass,
self.app.domains,
blind=True)
kwargs['device'] = self.app.domains.get_blind(
device.backend_name).devices[devclass][device.port_id]
kwargs['device'] = device
if device.port_id != '*':
plugged = self.app.domains.get_blind(
device.backend_name).devices[
devclass][device.port_id]
if (not isinstance(plugged, UnknownDevice)
and plugged.device_id == device.device_id):
kwargs['device'] = plugged
except (KeyError, ValueError):
pass
try:
if 'port' in kwargs:
devclass = event.split(':', 1)[1]
kwargs['port'] = Port.from_str(
Expand Down

0 comments on commit fe4f02b

Please sign in to comment.