Skip to content

Commit 2c4ae08

Browse files
ArkaniadDaanHoogland
authored andcommitted
CLOUDSTACK-5907, CLOUDSTACK-6396: KVM/RBD & KVM/CLVM volumes mistakenly shown as OVM, disables snapshotting
modified: server/src/com/cloud/api/ApiDBUtils.java Signed-off-by: Daan Hoogland <daan@onecht.net>
1 parent 149cb33 commit 2c4ae08

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎server/src/com/cloud/api/ApiDBUtils.java‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.ArrayList;
2020
import java.util.EnumSet;
2121
import java.util.List;
22+
import java.util.ListIterator;
2223
import java.util.Map;
2324
import java.util.Set;
2425

@@ -236,6 +237,7 @@
236237
import com.cloud.storage.Snapshot;
237238
import com.cloud.storage.SnapshotVO;
238239
import com.cloud.storage.Storage.ImageFormat;
240+
import com.cloud.storage.Storage.StoragePoolType;
239241
import com.cloud.storage.StorageManager;
240242
import com.cloud.storage.StoragePool;
241243
import com.cloud.storage.StorageStats;
@@ -1071,6 +1073,26 @@ public static HypervisorType getHypervisorTypeFromFormat(long dcId, ImageFormat
10711073
if (xenClusters.isEmpty()) {
10721074
type = HypervisorType.Hyperv;
10731075
}
1076+
} if (format == ImageFormat.RAW) {
1077+
// Currently, KVM only suppoorts RBD images of type RAW.
1078+
// This results in a weird collision with OVM volumes which
1079+
// can only be raw, thus making KVM RBD volumes show up as OVM
1080+
// rather than RBD. This block of code can (hopefuly) by checking to
1081+
// see if the pool is using either RBD or NFS. However, it isn't
1082+
// quite clear what to do if both storage types are used. If the image
1083+
// format is RAW, it narrows the hypervisor choice down to OVM and KVM / RBD or KVM / CLVM
1084+
// This would be better implemented at a cluster level.
1085+
List<StoragePoolVO> pools = s_storagePoolDao.listByDataCenterId(dcId);
1086+
ListIterator<StoragePoolVO> itr = pools.listIterator();
1087+
while(itr.hasNext()) {
1088+
StoragePoolVO pool = itr.next();
1089+
if(pool.getPoolType() == StoragePoolType.RBD || pool.getPoolType() == StoragePoolType.CLVM) {
1090+
// This case will note the presence of non-qcow2 primary stores, suggesting KVM without NFS. Otherwse,
1091+
// If this check is not passed, the hypervisor type will remain OVM.
1092+
type = HypervisorType.KVM;
1093+
break;
1094+
}
1095+
}
10741096
}
10751097
return type;
10761098
}

0 commit comments

Comments
 (0)