From 5ac44896c8ad2e5838f91b841d9d041790d17775 Mon Sep 17 00:00:00 2001 From: Tanner Danzey Date: Mon, 14 Apr 2014 16:52:05 -0500 Subject: [PATCH] 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 (cherry picked from commit 601827e6b34cb7debe67a8415a09440c389ba4a1) Signed-off-by: Rohit Yadav --- server/src/com/cloud/api/ApiDBUtils.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java index 2617097cbeb..1df872e0f4f 100755 --- a/server/src/com/cloud/api/ApiDBUtils.java +++ b/server/src/com/cloud/api/ApiDBUtils.java @@ -19,6 +19,7 @@ package com.cloud.api; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Set; @@ -233,6 +234,7 @@ import com.cloud.storage.ImageStore; import com.cloud.storage.Snapshot; import com.cloud.storage.SnapshotVO; import com.cloud.storage.Storage.ImageFormat; +import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePool; import com.cloud.storage.StorageStats; @@ -969,6 +971,26 @@ public class ApiDBUtils { if (xenClusters.isEmpty()) { type = HypervisorType.Hyperv; } + } if (format == ImageFormat.RAW) { + // Currently, KVM only suppoorts RBD images of type RAW. + // This results in a weird collision with OVM volumes which + // can only be raw, thus making KVM RBD volumes show up as OVM + // rather than RBD. This block of code can (hopefuly) by checking to + // see if the pool is using either RBD or NFS. However, it isn't + // quite clear what to do if both storage types are used. If the image + // format is RAW, it narrows the hypervisor choice down to OVM and KVM / RBD or KVM / CLVM + // This would be better implemented at a cluster level. + List pools = s_storagePoolDao.listByDataCenterId(dcId); + ListIterator itr = pools.listIterator(); + while(itr.hasNext()) { + StoragePoolVO pool = itr.next(); + if(pool.getPoolType() == StoragePoolType.RBD || pool.getPoolType() == StoragePoolType.CLVM) { + // This case will note the presence of non-qcow2 primary stores, suggesting KVM without NFS. Otherwse, + // If this check is not passed, the hypervisor type will remain OVM. + type = HypervisorType.KVM; + break; + } + } } return type; }