@@ -181,7 +181,7 @@ def parse_basic_device_properties(
181
181
f"when expected port: { expected .port_id } ." )
182
182
properties .pop ('port_id' , None )
183
183
184
- if expected .devclass == 'peripheral' :
184
+ if not expected .has_devclass :
185
185
expected = Port (
186
186
expected .backend_domain ,
187
187
expected .port_id ,
@@ -360,13 +360,18 @@ def devclass(self) -> str:
360
360
return "peripheral"
361
361
362
362
363
+ @property
364
+ def has_devclass (self ):
365
+ return self .__devclass is not None
366
+
367
+
363
368
class VirtualDevice :
364
369
"""
365
370
Class of a device connected to *port*.
366
371
367
372
Attributes:
368
- port (Port): A unique identifier for the port within the backend domain .
369
- device_id (str): A unique identifier for the device.
373
+ port (Port): Peripheral device port exposed by vm .
374
+ device_id (str): An identifier for the device.
370
375
"""
371
376
def __init__ (
372
377
self ,
@@ -573,10 +578,8 @@ def serialize(self) -> bytes:
573
578
for key , value in (
574
579
('device_id' , self .device_id ),
575
580
('port_id' , self .port_id ),
576
- ('devclass' , self .devclass )))
577
-
578
- properties += b' ' + DeviceSerializer .pack_property (
579
- 'backend_domain' , self .backend_name )
581
+ ('devclass' , self .devclass ),
582
+ ('backend_domain' , self .backend_name )))
580
583
581
584
return properties
582
585
@@ -1212,7 +1215,7 @@ def device(self) -> DeviceInfo:
1212
1215
return devices [0 ]
1213
1216
if len (devices ) > 1 :
1214
1217
raise ProtocolError ("Too many devices matches to assignment" )
1215
- raise ProtocolError ("Any devices matches to assignment" )
1218
+ raise ProtocolError ("No devices matches to assignment" )
1216
1219
1217
1220
@property
1218
1221
def port (self ) -> Port :
@@ -1329,7 +1332,7 @@ def _deserialize(
1329
1332
device_id = properties ['device_id' ])
1330
1333
# we do not need port, we need device
1331
1334
del properties ['port' ]
1332
- properties . pop ( 'device_id' , None )
1335
+ del properties [ 'device_id' ]
1333
1336
properties ['device' ] = expected_device
1334
1337
1335
1338
return cls (** properties )
0 commit comments