Skip to content

Commit d013133

Browse files
author
Mike Tutkowski
committed
Cache whether to migrate storage
1 parent 5eb0956 commit d013133

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateCommandWrapper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,11 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
132132
vmsnapshots = libvirtComputingResource.cleanVMSnapshotMetadata(dm);
133133

134134
Map<String, MigrateCommand.MigrateDiskInfo> mapMigrateStorage = command.getMigrateStorage();
135+
// migrateStorage is declared as final because the replaceStorage method may mutate mapMigrateStorage, but
136+
// migrateStorage's value should always only be associated with the initial state of mapMigrateStorage.
137+
final boolean migrateStorage = MapUtils.isNotEmpty(mapMigrateStorage);
135138

136-
if (MapUtils.isNotEmpty(mapMigrateStorage)) {
139+
if (migrateStorage) {
137140
xmlDesc = replaceStorage(xmlDesc, mapMigrateStorage);
138141
}
139142

@@ -142,7 +145,7 @@ Use VIR_DOMAIN_XML_SECURE (value = 1) prior to v1.0.0.
142145
//run migration in thread so we can monitor it
143146
s_logger.info("Live migration of instance " + vmName + " initiated");
144147
final ExecutorService executor = Executors.newFixedThreadPool(1);
145-
final Callable<Domain> worker = new MigrateKVMAsync(libvirtComputingResource, dm, dconn, xmlDesc, MapUtils.isNotEmpty(mapMigrateStorage),
148+
final Callable<Domain> worker = new MigrateKVMAsync(libvirtComputingResource, dm, dconn, xmlDesc, migrateStorage,
146149
command.isAutoConvergence(), vmName, command.getDestinationIp());
147150
final Future<Domain> migrateThread = executor.submit(worker);
148151
executor.shutdown();

0 commit comments

Comments
 (0)