Skip to content

Validate qcow2 file during import operation #11264

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

Merged
merged 4 commits into from
Jul 25, 2025

Conversation

sureshanaparti
Copy link
Contributor

@sureshanaparti sureshanaparti commented Jul 23, 2025

Description

This PR validates qcow2 file during import operation (and has some code improvements).

Fixes #11260

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

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Copy link

codecov bot commented Jul 23, 2025

Codecov Report

Attention: Patch coverage is 16.57143% with 146 lines in your changes missing coverage. Please review.

Project coverage is 15.17%. Comparing base (3fc02dd) to head (210a3f2).
Report is 2 commits behind head on 4.19.

Files with missing lines Patch % Lines
...urce/wrapper/LibvirtCheckVolumeCommandWrapper.java 2.22% 44 Missing ⚠️
...wrapper/LibvirtCopyRemoteVolumeCommandWrapper.java 2.27% 43 Missing ⚠️
.../cloud/hypervisor/kvm/storage/KVMPhysicalDisk.java 0.00% 19 Missing ⚠️
.../apache/cloudstack/vm/UnmanagedVMsManagerImpl.java 28.00% 15 Missing and 3 partials ⚠️
...pper/LibvirtGetVolumesOnStorageCommandWrapper.java 64.51% 3 Missing and 8 partials ⚠️
...in/java/com/cloud/agent/api/CheckVolumeAnswer.java 0.00% 5 Missing ⚠️
...va/com/cloud/agent/api/CopyRemoteVolumeAnswer.java 0.00% 5 Missing ⚠️
...rce/wrapper/LibvirtResizeVolumeCommandWrapper.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.19   #11264      +/-   ##
============================================
- Coverage     15.18%   15.17%   -0.01%     
+ Complexity    11367    11363       -4     
============================================
  Files          5415     5415              
  Lines        475910   476025     +115     
  Branches      58099    58114      +15     
============================================
- Hits          72254    72246       -8     
- Misses       395569   395696     +127     
+ Partials       8087     8083       -4     
Flag Coverage Δ
uitests 4.28% <ø> (+<0.01%) ⬆️
unittests 15.90% <16.57%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@sureshanaparti sureshanaparti linked an issue Jul 23, 2025 that may be closed by this pull request
@sureshanaparti sureshanaparti requested a review from Copilot July 23, 2025 04:19
@sureshanaparti sureshanaparti added this to the 4.19.4 milestone Jul 23, 2025
Copy link

@Copilot Copilot AI left a comment

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 adds qcow2 file validation during import operations to enhance security and data integrity. The changes consolidate duplicate code for getting virtual size from disk files and introduce a new validation method for qcow2 files.

  • Consolidates duplicate getVirtualSizeFromFile method implementations into a single utility method
  • Adds qcow2 file validation using Qcow2Inspector.validateQcow2File
  • Integrates qcow2 validation into copy and check volume operations

Reviewed Changes

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

File Description
KVMPhysicalDisk.java Adds centralized utility methods for getting virtual size and validating qcow2 files
LibvirtResizeVolumeCommandWrapper.java Removes duplicate getVirtualSizeFromFile method and uses centralized version
LibvirtCopyRemoteVolumeCommandWrapper.java Removes duplicate method, adds qcow2 validation, and uses centralized utilities
LibvirtCheckVolumeCommandWrapper.java Removes duplicate method, adds qcow2 validation, and uses centralized utilities

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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

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

@sureshanaparti
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

Copy link
Contributor

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

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

code LGTM

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm, good cleanup

@sureshanaparti sureshanaparti marked this pull request as ready for review July 23, 2025 07:52
Copy link
Contributor

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

@sureshanaparti

Can you provide a similar error message Like

"Vm with backing file cannot be imported"

Screenshot 2025-07-23 at 4 59 08 PM

Current error message

Screenshot 2025-07-23 at 4 59 38 PM

@blueorangutan
Copy link

[SF] Trillian test result (tid-13848)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 57257 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11264-t13848-kvm-ol8.zip
Smoke tests completed. 132 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_03_secured_to_nonsecured_vm_migration Error 399.91 test_vm_life_cycle.py
test_04_nonsecured_to_secured_vm_migration Error 492.86 test_vm_life_cycle.py

…encrypted volume, and volume with backing file
@sureshanaparti sureshanaparti force-pushed the validate-qcow2-in-import branch from 541274e to 210a3f2 Compare July 24, 2025 08:10
@sureshanaparti
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti 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.

@sureshanaparti
Copy link
Contributor Author

@sureshanaparti

Can you provide a similar error message Like

"Vm with backing file cannot be imported"

@kiranchavala updated, please check with latest packages

@blueorangutan
Copy link

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

Copy link
Contributor

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

LGTM, Verified import vm from local and shared storage and correct exception was thrown

Screenshot 2025-07-25 at 2 07 03 PM Screenshot 2025-07-25 at 2 06 43 PM

@DaanHoogland DaanHoogland merged commit 75a2b3c into apache:4.19 Jul 25, 2025
25 of 26 checks passed
@DaanHoogland DaanHoogland deleted the validate-qcow2-in-import branch July 25, 2025 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

validate qcow2 for a backing file during vm import
5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy