weizhouapache commented on code in PR #14162:
URL: https://github.com/apache/cloudstack/pull/14162#discussion_r4012534968
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckVolumeCommandWrapper.java:
##########
@@ -64,13 +65,24 @@ public Answer execute(final CheckVolumeCommand command,
final LibvirtComputingRe
if
(STORAGE_POOL_TYPES_SUPPORTED.contains(storageFilerTO.getType())) {
final KVMPhysicalDisk vol = pool.getPhysicalDisk(srcFile);
final String path = vol.getPath();
- try {
- KVMPhysicalDisk.checkQcow2File(path);
- } catch (final CloudRuntimeException e) {
- return new CheckVolumeAnswer(command, false, "", 0,
getVolumeDetails(pool, vol));
+ final boolean isRbd =
Storage.StoragePoolType.RBD.equals(storageFilerTO.getType());
+
+ Map<VolumeOnStorageTO.Detail, String> volumeDetails =
getVolumeDetails(pool, vol);
+ if (MapUtils.isEmpty(volumeDetails)) {
+ return new Answer(command, false, "Unable to read the
volume on the storage pool");
+ }
+
+ if (!isRbd) {
+ try {
+ KVMPhysicalDisk.checkQcow2File(path);
+ } catch (final CloudRuntimeException e) {
+ return new CheckVolumeAnswer(command, false, "", 0,
volumeDetails);
+ }
}
- long size = KVMPhysicalDisk.getVirtualSizeFromFile(path);
+ // Images on RBD are raw and the path is an image name that
qemu-img cannot open
+ // without the rbd: URI, so take the size libvirt already
reported for the volume.
+ long size = isRbd ? vol.getVirtualSize() :
KVMPhysicalDisk.getVirtualSizeFromFile(path);
return new CheckVolumeAnswer(command, true, "", size,
getVolumeDetails(pool, vol));
Review Comment:
`getVolumeDetails` is called twice, can `volumeDetails` be used here ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]