@@ -133,9 +133,6 @@ def __init__(self, app_name, qapp, dispatcher):
133
133
self .dispatcher .add_handler (
134
134
"device-detach:" + devclass , self .device_detached
135
135
)
136
- self .dispatcher .add_handler (
137
- "device-list-change:" + devclass , self ._update_queue
138
- )
139
136
self .dispatcher .add_handler ("device-added:" + devclass , self .device_added )
140
137
self .dispatcher .add_handler (
141
138
"device-removed:" + devclass , self .device_removed
@@ -179,17 +176,17 @@ def __init__(self, app_name, qapp, dispatcher):
179
176
"<b>Qubes Devices</b>\n View and manage devices."
180
177
)
181
178
182
- def _update_queue (self , vm , device , ** _kwargs ):
179
+ def _update_queue (self , vm , device , device_class ):
183
180
"""Handle certain operations that should not be done too often."""
184
181
# update children
185
182
if vm not in self .vm_update_queue :
186
183
self .vm_update_queue .add (vm )
187
184
asyncio .create_task (self .update_parents (vm ))
188
185
if device not in self .dev_update_queue :
189
186
self .dev_update_queue .add (device )
190
- asyncio .create_task (self .update_assignments ())
187
+ asyncio .create_task (self .update_assignments (device_class ))
191
188
192
- async def update_assignments (self ):
189
+ async def update_assignments (self , dev_class ):
193
190
"""Scan vm list for new assignments"""
194
191
await asyncio .sleep (0.3 )
195
192
@@ -199,20 +196,19 @@ async def update_assignments(self):
199
196
self .dev_update_queue .clear ()
200
197
201
198
for domain in self .qapp .domains :
202
- for devclass in DEV_TYPES :
203
- try :
204
- for device in domain .devices [devclass ].get_attached_devices ():
205
- dev = backend .Device .id_from_device (device )
206
- if dev in devs and dev in self .devices :
207
- self .devices [dev ].attachments .add (backend .VM (domain ))
208
-
209
- for device in domain .devices [devclass ].get_assigned_devices ():
210
- dev = backend .Device .id_from_device (device )
211
- if dev in devs and dev in self .devices :
212
- self .devices [dev ].assignments .add (backend .VM (domain ))
213
- except qubesadmin .exc .QubesException :
214
- # we have no permission to access VM's devices
215
- continue
199
+ try :
200
+ for device in domain .devices [dev_class ].get_attached_devices ():
201
+ dev = backend .Device .id_from_device (device )
202
+ if dev in devs and dev in self .devices :
203
+ self .devices [dev ].attachments .add (backend .VM (domain ))
204
+
205
+ for device in domain .devices [dev_class ].get_assigned_devices ():
206
+ dev = backend .Device .id_from_device (device )
207
+ if dev in devs and dev in self .devices :
208
+ self .devices [dev ].assignments .add (backend .VM (domain ))
209
+ except qubesadmin .exc .QubesException :
210
+ # we have no permission to access VM's devices
211
+ continue
216
212
217
213
async def update_parents (self , vm ):
218
214
await asyncio .sleep (0.3 )
@@ -270,7 +266,7 @@ def device_added(self, vm, _event, device):
270
266
notification_id = dev .notification_id ,
271
267
)
272
268
273
- self ._update_queue (vm , dev_id )
269
+ self ._update_queue (vm , dev_id , dev . device_class )
274
270
275
271
def device_removed (self , vm , _event , port ):
276
272
for potential_dev_id , potential_dev in self .devices .items ():
0 commit comments