Skip to content

Commit dc5e475

Browse files
authored
Fix of deployment VM from a copied snapshot in another zone (#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 ae95be3 commit dc5e475

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
@@ -4195,15 +4195,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
41954195
}
41964196

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

42084200
if (rootDiskOffering.getEncrypt() && hypervisorType != HypervisorType.KVM) {
42094201
throw new InvalidParameterValueException("Root volume encryption is not supported for hypervisor type " + hypervisorType);
@@ -6292,7 +6284,6 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
62926284
}
62936285
_accountMgr.checkAccess(caller, null, true, volume);
62946286
templateId = volume.getTemplateId();
6295-
overrideDiskOfferingId = volume.getDiskOfferingId();
62966287
} else if (cmd.getSnapshotId() != null) {
62976288
snapshot = _snapshotDao.findById(cmd.getSnapshotId());
62986289
if (snapshot == null) {
@@ -6301,7 +6292,6 @@ public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityE
63016292
_accountMgr.checkAccess(caller, null, true, snapshot);
63026293
VolumeInfo volumeOfSnapshot = getVolume(snapshot.getVolumeId(), templateId, true);
63036294
templateId = volumeOfSnapshot.getTemplateId();
6304-
overrideDiskOfferingId = volumeOfSnapshot.getDiskOfferingId();
63056295
}
63066296

63076297
VirtualMachineTemplate template = null;

0 commit comments

Comments
 (0)