apache / cloudstack

Apache CloudStack is an opensource Infrastructure as a Service (IaaS) cloud computing platform
https://cloudstack.apache.org/
Apache License 2.0
1.83k stars 1.07k forks source link

Unable to attach a raw format volume to an instance running on KVM #8652

Closed kiranchavala closed 3 weeks ago

kiranchavala commented 4 months ago

ISSUE TYPE

BUG

Component Name

Volume,

CLOUDSTACK VERSION

Cloudstack version 4.18, 4.19

SUMMARY

Unable to attach a raw format volume to an instance running on KVM

Steps to reproduce the issue

  1. Upload a volume of format RAW

Screenshot 2024-02-14 at 12 18 47 PM

tl.raw.zip

Cross check the DB , format is RAW

mysql> select * from volumes where id=8 \G;;
*************************** 1. row ***************************
                        id: 8
                account_id: 2
                 domain_id: 1
                   pool_id: NULL
              last_pool_id: NULL
               instance_id: NULL
                 device_id: NULL
                      name: test2
                      uuid: c0db18a8-153a-465c-b23d-2ec148a9b0b1
                      size: 53687296
                    folder: NULL
                      path: NULL
                    pod_id: NULL
            data_center_id: 1
                iscsi_name: NULL
                   host_ip: NULL
               volume_type: DATADISK
                 pool_type: NULL
          disk_offering_id: 6
               template_id: NULL
first_snapshot_backup_uuid: NULL
               recreatable: 0
                   created: 2024-02-13 10:19:15
                  attached: NULL
                   updated: 2024-02-13 10:21:41
                   removed: NULL
                     state: Uploaded
                chain_info: NULL
              update_count: 2
                 disk_type: NULL
    vm_snapshot_chain_size: NULL
                    iso_id: NULL
            display_volume: 1
                    format: RAW
                  min_iops: NULL
                  max_iops: NULL
             hv_ss_reserve: NULL
         provisioning_type: thin
             external_uuid: NULL
             passphrase_id: NULL
            encrypt_format: NULL
  1. Try to attach the volume to any running vm

Currently, Cloudstack doesn't list any running vm during volume attachment

Screenshot 2024-02-14 at 12 20 21 PM

The Backend api checks for vms which are only of Hypervisor type OVM

http://10.0.33.170:8080/client/api/?zoneid=c931b7f8-6376-47b2-8082-c4bb3867e9bf&hypervisor=Ovm&account=admin&domainid=85081752-ca47-11ee-923a-1e00d900023d&state=Stopped&command=listVirtualMachines&response=json

Not sure why Cloudstack limiting it to only OVM hypervisor.

VM running Kvm hypervisor can have disk format in raw which can be attached easily

I was able to attach to raw disk image to a kvm


virsh attach-disk 27 /root/ tl.raw vdb

[root@ol8 ~]# virsh domblklist 27

 Target   Source
------------------------------------------------------------------------------------------
 vda      /mnt/71104366-f42e-3fff-80a4-716f643d9525/2cc496ea-27f3-47d0-b680-2796ac2ace15
 vdb      /root/tl.raw
 hdc      -

Dumpxml

     <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/root/tl.raw' index='4'/>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>

Actual Behaviour

Cloudstack is not supporting the attachement of raw disk format to KVM Hypersior

Expected Behaviour

Cloudstack should supporting the attachment of raw disk format to KVM Hypersior

kiranchavala commented 4 months ago

Ideally Cloudstack should not allow the Upload of RAW image format if we are not supporting the attachment of it to a vm.

Or we should limit the raw format upload to only OVM hypervisor

slavkap commented 4 months ago

Hi @kiranchavala! CloudStack sets hypervisor for the volume OVM when the volume is in RAW format and is not one of those storages: RBD, PowerFlex, CLVM, Linstor, FiberChannel. I've seen a similar problem with CloudStack 4.11.3 but it was with take or revert snapshot (can't recall which operation exactly). I think the best solution is - to handle this in the storage plugins and not change the hypervisor of the volume

kiranchavala commented 4 months ago

thanks @slavkap

Since KVM (qemu) supports attaching raw disk images

I think Cloustack should also support it

sureshanaparti commented 3 weeks ago

Ideally Cloudstack should not allow the Upload of RAW image format if we are not supporting the attachment of it to a vm.

Or we should limit the raw format upload to only OVM hypervisor

Hi @kiranchavala Updated PR here: #9224 - CloudStack doesn't allow RAW image format if supported hypervisor is not found on the zone.

sureshanaparti commented 3 weeks ago

@kiranchavala Fix PR merged, closing this.