On 08/06/2013 08:26 PM, Edison Su wrote:
Possible to add some code in volumeObject-> 
processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer)
if (this.dataStore.getRole() == DataStoreRole.Primary) {
if (answer instanceof CopyCmdAnswer) {
else if (answer instanceof CreateObjectAnswer) {

if (newvol.getImageFormat() != null) {
     vol.setImageFormat(newvol.getImageFormat())
}


In the KVM resource code, need to return an image format in
kvmstorageProcessor:
Answer createVolume(CreateObjectCommand cmd)



Great! That indeed fixed it. See my commit: https://git-wip-us.apache.org/repos/asf?p=cloudstack.git;a=commitdiff;h=04f378bcff90c9a3ab3bb3c92c5ec1145aab45c4

Wido

And also need to move the following code:

         VolumeVO volVO = _volsDao.findById(vol.getId());
         volVO.setFormat(getSupportedImageFormatForCluster(rootDiskHyperType));
         _volsDao.update(volVO.getId(), volVO);

 From the bottom of volumemanagerImpl-> createVolumeOnPrimaryStorage to the 
beginning.



-----Original Message-----
From: Wido den Hollander [mailto:w...@widodh.nl]
Sent: Tuesday, August 06, 2013 8:46 AM
To: dev@cloudstack.apache.org
Cc: Edison Su
Subject: KVM always defaulting to QCOW2 image formats

Hi,

I just encountered CLOUDSTACK-4114 [0] during my tests.

I didn't encounter this before, but I just tried to restore from a snapshot and
there it assumed the snapshot was in QCOW2 format, but it is actually a RAW
device.

In VolumeDoaImpl this is implemented:

public ImageFormat getImageFormat(Long volumeId) {
      HypervisorType type = getHypervisorType(volumeId);
      if (type.equals(HypervisorType.KVM)) {
          return ImageFormat.QCOW2;
      } else if (type.equals(HypervisorType.XenServer)) {
          return ImageFormat.VHD;
      } else if (type.equals(HypervisorType.VMware)) {
          return ImageFormat.OVA;
      } else {
          s_logger.warn("Do not support hypervisor " + type.toString());
          return null;
      }
}

Thile QCOW2 is valid when using NFS, it isn't when using either RBD or LVM.

So why does KVM always default to QCOW2?

Where is the best way to override this and have RBD always use RAW?

I'd rather avoid a if pooltype == RBD kind of statement somewhere in the
code.

For now RBD is using the DefaultPrimary provider.

Wido

[0]: https://issues.apache.org/jira/browse/CLOUDSTACK-4114

Reply via email to