Skip to content

Commit 693d67f

Browse files
committed
Fix for CLOUDSTACK-8937 - XenServer migrations with storage failing in clustered management server environment
1 parent f1f1fef commit 693d67f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import org.apache.cloudstack.storage.to.VolumeObjectTO;
4343

44+
import com.cloud.utils.Pair;
4445
import com.cloud.agent.api.Answer;
4546
import com.cloud.agent.api.Command;
4647
import com.cloud.agent.api.MigrateWithStorageAnswer;
@@ -126,7 +127,7 @@ private List<VolumeObjectTO> getUpdatedVolumePathsOfMigratedVm(Connection connec
126127
protected MigrateWithStorageAnswer execute(MigrateWithStorageCommand cmd) {
127128
Connection connection = getConnection();
128129
VirtualMachineTO vmSpec = cmd.getVirtualMachine();
129-
Map<VolumeTO, StorageFilerTO> volumeToFiler = cmd.getVolumeToFiler();
130+
List<Pair<VolumeTO, StorageFilerTO>> volToFiler = cmd.getVolumeToFilerAsList();
130131
final String vmName = vmSpec.getName();
131132
Task task = null;
132133

@@ -151,8 +152,8 @@ protected MigrateWithStorageAnswer execute(MigrateWithStorageCommand cmd) {
151152
// Create the vif map. The vm stays in the same cluster so we have to pass an empty vif map.
152153
Map<VIF, Network> vifMap = new HashMap<VIF, Network>();
153154
Map<VDI, SR> vdiMap = new HashMap<VDI, SR>();
154-
for (Map.Entry<VolumeTO, StorageFilerTO> entry : volumeToFiler.entrySet()) {
155-
vdiMap.put(getVDIbyUuid(connection, entry.getKey().getPath()), getStorageRepository(connection, entry.getValue().getUuid()));
155+
for (Pair<VolumeTO, StorageFilerTO> entry : volToFiler) {
156+
vdiMap.put(getVDIbyUuid(connection, entry.first().getPath()), getStorageRepository(connection, entry.second().getUuid()));
156157
}
157158

158159
// Check migration with storage is possible.

plugins/hypervisors/xenserver/src/org/apache/cloudstack/storage/motion/XenServerStorageMotionStrategy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.cloudstack.storage.motion;
2020

2121
import java.util.HashMap;
22+
import java.util.ArrayList;
2223
import java.util.List;
2324
import java.util.Map;
2425

@@ -55,6 +56,7 @@
5556
import com.cloud.exception.OperationTimedoutException;
5657
import com.cloud.host.Host;
5758
import com.cloud.hypervisor.Hypervisor.HypervisorType;
59+
import com.cloud.utils.Pair;
5860
import com.cloud.storage.StoragePool;
5961
import com.cloud.storage.VolumeVO;
6062
import com.cloud.storage.dao.VolumeDao;
@@ -193,15 +195,15 @@ private Answer migrateVmWithVolumesWithinCluster(VMInstanceVO vm, VirtualMachine
193195

194196
// Initiate migration of a virtual machine with it's volumes.
195197
try {
196-
Map<VolumeTO, StorageFilerTO> volumeToFilerto = new HashMap<VolumeTO, StorageFilerTO>();
198+
List<Pair<VolumeTO, StorageFilerTO>> volumeToFilerto = new ArrayList<Pair<VolumeTO, StorageFilerTO>>();
197199
for (Map.Entry<VolumeInfo, DataStore> entry : volumeToPool.entrySet()) {
198200
VolumeInfo volume = entry.getKey();
199201
VolumeTO volumeTo = new VolumeTO(volume, storagePoolDao.findById(volume.getPoolId()));
200202
StorageFilerTO filerTo = new StorageFilerTO((StoragePool)entry.getValue());
201-
volumeToFilerto.put(volumeTo, filerTo);
203+
volumeToFilerto.add(new Pair<VolumeTO, StorageFilerTO>(volumeTo, filerTo));
202204
}
203205

204-
MigrateWithStorageCommand command = new MigrateWithStorageCommand(to, volumeToFilerto);
206+
MigrateWithStorageCommand command = new MigrateWithStorageCommand(to, volumeToFilerto,destHost.getGuid());
205207
MigrateWithStorageAnswer answer = (MigrateWithStorageAnswer)agentMgr.send(destHost.getId(), command);
206208
if (answer == null) {
207209
s_logger.error("Migration with storage of vm " + vm + " failed.");

0 commit comments

Comments
 (0)