kvm: Better handle different volume formats when creating a volume

The KVMStorageProcessor no longer has a hardcoded if-statement which sets
RBD volumes to RAW, this is now handled in the LibvirtStorageAdapter

The Management Server still sends QCOW2 as format. That's a fix for later.
This commit is contained in:
Wido den Hollander 2014-04-29 13:35:20 +02:00
parent b3491bcbac
commit c1116142a3
3 changed files with 5 additions and 12 deletions

View File

@ -1054,19 +1054,13 @@ public class KVMStorageProcessor implements StorageProcessor {
primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
disksize = volume.getSize();
vol = primaryPool.createPhysicalDisk(volume.getUuid(), volume.getProvisioningType(), disksize);
vol = primaryPool.createPhysicalDisk(volume.getUuid(), PhysicalDiskFormat.valueOf(volume.getFormat().toString().toUpperCase()),
volume.getProvisioningType(), disksize);
VolumeObjectTO newVol = new VolumeObjectTO();
newVol.setPath(vol.getName());
newVol.setSize(volume.getSize());
/**
* Volumes on RBD are always in RAW format
* Hardcode this to RAW since there is no other way right now
*/
if (primaryPool.getType() == StoragePoolType.RBD) {
newVol.setFormat(ImageFormat.RAW);
}
newVol.setFormat(ImageFormat.valueOf(vol.getFormat().toString().toUpperCase()));
return new CreateObjectAnswer(newVol);
} catch (Exception e) {

View File

@ -733,7 +733,6 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
* For that reason we use the native RBD bindings to create the
* RBD image until libvirt creates RBD format 2 by default
*/
format = PhysicalDiskFormat.RAW;
try {
s_logger.info("Creating RBD image " + pool.getSourceDir() + "/" + name + " with size " + size);
@ -758,7 +757,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
volPath = pool.getSourceDir() + "/" + name;
KVMPhysicalDisk disk = new KVMPhysicalDisk(volPath, name, pool);
disk.setFormat(format);
disk.setFormat(PhysicalDiskFormat.RAW);
disk.setSize(size);
disk.setVirtualSize(size);
return disk;

View File

@ -106,7 +106,7 @@ public class LibvirtStoragePool implements KVMStoragePool {
@Override
public PhysicalDiskFormat getDefaultFormat() {
if (getStoragePoolType() == StoragePoolType.CLVM) {
if (getStoragePoolType() == StoragePoolType.CLVM || getStoragePoolType() == StoragePoolType.RBD) {
return PhysicalDiskFormat.RAW;
} else {
return PhysicalDiskFormat.QCOW2;