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
This commit is contained in:
slavkap 2025-08-07 15:47:57 +03:00 committed by GitHub
parent ae95be3702
commit dc5e475bd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 12 deletions

View File

@ -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());
}

View File

@ -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;