This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/main by this push:
new dc5e475bd2d Fix of deployment VM from a copied snapshot in another
zone (#11351)
dc5e475bd2d is described below
commit dc5e475bd2d3e92787b097e23aaea22b69d63e4a
Author: slavkap <[email protected]>
AuthorDate: Thu Aug 7 15:47:57 2025 +0300
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
---
.../wrapper/StorPoolDownloadTemplateCommandWrapper.java | 3 ++-
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java | 12 +-----------
2 files changed, 3 insertions(+), 12 deletions(-)
diff --git
a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadTemplateCommandWrapper.java
b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadTemplateCommandWrapper.java
index 3e7118ab81d..da67812cbbe 100644
---
a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadTemplateCommandWrapper.java
+++
b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/StorPoolDownloadTemplateCommandWrapper.java
@@ -103,9 +103,10 @@ public final class StorPoolDownloadTemplateCommandWrapper
extends CommandWrapper
final QemuImgFile srcFile = new QemuImgFile(srcDisk.getPath(),
srcDisk.getFormat());
final QemuImg qemu = new QemuImg(cmd.getWaitInMillSeconds());
- StorPoolStorageAdaptor.resize(
Long.toString(srcDisk.getVirtualSize()), dst.getPath());
if (dst instanceof TemplateObjectTO) {
+
StorPoolStorageAdaptor.resize(Long.toString(srcDisk.getVirtualSize()),
dst.getPath());
+
((TemplateObjectTO) dst).setSize(srcDisk.getVirtualSize());
}
diff --git a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
index 6cdcba7e3b6..cd7d198eb61 100644
--- a/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
@@ -4195,15 +4195,7 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
}
DiskOfferingVO rootDiskOffering =
_diskOfferingDao.findById(rootDiskOfferingId);
- long volumesSize = 0;
- if (volume != null) {
- volumesSize = volume.getSize();
- } else if (snapshot != null) {
- VolumeVO volumeVO = _volsDao.findById(snapshot.getVolumeId());
- volumesSize = volumeVO != null ? volumeVO.getSize() : 0;
- } else {
- volumesSize = configureCustomRootDiskSize(customParameters,
template, hypervisorType, rootDiskOffering);
- }
+ long volumesSize = configureCustomRootDiskSize(customParameters,
template, hypervisorType, rootDiskOffering);
if (rootDiskOffering.getEncrypt() && hypervisorType !=
HypervisorType.KVM) {
throw new InvalidParameterValueException("Root volume encryption
is not supported for hypervisor type " + hypervisorType);
@@ -6292,7 +6284,6 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
}
_accountMgr.checkAccess(caller, null, true, volume);
templateId = volume.getTemplateId();
- overrideDiskOfferingId = volume.getDiskOfferingId();
} else if (cmd.getSnapshotId() != null) {
snapshot = _snapshotDao.findById(cmd.getSnapshotId());
if (snapshot == null) {
@@ -6301,7 +6292,6 @@ public class UserVmManagerImpl extends ManagerBase
implements UserVmManager, Vir
_accountMgr.checkAccess(caller, null, true, snapshot);
VolumeInfo volumeOfSnapshot = getVolume(snapshot.getVolumeId(),
templateId, true);
templateId = volumeOfSnapshot.getTemplateId();
- overrideDiskOfferingId = volumeOfSnapshot.getDiskOfferingId();
}
VirtualMachineTemplate template = null;