Skip to content

Commit 498227b

Browse files
slavkapdhslove
authored andcommitted
Fix of deployment VM from a copied snapshot in another zone (apache#11351)
* Fix of deploy VM with a snapshot that is copied to another zone * Fix of creating StorPool volume from a snapshot if the size in the offering is bigger than the snapshot size
1 parent 2a8d113 commit 498227b

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadTemplateCommandWrapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ public CopyCmdAnswer execute(final StorPoolDownloadTemplateCommand cmd, final Li
103103
final QemuImgFile srcFile = new QemuImgFile(srcDisk.getPath(), srcDisk.getFormat());
104104

105105
final QemuImg qemu = new QemuImg(cmd.getWaitInMillSeconds());
106-
StorPoolStorageAdaptor.resize( Long.toString(srcDisk.getVirtualSize()), dst.getPath());
107106

108107
if (dst instanceof TemplateObjectTO) {
108+
StorPoolStorageAdaptor.resize(Long.toString(srcDisk.getVirtualSize()), dst.getPath());
109+
109110
((TemplateObjectTO) dst).setSize(srcDisk.getVirtualSize());
110111
}
111112

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4327,15 +4327,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
43274327
}
43284328

43294329
DiskOfferingVO rootDiskOffering = _diskOfferingDao.findById(rootDiskOfferingId);
4330-
long volumesSize = 0;
4331-
if (volume != null) {
4332-
volumesSize = volume.getSize();
4333-
} else if (snapshot != null) {
4334-
VolumeVO volumeVO = _volsDao.findById(snapshot.getVolumeId());
4335-
volumesSize = volumeVO != null ? volumeVO.getSize() : 0;
4336-
} else {
4337-
volumesSize = configureCustomRootDiskSize(customParameters, template, hypervisorType, rootDiskOffering);
4338-
}
4330+
long volumesSize = configureCustomRootDiskSize(customParameters, template, hypervisorType, rootDiskOffering);
43394331

43404332
if (rootDiskOffering.getEncrypt() && hypervisorType != HypervisorType.KVM) {
43414333
throw new InvalidParameterValueException("Root volume encryption is not supported for hypervisor type " + hypervisorType);
@@ -6460,7 +6452,6 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
64606452
}
64616453
_accountMgr.checkAccess(caller, null, true, volume);
64626454
templateId = volume.getTemplateId();
6463-
overrideDiskOfferingId = volume.getDiskOfferingId();
64646455
} else if (cmd.getSnapshotId() != null) {
64656456
snapshot = _snapshotDao.findById(cmd.getSnapshotId());
64666457
if (snapshot == null) {
@@ -6469,7 +6460,6 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
64696460
_accountMgr.checkAccess(caller, null, true, snapshot);
64706461
VolumeInfo volumeOfSnapshot = getVolume(snapshot.getVolumeId(), templateId, true);
64716462
templateId = volumeOfSnapshot.getTemplateId();
6472-
overrideDiskOfferingId = volumeOfSnapshot.getDiskOfferingId();
64736463
}
64746464

64756465
VirtualMachineTemplate template = null;

0 commit comments

Comments
 (0)