Skip to content

enabled discard option #10077

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 2 commits into from
Jun 14, 2025
Merged

enabled discard option #10077

merged 2 commits into from
Jun 14, 2025

Conversation

slavkap
Copy link
Contributor

@slavkap slavkap commented Dec 10, 2024

Description

Enable the discard option for virtio-blk and virtio-scsi devices for volumes on StorPool storage

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

How Has This Been Tested?

manually tested with different controllers and UEFI legacy/secured
deploy a VM
attach volume

Enable the discard option for virtio-blk and virtio-scsi devices for
volumes on StorPool storage
Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 16.06%. Comparing base (c94d0ab) to head (63e0cd6).
Report is 472 commits behind head on main.

Files with missing lines Patch % Lines
...ud/hypervisor/kvm/storage/StorPoolStoragePool.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #10077      +/-   ##
============================================
- Coverage     16.06%   16.06%   -0.01%     
- Complexity    12862    12863       +1     
============================================
  Files          5641     5642       +1     
  Lines        493791   493856      +65     
  Branches      59858    59860       +2     
============================================
+ Hits          79318    79326       +8     
- Misses       405691   405749      +58     
+ Partials       8782     8781       -1     
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 16.90% <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 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.

@DaanHoogland DaanHoogland added this to the 4.21.0 milestone Dec 10, 2024
Copy link
Contributor

@BryanMLima BryanMLima left a comment

Choose a reason for hiding this comment

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

CLGTM

rearrange imports
@DaanHoogland
Copy link
Contributor

Code looks ok, but we need to rely on your testing, @slavkap !

Copy link
Contributor

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

minor: @slavkap would something like this improve readability?

--- a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStoragePool.java
+++ b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStoragePool.java
@@ -16,11 +16,13 @@
 // under the License.
 package com.cloud.hypervisor.kvm.storage;
 
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat;
 
+import com.cloud.hypervisor.kvm.resource.LibvirtVMDef;
 import com.cloud.storage.Storage;
 import com.cloud.storage.Storage.StoragePoolType;
 
@@ -35,6 +37,11 @@ public class StorPoolStoragePool implements KVMStoragePool {
     private String _sourceDir;
     private String _localPath;
 
+    private static final List<LibvirtVMDef.DiskDef.DiskBus> supportedBusTypes = Arrays.asList(
+            LibvirtVMDef.DiskDef.DiskBus.VIRTIO,
+            LibvirtVMDef.DiskDef.DiskBus.SCSI
+    );
+
     public StorPoolStoragePool(String uuid, String host, int port, StoragePoolType storagePoolType, StorageAdaptor storageAdaptor) {
         _uuid = uuid;
         _sourceHost = host;
@@ -166,4 +173,11 @@ public class StorPoolStoragePool implements KVMStoragePool {
     public Map<String, String> getDetails() {
         return null;
     }
+
+    public void customizeLibvirtDiskDef(LibvirtVMDef.DiskDef disk) {
+        if (!supportedBusTypes.contains(disk.getBusType())) {
+            return;
+        }
+        disk.setDiscard(LibvirtVMDef.DiskDef.DiscardType.UNMAP);
+    }
 }

@wido wido self-requested a review January 13, 2025 13:37
Copy link
Contributor

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

@sureshanaparti
Copy link
Contributor

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

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File

@DaanHoogland DaanHoogland merged commit 28ff19b into apache:main Jun 14, 2025
25 of 26 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Apache CloudStack 4.21.0 Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants