Skip to content

Support Direct Download on Ceph primary storage #11069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,35 @@
} 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);

Check warning on line 230 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java#L228-L230

Added lines #L228 - L230 were not covered by tests
}
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()));
Copy link
Contributor

@wido wido Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line here makes that it doesn't need ceph.conf, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my case the logs indicated that qemu img was looking for ceph.conf at diferent directories and failed as it couldn't find it. Probably it could be some misconfiguration at my side, will explore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was initially testing on 4.20 branch and the RBDStringBuilder was accepting more parameters, I have now recreated the env using this PR packages and I don't observe the failure anymore

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

Check warning on line 254 in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java#L235-L254

Added lines #L235 - L254 were not covered by tests

public StorageVol getVolume(StoragePool pool, String volName) {
StorageVol vol = null;

Expand Down
Loading