This is an automated email from the ASF dual-hosted git repository.
dahn 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 16c60c7528a Support Direct Download on Ceph (#11069)
16c60c7528a is described below
commit 16c60c7528a3ee731bceaa9113d5e6a76b22a246
Author: Nicolas Vazquez <[email protected]>
AuthorDate: Tue Jun 24 09:19:01 2025 -0300
Support Direct Download on Ceph (#11069)
---
.../kvm/storage/LibvirtStorageAdaptor.java | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index c0d58c57908..7c66a91876f 100644
---
a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++
b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -224,10 +224,35 @@ public class LibvirtStorageAdaptor implements
StorageAdaptor {
} else {
Script.runSimpleBashScript("mv " + templateFilePath + " " +
destinationFile);
}
+ } else if (destPool.getType() == StoragePoolType.RBD) {
+ String temporaryExtractFilePath = sourceFile.getParent() +
File.separator + templateUuid;
+ extractDownloadedTemplate(templateFilePath, destPool,
temporaryExtractFilePath);
+
createTemplateOnRBDFromDirectDownloadFile(temporaryExtractFilePath,
templateUuid, destPool, timeout);
}
return destPool.getPhysicalDisk(templateUuid);
}
+ private void createTemplateOnRBDFromDirectDownloadFile(String
srcTemplateFilePath, String templateUuid, KVMStoragePool destPool, int timeout)
{
+ try {
+ QemuImg.PhysicalDiskFormat srcFileFormat =
QemuImg.PhysicalDiskFormat.QCOW2;
+ QemuImgFile srcFile = new QemuImgFile(srcTemplateFilePath,
srcFileFormat);
+ QemuImg qemu = new QemuImg(timeout);
+ Map<String, String> info = qemu.info(srcFile);
+ Long virtualSize = Long.parseLong(info.get(QemuImg.VIRTUAL_SIZE));
+ KVMPhysicalDisk destDisk = new
KVMPhysicalDisk(destPool.getSourceDir() + "/" + templateUuid, templateUuid,
destPool);
+ destDisk.setFormat(PhysicalDiskFormat.RAW);
+ destDisk.setSize(virtualSize);
+ destDisk.setVirtualSize(virtualSize);
+ QemuImgFile destFile = new
QemuImgFile(KVMPhysicalDisk.RBDStringBuilder(destPool, destDisk.getPath()));
+ destFile.setFormat(PhysicalDiskFormat.RAW);
+ qemu.convert(srcFile, destFile);
+ } catch (LibvirtException | QemuImgException e) {
+ String err = String.format("Error creating template from direct
download file on pool %s: %s", destPool.getUuid(), e.getMessage());
+ logger.error(err, e);
+ throw new CloudRuntimeException(err, e);
+ }
+ }
+
public StorageVol getVolume(StoragePool pool, String volName) {
StorageVol vol = null;