QCOW2 volatile disk always is created with 197kB size

Hello!

It was noticed that when new volatile qcow2 disk is attached to the running KVM VM if the “Image mapping driver” is not explicitly set into qcow2 too the size always has 197 kB size despite what its size was specified in the wizard.

Versions of the related components and OS (frontend, hypervisors, VMs):
OpenNebula 5.4.9
libvirt/qemu* on the nodes:
rpm -qa|egrep “libvirt|qemu”
libvirt-daemon-driver-network-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-config-network-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-rbd-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-logical-3.2.0-14.el7_4.9.x86_64
libvirt-3.2.0-14.el7_4.9.x86_64
ipxe-roms-qemu-20170123-1.git4e85b27.el7_4.1.noarch
qemu-img-1.5.3-141.el7_4.6.x86_64
libvirt-python-3.2.0-3.el7_4.1.x86_64
libvirt-client-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-nwfilter-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-lxc-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-interface-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-nodedev-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-core-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-mpath-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-iscsi-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-gluster-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-scsi-3.2.0-14.el7_4.9.x86_64
qemu-kvm-common-1.5.3-141.el7_4.6.x86_64
qemu-kvm-1.5.3-141.el7_4.6.x86_64
libvirt-libs-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-config-nwfilter-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-secret-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-disk-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-qemu-3.2.0-14.el7_4.9.x86_64
libvirt-daemon-driver-storage-3.2.0-14.el7_4.9.x86_64

Steps to reproduce:
Attach to the running KVM VM a new volatile disk with “Disk type” = FS, “Filesystem format” = qcow2, Size = 2GB, BUS = Virtio.

Current results:
‘parted -l’ inside VM (CentOS 7 x64) shows 197kB disk size:

Error: /dev/vdb: unrecognised disk label
Model: Virtio Block Device (virtblk)                                      
Disk /dev/vdb: 197kB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 

Expected results:
Hotplugged disk should has 2GB size.

The workaround is to set “Image mapping driver” to qcow2 also.

Another thing what was noticed is that in the VM log file on the node (/var/log/libvirt/qemu/<vmid>.log the corresponding file has a format option set as raw instead of qcow2, i.e. it looks like
-drive file=<path-to-vm-dir>/disk.3,format=raw

and it has qcow3 type instead of qcow2:
file \<path-to-vm-dir>/disk.3 \<path-to-vm-dir>/disk.3: QEMU QCOW Image (v3), 2147483648 bytes