@@ -502,15 +502,6 @@ def pre_attachment_internal(
502
502
raise qubes .exc .QubesValueError (
503
503
'Unsupported option {}' .format (option ))
504
504
505
- # identity = value # TODO!
506
- # if identity not in ('any', device.self_identity):
507
- # print("Unrecognized identity, skipping attachment of"
508
- # f" {device}", file=sys.stderr)
509
- # raise qubes.devices.UnrecognizedDevice(
510
- # f"Device presented identity {device.self_identity} "
511
- # f"does not match expected {identity}"
512
- # )
513
-
514
505
if 'read-only' not in options :
515
506
options ['read-only' ] = 'yes' if device .mode == 'r' else 'no'
516
507
if options .get ('read-only' , 'no' ) == 'no' and device .mode == 'r' :
@@ -550,19 +541,34 @@ def pre_attachment_internal(
550
541
async def on_domain_start (self , vm , _event , ** _kwargs ):
551
542
# pylint: disable=unused-argument
552
543
for assignment in vm .devices ['block' ].get_assigned_devices ():
553
- self .notify_auto_attached (
554
- vm , assignment .device , assignment .options )
544
+ if assignment .mode == qubes .device_protocol .AssignmentMode .ASK :
545
+ pass
546
+ self .notify_auto_attached (vm , assignment )
547
+
548
+ def notify_auto_attached (self , vm , assignment ):
549
+ identity = assignment .device_ientity
550
+ device = assignment .device
551
+ if identity not in ('any' , device .self_identity ):
552
+ print ("Unrecognized identity, skipping attachment of device in port"
553
+ f" { assignment } " , file = sys .stderr )
554
+ raise qubes .devices .UnrecognizedDevice (
555
+ f"Device presented identity { device .self_identity } "
556
+ f"does not match expected { identity } "
557
+ )
555
558
556
- def notify_auto_attached (self , vm , device , options ):
557
559
self .pre_attachment_internal (
558
- vm , device , options , expected_attachment = vm )
560
+ vm , device , assignment .options , expected_attachment = vm )
561
+
559
562
asyncio .ensure_future (vm .fire_event_async (
560
- 'device-attach:block' , device = device , options = options ))
563
+ 'device-attach:block' ,
564
+ device = device ,
565
+ options = assignment .options ,
566
+ ))
561
567
562
- async def attach_and_notify (self , vm , device , options ):
568
+ async def attach_and_notify (self , vm , assignment ):
563
569
# bypass DeviceCollection logic preventing double attach
564
570
# we expected that these devices are already attached to this vm
565
- self .notify_auto_attached (vm , device , options )
571
+ self .notify_auto_attached (vm , assignment )
566
572
567
573
@qubes .ext .handler ('domain-shutdown' )
568
574
async def on_domain_shutdown (self , vm , event , ** _kwargs ):
0 commit comments