|
24 | 24 | import java.util.ArrayList; |
25 | 25 | import java.util.Arrays; |
26 | 26 | import java.util.HashMap; |
27 | | -import java.util.HashSet; |
28 | 27 | import java.util.List; |
29 | 28 | import java.util.Map; |
30 | 29 | import java.util.Set; |
@@ -97,8 +96,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { |
97 | 96 | 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; |
98 | 97 | private int rbdOrder = 0; /* Order 0 means 4MB blocks (the default) */ |
99 | 98 |
|
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); |
102 | 100 |
|
103 | 101 | public LibvirtStorageAdaptor(StorageLayer storage) { |
104 | 102 | _storageLayer = storage; |
@@ -134,8 +132,8 @@ public KVMPhysicalDisk createDiskFromTemplateBacking(KVMPhysicalDisk template, S |
134 | 132 | 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(), |
135 | 133 | destPool.getType(), size, passphrase != null && passphrase.length > 0); |
136 | 134 |
|
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() |
139 | 137 | .map(type -> type.toString()).collect(Collectors.joining(", ")))); |
140 | 138 |
|
141 | 139 | return null; |
@@ -979,7 +977,7 @@ public boolean deleteStoragePool(String uuid) { |
979 | 977 | * </ul> |
980 | 978 | * </li> |
981 | 979 | * <li> |
982 | | - * {@link StoragePoolType#NetworkFilesystem} and {@link StoragePoolType#Filesystem} |
| 980 | + * {@link StoragePoolType#NetworkFilesystem}, {@link StoragePoolType#Filesystem} and {@link StoragePoolType#SharedMountPoint} |
983 | 981 | * <ul> |
984 | 982 | * <li> |
985 | 983 | * 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, |
1010 | 1008 |
|
1011 | 1009 | return (dataPool == null) ? createPhysicalDiskByLibVirt(name, pool, PhysicalDiskFormat.RAW, provisioningType, size) : |
1012 | 1010 | 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)) { |
1014 | 1012 | switch (format) { |
1015 | 1013 | case QCOW2: |
1016 | 1014 | case RAW: |
@@ -1080,7 +1078,7 @@ private KVMPhysicalDisk createPhysicalDiskByQemuImg(String name, KVMStoragePool |
1080 | 1078 | destFile.setFormat(format); |
1081 | 1079 | destFile.setSize(size); |
1082 | 1080 | 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())) { |
1084 | 1082 | options.put(QemuImg.PREALLOCATION, QemuImg.PreallocationType.getPreallocationType(provisioningType).toString()); |
1085 | 1083 | } |
1086 | 1084 |
|
|
0 commit comments