You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2025/10/07 12:29:11 UTC

(cloudstack) branch 4.20 updated (823cb00a0a0 -> aca82359606)

This is an automated email from the ASF dual-hosted git repository.

dahn pushed a change to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


    from 823cb00a0a0 server: do not enable the disabled local storage(s) on host connection during mgmt server / agent start (#11722)
     add a208db54ea8 linstor: use sparse/discard qemu-img convert on thin devices (#11787)
     new aca82359606 Merge branch '4.19' into 4.20

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 plugins/storage/volume/linstor/CHANGELOG.md        |  6 ++++
 .../LinstorRevertBackupSnapshotCommandWrapper.java | 22 +++++++++++--
 .../kvm/storage/LinstorStorageAdaptor.java         | 38 +---------------------
 .../storage/datastore/util/LinstorUtil.java        | 34 +++++++++++++++++++
 4 files changed, 60 insertions(+), 40 deletions(-)


(cloudstack) 01/01: Merge branch '4.19' into 4.20

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git

commit aca823596067522b0f63b3220807cc906fd8d673
Merge: 823cb00a0a0 a208db54ea8
Author: Daan Hoogland <da...@apache.org>
AuthorDate: Tue Oct 7 14:28:47 2025 +0200

    Merge branch '4.19' into 4.20

 plugins/storage/volume/linstor/CHANGELOG.md        |  6 ++++
 .../LinstorRevertBackupSnapshotCommandWrapper.java | 22 +++++++++++--
 .../kvm/storage/LinstorStorageAdaptor.java         | 38 +---------------------
 .../storage/datastore/util/LinstorUtil.java        | 34 +++++++++++++++++++
 4 files changed, 60 insertions(+), 40 deletions(-)

diff --cc plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorRevertBackupSnapshotCommandWrapper.java
index 252cb6c7327,98b8bf0bb78..2d6df5f2296
--- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorRevertBackupSnapshotCommandWrapper.java
+++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LinstorRevertBackupSnapshotCommandWrapper.java
@@@ -32,18 -34,33 +34,31 @@@ import org.apache.cloudstack.storage.to
  import org.apache.cloudstack.utils.qemu.QemuImg;
  import org.apache.cloudstack.utils.qemu.QemuImgException;
  import org.apache.cloudstack.utils.qemu.QemuImgFile;
 -import org.apache.log4j.Logger;
+ import org.joda.time.Duration;
  import org.libvirt.LibvirtException;
  
  @ResourceWrapper(handles = LinstorRevertBackupSnapshotCommand.class)
  public final class LinstorRevertBackupSnapshotCommandWrapper
      extends CommandWrapper<LinstorRevertBackupSnapshotCommand, CopyCmdAnswer, LibvirtComputingResource>
  {
-     private void convertQCow2ToRAW(final String srcPath, final String dstPath, int waitMilliSeconds)
 -    private static final Logger s_logger = Logger.getLogger(LinstorRevertBackupSnapshotCommandWrapper.class);
+ 
+     private void convertQCow2ToRAW(
+             KVMStoragePool pool, final String srcPath, final String dstUuid, int waitMilliSeconds)
          throws LibvirtException, QemuImgException
      {
+         final String dstPath = pool.getPhysicalDisk(dstUuid).getPath();
          final QemuImgFile srcQemuFile = new QemuImgFile(
              srcPath, QemuImg.PhysicalDiskFormat.QCOW2);
-         final QemuImg qemu = new QemuImg(waitMilliSeconds);
+         boolean zeroedDevice = LinstorUtil.resourceSupportZeroBlocks(pool, LinstorUtil.RSC_PREFIX + dstUuid);
+         if (zeroedDevice)
+         {
+             // blockdiscard the device to ensure the device is filled with zeroes
+             Script blkDiscardScript = new Script("blkdiscard", Duration.millis(waitMilliSeconds));
+             blkDiscardScript.add("-f");
+             blkDiscardScript.add(dstPath);
+             blkDiscardScript.execute();
+         }
+         final QemuImg qemu = new QemuImg(waitMilliSeconds, zeroedDevice, true);
          final QemuImgFile dstFile = new QemuImgFile(dstPath, QemuImg.PhysicalDiskFormat.RAW);
          qemu.convert(srcQemuFile, dstFile);
      }
diff --cc plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java
index 40aca2fdd45,9a6151efafc..9c3c9d32611
--- a/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java
+++ b/plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/util/LinstorUtil.java
@@@ -42,13 -42,13 +42,14 @@@ import java.util.Map
  import java.util.Optional;
  import java.util.stream.Collectors;
  
+ import com.cloud.hypervisor.kvm.storage.KVMStoragePool;
  import com.cloud.utils.Pair;
  import com.cloud.utils.exception.CloudRuntimeException;
 -import org.apache.log4j.Logger;
 +import org.apache.logging.log4j.Logger;
 +import org.apache.logging.log4j.LogManager;
  
  public class LinstorUtil {
 -    private static final Logger s_logger = Logger.getLogger(LinstorUtil.class);
 +    protected static Logger LOGGER = LogManager.getLogger(LinstorUtil.class);
  
      public final static String PROVIDER_NAME = "Linstor";
      public static final String RSC_PREFIX = "cs-";
@@@ -431,4 -431,37 +432,37 @@@
      public static boolean isRscDiskless(ResourceWithVolumes rsc) {
          return rsc.getFlags() != null && rsc.getFlags().contains(ApiConsts.FLAG_DISKLESS);
      }
+ 
+     /**
+      * Checks if all diskful resource are on a zeroed block device.
+      * @param pool Linstor pool to use
+      * @param resName Linstor resource name
+      * @return true if all resources are on a provider with zeroed blocks.
+      */
+     public static boolean resourceSupportZeroBlocks(KVMStoragePool pool, String resName) {
+         final DevelopersApi api = getLinstorAPI(pool.getSourceHost());
+         try {
+             List<ResourceWithVolumes> resWithVols = api.viewResources(
+                     Collections.emptyList(),
+                     Collections.singletonList(resName),
+                     Collections.emptyList(),
+                     Collections.emptyList(),
+                     null,
+                     null);
+ 
+             if (resWithVols != null) {
+                 return resWithVols.stream()
+                         .allMatch(res -> {
+                             Volume vol0 = res.getVolumes().get(0);
+                             return vol0 != null && (vol0.getProviderKind() == ProviderKind.LVM_THIN ||
+                                     vol0.getProviderKind() == ProviderKind.ZFS ||
+                                     vol0.getProviderKind() == ProviderKind.ZFS_THIN ||
+                                     vol0.getProviderKind() == ProviderKind.DISKLESS);
+                         } );
+             }
+         } catch (ApiException apiExc) {
 -            s_logger.error(apiExc.getMessage());
++            LOGGER.error(apiExc.getMessage());
+         }
+         return false;
+     }
  }