Skip to content

Commit fe4f02b

Browse files
committed
q-dev: fix loading devices in event handling
1 parent a5da230 commit fe4f02b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

qubesadmin/events/__init__.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import qubesadmin.config
2828
import qubesadmin.exc
29-
from qubesadmin.device_protocol import VirtualDevice, Port
29+
from qubesadmin.device_protocol import VirtualDevice, Port, UnknownDevice
3030

3131

3232
class EventsDispatcher(object):
@@ -239,8 +239,17 @@ def handle(self, subject, event, **kwargs):
239239
devclass,
240240
self.app.domains,
241241
blind=True)
242-
kwargs['device'] = self.app.domains.get_blind(
243-
device.backend_name).devices[devclass][device.port_id]
242+
kwargs['device'] = device
243+
if device.port_id != '*':
244+
plugged = self.app.domains.get_blind(
245+
device.backend_name).devices[
246+
devclass][device.port_id]
247+
if (not isinstance(plugged, UnknownDevice)
248+
and plugged.device_id == device.device_id):
249+
kwargs['device'] = plugged
250+
except (KeyError, ValueError):
251+
pass
252+
try:
244253
if 'port' in kwargs:
245254
devclass = event.split(':', 1)[1]
246255
kwargs['port'] = Port.from_str(

0 commit comments

Comments
 (0)