Commit 7ec56ae 1 parent fe4f02b commit 7ec56ae Copy full SHA for 7ec56ae
File tree 2 files changed +22
-4
lines changed
2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -1187,8 +1187,9 @@ def device_id(self) -> str:
1187
1187
def devices (self ) -> List [DeviceInfo ]:
1188
1188
"""Get DeviceInfo objects corresponding to this DeviceAssignment"""
1189
1189
if self .port_id != '*' :
1190
- # could return UnknownDevice
1191
- return [self .backend_domain .devices [self .devclass ][self .port_id ]]
1190
+ dv = self .backend_domain .devices [self .devclass ][self .port_id ]
1191
+ if isinstance (dv , UnknownDevice ) or dv .device_id == self .device_id :
1192
+ return [dv ]
1192
1193
result = []
1193
1194
if self .device_id == "0000:0000::?******" :
1194
1195
return result
Original file line number Diff line number Diff line change @@ -287,8 +287,25 @@ def assign_device(args):
287
287
print ("Warning: The assigned device is on the denied list: "
288
288
f"{ DEVICE_DENY_LIST } \n Auto-attach will work, "
289
289
f"but make sure that the assignment is correct." )
290
- if (vm .is_running () and not assignment .attached
291
- and assignment .port_id != '*' and not args .quiet ):
290
+ if vm .is_running () and not args .quiet :
291
+ _print_attach_hint (assignment , vm )
292
+
293
+
294
+ def _print_attach_hint (assignment , vm ):
295
+ if assignment .port_id == '*' :
296
+ return
297
+
298
+ try :
299
+ plugged = assignment .backend_domain .devices [
300
+ assignment .devclass ][assignment .port_id ]
301
+ except KeyError :
302
+ return
303
+
304
+ if isinstance (plugged , UnknownDevice ):
305
+ return
306
+
307
+ attached = vm .devices [assignment .devclass ].get_attached_devices ()
308
+ if assignment .matches (plugged ) and plugged not in attached :
292
309
print ("Assigned. To attach you can now restart domain or run: \n "
293
310
f"\t qvm-{ assignment .devclass } attach { vm } "
294
311
f"{ assignment .backend_domain } :{ assignment .port_id } " )
You can’t perform that action at this time.
0 commit comments