Skip to content

Commit 0c2cf26

Browse files
committed
Fix encryption and migration not working on Shared mountpoint
1 parent 21b2025 commit 0c2cf26

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import java.util.ArrayList;
2525
import java.util.Arrays;
2626
import java.util.HashMap;
27-
import java.util.HashSet;
2827
import java.util.List;
2928
import java.util.Map;
3029
import java.util.Set;
@@ -97,8 +96,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
9796
public static final int RBD_FEATURES = RBD_FEATURE_LAYERING + RBD_FEATURE_EXCLUSIVE_LOCK + RBD_FEATURE_OBJECT_MAP + RBD_FEATURE_FAST_DIFF + RBD_FEATURE_DEEP_FLATTEN;
9897
private int rbdOrder = 0; /* Order 0 means 4MB blocks (the default) */
9998

100-
private static final Set<StoragePoolType> poolTypesThatEnableCreateDiskFromTemplateBacking = new HashSet<>(Arrays.asList(StoragePoolType.NetworkFilesystem,
101-
StoragePoolType.Filesystem));
99+
private static final Set<StoragePoolType> QEMU_IMG_MANAGED_POOL_TYPES = Set.of(StoragePoolType.NetworkFilesystem, StoragePoolType.Filesystem, StoragePoolType.SharedMountPoint);
102100

103101
public LibvirtStorageAdaptor(StorageLayer storage) {
104102
_storageLayer = storage;
@@ -134,8 +132,8 @@ public KVMPhysicalDisk createDiskFromTemplateBacking(KVMPhysicalDisk template, S
134132
String volumeDesc = String.format("volume [%s], with template backing [%s], in pool [%s] (%s), with size [%s] and encryption is %s", name, template.getName(), destPool.getUuid(),
135133
destPool.getType(), size, passphrase != null && passphrase.length > 0);
136134

137-
if (!poolTypesThatEnableCreateDiskFromTemplateBacking.contains(destPool.getType())) {
138-
logger.info(String.format("Skipping creation of %s due to pool type is none of the following types %s.", volumeDesc, poolTypesThatEnableCreateDiskFromTemplateBacking.stream()
135+
if (!QEMU_IMG_MANAGED_POOL_TYPES.contains(destPool.getType())) {
136+
logger.info(String.format("Skipping creation of %s due to pool type is none of the following types %s.", volumeDesc, QEMU_IMG_MANAGED_POOL_TYPES.stream()
139137
.map(type -> type.toString()).collect(Collectors.joining(", "))));
140138

141139
return null;
@@ -979,7 +977,7 @@ public boolean deleteStoragePool(String uuid) {
979977
* </ul>
980978
* </li>
981979
* <li>
982-
* {@link StoragePoolType#NetworkFilesystem} and {@link StoragePoolType#Filesystem}
980+
* {@link StoragePoolType#NetworkFilesystem}, {@link StoragePoolType#Filesystem} and {@link StoragePoolType#SharedMountPoint}
983981
* <ul>
984982
* <li>
985983
* If the format is {@link PhysicalDiskFormat#QCOW2} or {@link PhysicalDiskFormat#RAW}, utilizes QemuImg to create the physical disk through the method
@@ -1010,7 +1008,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
10101008

10111009
return (dataPool == null) ? createPhysicalDiskByLibVirt(name, pool, PhysicalDiskFormat.RAW, provisioningType, size) :
10121010
createPhysicalDiskByQemuImg(name, pool, PhysicalDiskFormat.RAW, provisioningType, size, passphrase);
1013-
} else if (StoragePoolType.NetworkFilesystem.equals(poolType) || StoragePoolType.Filesystem.equals(poolType)) {
1011+
} else if (QEMU_IMG_MANAGED_POOL_TYPES.contains(poolType)) {
10141012
switch (format) {
10151013
case QCOW2:
10161014
case RAW:
@@ -1080,7 +1078,7 @@ private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool
10801078
destFile.setFormat(format);
10811079
destFile.setSize(size);
10821080
Map<String, String> options = new HashMap<String, String>();
1083-
if (List.of(StoragePoolType.NetworkFilesystem, StoragePoolType.Filesystem).contains(pool.getType())) {
1081+
if (QEMU_IMG_MANAGED_POOL_TYPES.contains(pool.getType())) {
10841082
options.put(QemuImg.PREALLOCATION, QemuImg.PreallocationType.getPreallocationType(provisioningType).toString());
10851083
}
10861084

0 commit comments

Comments
 (0)