3131
3232import javax .inject .Inject ;
3333
34+ import com .cloud .agent .api .PrepareForMigrationAnswer ;
3435import org .apache .cloudstack .engine .subsystem .api .storage .ChapInfo ;
3536import org .apache .cloudstack .engine .subsystem .api .storage .ClusterScope ;
3637import org .apache .cloudstack .engine .subsystem .api .storage .CopyCommandResult ;
@@ -1884,18 +1885,18 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
18841885 }
18851886
18861887 PrepareForMigrationCommand pfmc = new PrepareForMigrationCommand (vmTO );
1888+ Answer pfma ;
18871889
18881890 try {
1889- Answer pfma = agentManager .send (destHost .getId (), pfmc );
1891+ pfma = agentManager .send (destHost .getId (), pfmc );
18901892
18911893 if (pfma == null || !pfma .getResult ()) {
18921894 String details = pfma != null ? pfma .getDetails () : "null answer returned" ;
18931895 String msg = "Unable to prepare for migration due to the following: " + details ;
18941896
18951897 throw new AgentUnavailableException (msg , destHost .getId ());
18961898 }
1897- }
1898- catch (final OperationTimedoutException e ) {
1899+ } catch (final OperationTimedoutException e ) {
18991900 throw new AgentUnavailableException ("Operation timed out" , destHost .getId ());
19001901 }
19011902
@@ -1911,6 +1912,12 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
19111912 migrateCommand .setMigrateStorageManaged (managedStorageDestination );
19121913 migrateCommand .setMigrateNonSharedInc (migrateNonSharedInc );
19131914
1915+ Integer newVmCpuShares = ((PrepareForMigrationAnswer ) pfma ).getNewVmCpuShares ();
1916+ if (newVmCpuShares != null ) {
1917+ LOGGER .debug (String .format ("Setting CPU shares to [%d] as part of migrate VM with volumes command for VM [%s]." , newVmCpuShares , vmTO ));
1918+ migrateCommand .setNewVmCpuShares (newVmCpuShares );
1919+ }
1920+
19141921 boolean kvmAutoConvergence = StorageManager .KvmAutoConvergence .value ();
19151922 migrateCommand .setAutoConvergence (kvmAutoConvergence );
19161923
0 commit comments