Commit 43cf889
committed
migration: Add destination VM backup and cleanup support
Add optional destination VM backup/cleanup functionality to MigrationBase:
- New parameter 'do_destination_vm_backup' (default: no) to enable feature
- Accept optional remote_virsh session for destination host operations
- Check if VM exists on destination before migration
- Fail test if destination VM is running (blocker condition)
- Backup and undefine pre-existing stopped VMs to avoid conflicts
- Use comprehensive undefine options (--nvram, --managed-save, etc.)
- Restore destination VM in cleanup_default()
Update migration_iommu_device test:
- Add setup_remote_virsh_session() helper function
- Create single remote virsh session shared across test operations
- Refactor check_iommu_xml() to reuse remote session (no duplication)
- Add cleanup_default() call in finally block
- Properly close remote session in finally block
This allows migration tests to run on non-clean environments without
depending on destination host state.
AI assisted code and commit. Human reviewed.
Signed-off-by: hholoubk <hholoubk@redhat.com>
Refactor MigrationBase to cache destination host credentials and reuse them across methods, and extract destination VM backup/undefine flow into a helper method.
When do_destination_vm_backup is enabled, include destination host info in logs, fail with clearer message if the destination VM is running, and restore a backed-up destination VM by copying its XML file to the destination host before defining it via remote virsh.
When destination VM backup is enabled, return early if the VM does not exist on the destination host, and enable debug logging for the existence/running-state checks.
Only call destination VM backup/undefine helper when do_destination_vm_backup is enabled, and drop the redundant guard from the helper.
AI assisted code and commit. Human reviewed.
Signed-off-by: hholoubk <hholoubk@redhat.com>
migration: Fix remote_virsh session resource leak in migration_iommu_device
Move remote_virsh session creation and migration_obj initialization
inside the try block to prevent resource leaks if MigrationBase.__init__
fails. Also remove redundant cleanup_default() call since it's already
called within cleanup_connection().
Changes:
- Initialize remote_virsh and migration_obj to None before try block
- Move session creation inside try block
- Add null checks before cleanup operations
- Remove duplicate cleanup_default() call
AI assisted code and commit. Human reviewed.
Signed-off-by: hholoubk <hholoubk@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
migration: Check destination host libvirt version for checkpoints-metadata
Replace local version_compare() call with is_libvirt_feature_supported()
using a remote SSH session to the destination host. The previous code
incorrectly checked the local libvirt version when deciding whether to
pass --checkpoints-metadata to undefine on the remote host.
AI assisted code and commit. Human reviewed.
Signed-off-by: hholoubk <hholoubk@redhat.com>
Made-with: Cursor
dd1 parent 6011393 commit 43cf889
3 files changed
Lines changed: 129 additions & 42 deletions
File tree
- libvirt/tests
- cfg/sriov/vIOMMU
- src/sriov/vIOMMU
- provider/migration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
Lines changed: 33 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
17 | 37 | | |
18 | 38 | | |
19 | 39 | | |
20 | 40 | | |
21 | 41 | | |
| 42 | + | |
22 | 43 | | |
23 | 44 | | |
24 | 45 | | |
25 | 46 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 47 | | |
36 | | - | |
| 48 | + | |
37 | 49 | | |
38 | 50 | | |
39 | 51 | | |
| |||
71 | 83 | | |
72 | 84 | | |
73 | 85 | | |
74 | | - | |
75 | 86 | | |
| 87 | + | |
| 88 | + | |
76 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
77 | 93 | | |
78 | 94 | | |
79 | 95 | | |
80 | 96 | | |
81 | | - | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
| |||
87 | 103 | | |
88 | 104 | | |
89 | 105 | | |
90 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
91 | 110 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
56 | 65 | | |
57 | 66 | | |
58 | 67 | | |
| |||
63 | 72 | | |
64 | 73 | | |
65 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
66 | 124 | | |
67 | 125 | | |
68 | 126 | | |
| |||
253 | 311 | | |
254 | 312 | | |
255 | 313 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | 314 | | |
260 | 315 | | |
261 | 316 | | |
262 | | - | |
263 | | - | |
264 | | - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
265 | 320 | | |
266 | 321 | | |
267 | | - | |
268 | | - | |
| 322 | + | |
| 323 | + | |
269 | 324 | | |
270 | 325 | | |
271 | 326 | | |
| |||
343 | 398 | | |
344 | 399 | | |
345 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
346 | 422 | | |
347 | 423 | | |
348 | 424 | | |
| |||
390 | 466 | | |
391 | 467 | | |
392 | 468 | | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | 469 | | |
397 | 470 | | |
398 | 471 | | |
| |||
404 | 477 | | |
405 | 478 | | |
406 | 479 | | |
407 | | - | |
408 | | - | |
409 | | - | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
410 | 483 | | |
411 | 484 | | |
412 | 485 | | |
| |||
439 | 512 | | |
440 | 513 | | |
441 | 514 | | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
448 | 518 | | |
449 | 519 | | |
450 | 520 | | |
| |||
469 | 539 | | |
470 | 540 | | |
471 | 541 | | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
| 542 | + | |
| 543 | + | |
477 | 544 | | |
478 | 545 | | |
479 | 546 | | |
| |||
520 | 587 | | |
521 | 588 | | |
522 | 589 | | |
523 | | - | |
| 590 | + | |
524 | 591 | | |
525 | 592 | | |
526 | 593 | | |
| |||
587 | 654 | | |
588 | 655 | | |
589 | 656 | | |
590 | | - | |
| 657 | + | |
591 | 658 | | |
592 | 659 | | |
593 | 660 | | |
| |||
0 commit comments