Skip to content

Fix in the calculation of a volume's physical size - #13286

Open
Tonitzpp wants to merge 2 commits into
apache:4.22from
scclouds:fix-calculation-volume-physicalsize
Open

Fix in the calculation of a volume's physical size#13286
Tonitzpp wants to merge 2 commits into
apache:4.22from
scclouds:fix-calculation-volume-physicalsize

Conversation

@Tonitzpp

Copy link
Copy Markdown
Contributor

Description

Currently, when using the KVM hypervisor, the calculation of a volume's physical size ignores the backing files (if they exist) as part of the volume's physical size in storage, which can cause confusion for users. This behavior has been changed in this PR so that the backing files are now taken into account for the volume's physical size.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

To perform the tests, I created a new VM with a backing file, and after that I took a few backups of this VM. Then, when checking the volume of this VM, it was observed that the physical size is proportional to the physical size in the storage.

@winterhazel winterhazel added this to the 4.22.2 milestone May 29, 2026
@winterhazel

Copy link
Copy Markdown
Member

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes KVM volume physical-size reporting by including the storage allocation of QCOW2 backing files in the reported KVMPhysicalDisk.size, aligning the “physical size” users see with actual storage usage when backing chains exist.

Changes:

  • Added XML parsing to detect a volume’s backing file from libvirt volume XML.
  • Updated KVM volume size calculation to recursively sum allocation across the backing chain.
  • Added a getter on LibvirtStorageVolumeDef (though not directly used by the new sizing flow).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java Recursively sums backing-file allocations and uses the result as the disk “physical size”.
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeXMLParser.java Adds backing-store parsing from volume XML to resolve backing file names.
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtStorageVolumeDef.java Adds getVolSize() accessor for the volume size field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented May 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.93%. Comparing base (9030443) to head (01ea312).

Files with missing lines Patch % Lines
.../hypervisor/kvm/storage/LibvirtStorageAdaptor.java 0.00% 25 Missing ⚠️
...or/kvm/resource/LibvirtStorageVolumeXMLParser.java 0.00% 23 Missing ⚠️
...pervisor/kvm/resource/LibvirtStorageVolumeDef.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.22   #13286      +/-   ##
============================================
- Coverage     17.94%   17.93%   -0.01%     
  Complexity    16147    16147              
============================================
  Files          5928     5928              
  Lines        535174   535224      +50     
  Branches      65494    65500       +6     
============================================
  Hits          96019    96019              
- Misses       428226   428276      +50     
  Partials      10929    10929              
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 19.01% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 18087

@JoaoJandre JoaoJandre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CLGTM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

@sureshanaparti

Copy link
Copy Markdown
Contributor

@Tonitzpp can you check and address the copilot comments if relavant. thanks.

@bernardodemarco

Copy link
Copy Markdown
Member

@GeanJair, could you take a look at @JoaoJandre's suggestion, please? (see #13286 (comment))

@DaanHoogland DaanHoogland moved this from Backlog to Ready in CloudStack Testing Sep 1, 2026
@abh1sar abh1sar self-assigned this Sep 8, 2026
@abh1sar abh1sar moved this from Ready to In progress in CloudStack Testing Sep 9, 2026
@abh1sar

abh1sar commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 19204

@JoaoJandre

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 19206

@abh1sar

abh1sar commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan

Copy link
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 19218

@abh1sar abh1sar closed this Sep 11, 2026
@github-project-automation github-project-automation Bot moved this from In progress to Done in CloudStack Testing Sep 11, 2026
@abh1sar abh1sar reopened this Sep 11, 2026
@abh1sar

abh1sar commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Looks like there is a compilation error @Tonitzpp

13:27:27 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project cloud-plugin-hypervisor-kvm: Compilation failure
13:27:27 [ERROR] /jenkins/workspace/acs-deb-pkg-builder/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java:[666,34] error: cannot find symbol
13:27:27 [ERROR]   symbol:   class HashSet
13:27:27 [ERROR]   location: class LibvirtStorageAdaptor

@GeanJair
GeanJair force-pushed the fix-calculation-volume-physicalsize branch from 841513d to 77fbaba Compare September 11, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

10 participants