Skip to content

Commit aaa2a61

Browse files
bradh352claude
andcommitted
kvm: apply rbd_default_data_pool when creating volumes from templates on RBD
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. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 21b2025 commit aaa2a61

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,8 @@ private KVMPhysicalDisk createDiskFromTemplateOnRBD(KVMPhysicalDisk template,
13501350
*/
13511351

13521352
KVMStoragePool srcPool = template.getPool();
1353+
Map<String, String> destDetails = destPool.getDetails();
1354+
String dataPool = (destDetails == null) ? null : destDetails.get(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL);
13531355
KVMPhysicalDisk disk = null;
13541356
String newUuid = name;
13551357

@@ -1398,6 +1400,10 @@ private KVMPhysicalDisk createDiskFromTemplateOnRBD(KVMPhysicalDisk template,
13981400
r.confSet("mon_host", srcPool.getSourceHost() + ":" + srcPool.getSourcePort());
13991401
r.confSet("key", srcPool.getAuthSecret());
14001402
r.confSet("client_mount_timeout", "30");
1403+
if (dataPool != null) {
1404+
logger.debug("Setting RBD data pool to " + dataPool + " for the new image " + disk.getName());
1405+
r.confSet(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL, dataPool);
1406+
}
14011407
r.connect();
14021408
logger.debug("Successfully connected to Ceph cluster at " + r.confGet("mon_host"));
14031409

@@ -1476,6 +1482,10 @@ private KVMPhysicalDisk createDiskFromTemplateOnRBD(KVMPhysicalDisk template,
14761482
rDest.confSet("mon_host", destPool.getSourceHost() + ":" + destPool.getSourcePort());
14771483
rDest.confSet("key", destPool.getAuthSecret());
14781484
rDest.confSet("client_mount_timeout", "30");
1485+
if (dataPool != null) {
1486+
logger.debug("Setting RBD data pool to " + dataPool + " on the destination cluster for the new image " + disk.getName());
1487+
rDest.confSet(KVMPhysicalDisk.RBD_DEFAULT_DATA_POOL, dataPool);
1488+
}
14791489
rDest.connect();
14801490
logger.debug("Successfully connected to source Ceph cluster at " + rDest.confGet("mon_host"));
14811491

0 commit comments

Comments
 (0)