Commit 26e815d
Fix deepcopy usage for BlockDeviceMapping in get_root_info
The method get_root_info sometimes receives a BlockDeviceMapping object,
which lacks a copy method. The previous code assumed root_bdm was always
an instance of DriverBlockDevice, a subclass of dict that supports the copy()
method. However, during testing, it was discovered that root_bdm could also
be a BlockDeviceMapping object, which does not have a copy method.
To address this, the change replaces the copy() call with copy.deepcopy()
according to the suggestion in the comment [1], which works for both
BlockDeviceMapping and DriverBlockDevice instances. The deepcopy method is
supported because oslo.versionedobjects implements the __deepcopy__ method.
This change ensures the function handles both object types correctly,
preventing the AttributeError observed during testing.
[1] https://review.opendev.org/c/openstack/nova/+/909611/4/nova/virt/libvirt/blockinfo.py
Change-Id: I9432718586855ff57e8e6a5cae064e0685dd01e8
(cherry picked from commit 065bf99)
Signed-off-by: Zhang Hua <[email protected]>
(cherry picked from commit 9ff4953)
(cherry picked from commit 608a73e)
(cherry picked from commit 5b57acb)1 parent 200d375 commit 26e815d
File tree
2 files changed
+49
-3
lines changed- nova
- tests/unit/virt/libvirt
- virt/libvirt
2 files changed
+49
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1289 | 1289 | | |
1290 | 1290 | | |
1291 | 1291 | | |
| 1292 | + | |
1292 | 1293 | | |
1293 | 1294 | | |
1294 | 1295 | | |
| |||
1318 | 1319 | | |
1319 | 1320 | | |
1320 | 1321 | | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
1321 | 1365 | | |
1322 | 1366 | | |
1323 | 1367 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
444 | 445 | | |
445 | 446 | | |
446 | 447 | | |
| 448 | + | |
447 | 449 | | |
448 | | - | |
449 | | - | |
| 450 | + | |
| 451 | + | |
450 | 452 | | |
451 | 453 | | |
452 | | - | |
| 454 | + | |
453 | 455 | | |
454 | 456 | | |
455 | 457 | | |
| |||
0 commit comments