To enable VM migration, you need to set an instance of some VmAllocationPolicyMigration class when creating your datacenter.
There are some implementations such as the VmAllocationPolicyMigrationBestFitStaticThreshold.
And if you need to create a new VM migration policy, you can extend some of the existing classes.
You can check CloudSim Plus. It has some simple VM migration examples available. It also provides a totally refactored set of VmAllocationPolicyMigration that makes it way easier to implement your own policies.
In CloudSim Plus you can create a VmAllocationPolicyMigration to a given datacenter as the example below:
VmAllocationPolicyMigrationStaticThreshold allocationPolicy =
new VmAllocationPolicyMigrationBestFitStaticThreshold(
new PowerVmSelectionPolicyMinimumUtilization(),
HOST_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION);
DatacenterSimple dc = new DatacenterSimple(simulation, hostList, allocationPolicy);
Where HOST_UTILIZATION_THRESHOLD_FOR_VM_MIGRATION is a percentage value defining the CPU utilization threshold a Host can reach to start migrating VMs. It also uses a PowerVmSelectionPolicy that will select VMs with minimum utilization to be migrated from the overloaded Host.
The complete example is available here.
If the example was helpful, please upvote.