@@ -133,9 +133,6 @@ def __init__(self, app_name, qapp, dispatcher):
133133 self .dispatcher .add_handler (
134134 "device-detach:" + devclass , self .device_detached
135135 )
136- self .dispatcher .add_handler (
137- "device-list-change:" + devclass , self ._update_queue
138- )
139136 self .dispatcher .add_handler ("device-added:" + devclass , self .device_added )
140137 self .dispatcher .add_handler (
141138 "device-removed:" + devclass , self .device_removed
@@ -179,17 +176,17 @@ def __init__(self, app_name, qapp, dispatcher):
179176 "<b>Qubes Devices</b>\n View and manage devices."
180177 )
181178
182- def _update_queue (self , vm , device , ** _kwargs ):
179+ def _update_queue (self , vm , device , device_class ):
183180 """Handle certain operations that should not be done too often."""
184181 # update children
185182 if vm not in self .vm_update_queue :
186183 self .vm_update_queue .add (vm )
187184 asyncio .create_task (self .update_parents (vm ))
188185 if device not in self .dev_update_queue :
189186 self .dev_update_queue .add (device )
190- asyncio .create_task (self .update_assignments ())
187+ asyncio .create_task (self .update_assignments (device_class ))
191188
192- async def update_assignments (self ):
189+ async def update_assignments (self , dev_class ):
193190 """Scan vm list for new assignments"""
194191 await asyncio .sleep (0.3 )
195192
@@ -199,20 +196,19 @@ async def update_assignments(self):
199196 self .dev_update_queue .clear ()
200197
201198 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
216212
217213 async def update_parents (self , vm ):
218214 await asyncio .sleep (0.3 )
@@ -270,7 +266,7 @@ def device_added(self, vm, _event, device):
270266 notification_id = dev .notification_id ,
271267 )
272268
273- self ._update_queue (vm , dev_id )
269+ self ._update_queue (vm , dev_id , dev . device_class )
274270
275271 def device_removed (self , vm , _event , port ):
276272 for potential_dev_id , potential_dev in self .devices .items ():
0 commit comments