Skip to content

Commit 01f9a61

Browse files
committed
Fix live migrate with local storage
1 parent d98511d commit 01f9a61

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7362,6 +7362,24 @@ public VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinatio
73627362

73637363
Map<Long, Long> volToPoolObjectMap = getVolumePoolMappingForMigrateVmWithStorage(vm, volumeToPool);
73647364

7365+
// If volumeToPool is empty and there are local storage volumes, auto-populate the mapping
7366+
if (MapUtils.isEmpty(volToPoolObjectMap) && isAnyVmVolumeUsingLocalStorage(volumes)) {
7367+
// First, find a destination host if not provided
7368+
if (destinationHost == null) {
7369+
DeployDestination deployDestination = chooseVmMigrationDestination(vm, srcHost, null);
7370+
if (deployDestination == null || deployDestination.getHost() == null) {
7371+
throw new CloudRuntimeException("Unable to find suitable destination host to migrate VM " + vm.getInstanceName());
7372+
}
7373+
destinationHost = deployDestination.getHost();
7374+
}
7375+
7376+
// Verify the destination host has local storage
7377+
if (!storageManager.isLocalStorageActiveOnHost(destinationHost.getId())) {
7378+
throw new CloudRuntimeException(String.format("Destination host %s (ID: %s) does not have local storage, but VM %s (ID: %s) has volumes using local storage",
7379+
destinationHost.getName(), destinationHost.getUuid(), vm.getInstanceName(), vm.getUuid()));
7380+
}
7381+
}
7382+
73657383
if (destinationHost == null) {
73667384
destinationHost = chooseVmMigrationDestinationUsingVolumePoolMap(vm, srcHost, volToPoolObjectMap);
73677385
}

0 commit comments

Comments
 (0)