You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2026/09/14 08:38:19 UTC

(cloudstack) branch 4.22 updated: kvm: apply rbd_default_data_pool when creating volumes from templates on RBD (#13361)

This is an automated email from the ASF dual-hosted git repository.

weizhouapache pushed a commit to branch 4.22
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.22 by this push:
     new e38b7a724b1 kvm: apply rbd_default_data_pool when creating volumes from templates on RBD (#13361)
e38b7a724b1 is described below

commit e38b7a724b1505d6052d1bc24cedca4601b60f48
Author: Brad House - Nexthop <bh...@nexthop.ai>
AuthorDate: Mon Sep 14 04:38:11 2026 -0400

    kvm: apply rbd_default_data_pool when creating volumes from templates on RBD (#13361)
    
    RBD erasure-coded pool support (#9808) added handling of the
    rbd_default_data_pool storage-pool detail to RBDStringBuilder (qemu-img
    path) and to createPhysicalDisk (blank volumes), but not to
    createDiskFromTemplateOnRBD. As a result, ROOT volumes created from a
    template via rados-java rbd.clone()/rbd.create() are created without a
    data pool: all of their data objects land in the (replicated) metadata
    pool instead of the erasure-coded data pool, defeating the point of EC
    and consuming ~3x raw space.
    
    Set rbd_default_data_pool on the Rados connection (before connect) in
    both the same-cluster clone/copy branch and the cross-cluster copy
    branch of createDiskFromTemplateOnRBD, using the destination pool's
    detail. librbd then honors it as the default data pool when the new
    image is created, so template-derived volumes get data_pool set, the
    same way blank volumes already do.
---
 .../cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java    | 10 ++++++++++
 1 file changed, 10 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 6c21065340c..059f4f8b67a 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
@@ -1348,6 +1348,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
          */
 
         KVMStoragePool srcPool = template.getPool();
+        Map<String, String> destDetails = destPool.getDetails();
+        String dataPool = (destDetails == null) ? null : destDetails.get(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL);
         KVMPhysicalDisk disk = null;
         String newUuid = name;
 
@@ -1396,6 +1398,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                     r.confSet("mon_host", srcPool.getSourceHost() + ":" + srcPool.getSourcePort());
                     r.confSet("key", srcPool.getAuthSecret());
                     r.confSet("client_mount_timeout", "30");
+                    if (dataPool != null) {
+                        logger.debug("Setting RBD data pool to " + dataPool + " for the new image " + disk.getName());
+                        r.confSet(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL, dataPool);
+                    }
                     r.connect();
                     logger.debug("Successfully connected to Ceph cluster at " + r.confGet("mon_host"));
 
@@ -1474,6 +1480,10 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
                     rDest.confSet("mon_host", destPool.getSourceHost() + ":" + destPool.getSourcePort());
                     rDest.confSet("key", destPool.getAuthSecret());
                     rDest.confSet("client_mount_timeout", "30");
+                    if (dataPool != null) {
+                        logger.debug("Setting RBD data pool to " + dataPool + " on the destination cluster for the new image " + disk.getName());
+                        rDest.confSet(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL, dataPool);
+                    }
                     rDest.connect();
                     logger.debug("Successfully connected to source Ceph cluster at " + rDest.confGet("mon_host"));