Damans227 commented on code in PR #13286:
URL: https://github.com/apache/cloudstack/pull/13286#discussion_r4259120665


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:
##########
@@ -663,8 +692,9 @@ public KVMPhysicalDisk getPhysicalDisk(String volumeUuid, 
KVMStoragePool pool) {
             StorageVol vol = getVolume(libvirtPool.getPool(), volumeUuid);
             KVMPhysicalDisk disk;
             LibvirtStorageVolumeDef voldef = 
getStorageVolumeDef(libvirtPool.getPool().getConnect(), vol);
+            Long allSizes = getBackingFileSizes(libvirtPool.getPool(), vol);
             disk = new KVMPhysicalDisk(vol.getPath(), vol.getName(), pool);
-            disk.setSize(vol.getInfo().allocation);
+            disk.setSize(allSizes);

Review Comment:
   wont every volume made from the same template now count the whole template 
too? adding up the volumes on a pool would count it many times



##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:
##########
@@ -655,6 +662,28 @@ public KVMStoragePool getStoragePool(String uuid, boolean 
refreshInfo) {
         }
     }
 
+    private Long getBackingFileSizes(StoragePool pool, StorageVol vol) throws 
LibvirtException {
+        long total = 0L;
+        Set<String> visited = new HashSet<>();
+        StorageVol current = vol;
+
+        while (current != null) {
+            total += current.getInfo().allocation;
+            String backingName = getBackingFileOfVolumeIfExists(current);
+            if (StringUtils.isBlank(backingName) || !visited.add(backingName)) 
{
+                break;
+            }
+            try {
+                current = getVolume(pool, backingName);

Review Comment:
   what happens when the backing file isnt found in this pool? looks like each 
miss refreshes the whole pool, and this runs for every volume on each stats pass



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to