|
84 | 84 | import static org.zstack.compute.vm.VmGlobalConfig.ENABLE_UEFI_SECURE_BOOT; |
85 | 85 | import static org.zstack.core.Platform.operr; |
86 | 86 | import static org.zstack.header.vm.VmMigrationType.HostMigration; |
| 87 | +import static org.zstack.header.vm.additions.VmHostFileSyncReason.PostMigration; |
| 88 | +import static org.zstack.header.vm.additions.VmHostFileSyncReason.PrepareReRead; |
| 89 | +import static org.zstack.header.vm.additions.VmHostFileSyncReason.PrepareRead; |
| 90 | +import static org.zstack.header.vm.additions.VmHostFileSyncReason.ResourceRelease; |
87 | 91 | import static org.zstack.kvm.KVMConstant.*; |
88 | 92 | import static org.zstack.utils.CollectionDSL.list; |
89 | 93 |
|
@@ -358,6 +362,7 @@ public static class PrepareHostFileContext { |
358 | 362 | public String hostUuid; |
359 | 363 | public String vmUuid; |
360 | 364 | public VmHostFileType type; |
| 365 | + public String syncReason; |
361 | 366 |
|
362 | 367 | public String path; |
363 | 368 | // whether the NvRam is on the same host as before |
@@ -396,6 +401,7 @@ public void run(FlowTrigger trigger, Map data) { |
396 | 401 | SyncVmHostFilesFromHostMsg syncMsg = new SyncVmHostFilesFromHostMsg(); |
397 | 402 | syncMsg.setHostUuid(vmHostFile.getHostUuid()); |
398 | 403 | syncMsg.setVmUuid(context.vmUuid); |
| 404 | + syncMsg.setSyncReason(PrepareRead.reason(context.syncReason)); |
399 | 405 |
|
400 | 406 | if (vmHostFile.getType() == VmHostFileType.NvRam) { |
401 | 407 | context.path = vmHostFile.getPath(); |
@@ -506,6 +512,7 @@ public void run(FlowTrigger trigger, Map data) { |
506 | 512 | SyncVmHostFilesFromHostMsg syncMsg = new SyncVmHostFilesFromHostMsg(); |
507 | 513 | syncMsg.setHostUuid(context.hostUuid); |
508 | 514 | syncMsg.setVmUuid(context.vmUuid); |
| 515 | + syncMsg.setSyncReason(PrepareReRead.reason(context.syncReason)); |
509 | 516 |
|
510 | 517 | if (context.type == VmHostFileType.NvRam) { |
511 | 518 | syncMsg.setNvRamPath(context.path); |
@@ -549,6 +556,7 @@ private void prepareNvRamHostFileOnHost(VmInstanceSpec spec, Completion completi |
549 | 556 | context.hostUuid = spec.getDestHost().getUuid(); |
550 | 557 | context.vmUuid = spec.getVmInventory().getUuid(); |
551 | 558 | context.type = VmHostFileType.NvRam; |
| 559 | + context.syncReason = "pre-instantiate VM resource"; |
552 | 560 | prepareHostFileOnHost(context, completion); |
553 | 561 | } |
554 | 562 |
|
@@ -758,6 +766,7 @@ public void releaseVmResource(VmInstanceSpec spec, Completion completion) { |
758 | 766 | SyncVmHostFilesFromHostMsg syncMsg = new SyncVmHostFilesFromHostMsg(); |
759 | 767 | syncMsg.setHostUuid(hostUuid); |
760 | 768 | syncMsg.setVmUuid(vmUuid); |
| 769 | + syncMsg.setSyncReason(ResourceRelease.reason()); |
761 | 770 |
|
762 | 771 | for (VmHostFileVO file : vmHostFiles) { |
763 | 772 | if (file.getType() == VmHostFileType.NvRam) { |
@@ -822,6 +831,7 @@ public void afterMigrateVm(VmInstanceInventory inv, String srcHostUuid, NoErrorC |
822 | 831 | SyncVmHostFilesFromHostMsg syncMsg = new SyncVmHostFilesFromHostMsg(); |
823 | 832 | syncMsg.setHostUuid(destHostUuid); |
824 | 833 | syncMsg.setVmUuid(vmUuid); |
| 834 | + syncMsg.setSyncReason(PostMigration.reason()); |
825 | 835 |
|
826 | 836 | for (VmHostFileVO file : vmHostFiles) { |
827 | 837 | if (file.getType() == VmHostFileType.NvRam) { |
|
0 commit comments