Skip to content

Commit 2652739

Browse files
committed
Fix of deployment VM from a copied snapshot in another zone
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 76cfcb4 commit 2652739

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
@@ -4192,15 +4192,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
41924192
}
41934193

41944194
DiskOfferingVO rootDiskOffering = _diskOfferingDao.findById(rootDiskOfferingId);
4195-
long volumesSize = 0;
4196-
if (volume != null) {
4197-
volumesSize = volume.getSize();
4198-
} else if (snapshot != null) {
4199-
VolumeVO volumeVO = _volsDao.findById(snapshot.getVolumeId());
4200-
volumesSize = volumeVO != null ? volumeVO.getSize() : 0;
4201-
} else {
4202-
volumesSize = configureCustomRootDiskSize(customParameters, template, hypervisorType, rootDiskOffering);
4203-
}
4195+
long volumesSize = configureCustomRootDiskSize(customParameters, template, hypervisorType, rootDiskOffering);
42044196

42054197
if (rootDiskOffering.getEncrypt() && hypervisorType != HypervisorType.KVM) {
42064198
throw new InvalidParameterValueException("Root volume encryption is not supported for hypervisor type " + hypervisorType);
@@ -6222,7 +6214,6 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
62226214
}
62236215
_accountMgr.checkAccess(caller, null, true, volume);
62246216
templateId = volume.getTemplateId();
6225-
overrideDiskOfferingId = volume.getDiskOfferingId();
62266217
} else if (cmd.getSnapshotId() != null) {
62276218
snapshot = _snapshotDao.findById(cmd.getSnapshotId());
62286219
if (snapshot == null) {
@@ -6231,7 +6222,6 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
62316222
_accountMgr.checkAccess(caller, null, true, snapshot);
62326223
VolumeInfo volumeOfSnapshot = getVolume(snapshot.getVolumeId(), templateId, true);
62336224
templateId = volumeOfSnapshot.getTemplateId();
6234-
overrideDiskOfferingId = volumeOfSnapshot.getDiskOfferingId();
62356225
}
62366226

62376227
boolean dynamicScalingEnabled = cmd.isDynamicScalingEnabled();

0 commit comments

Comments
 (0)