qcow2 [virtio-scsi] devices when mapped to the guest shows as 0MB irrespective of the volume size

Bug #1197663 reported by chandrashekar shastri
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Invalid
Undecided
Unassigned
Fedora
New
Undecided
Unassigned

Bug Description

qcow2 [virtio-scsi] devices when mapped to the guest shows as 0MB irrespective of the volume size.

Kernel Version: 3.10.0-rc5+

Libvirt Version: 1.0.6

Qemu Version: 1.5.50

Steps to reproduce the issue:

1. Create a qcow2 voulme using the command qemu-img create -f qcow2 virtio-scsi11.img 10G
2. Add the virtio-scsi controller

 <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>

3. Attach the qcow2 device to the guest, virsh attach-disk rhel64-64 /home/images/virtio-scsi11.img --persistent sdr --cache writethrough

4. Run the scan commnad echo ' - - - ' > /sys/class/scsi_host/host#/scan, if the attached volume doesn't get recognize.

5. Check the dmesg for the added volume.

6. Run fdisk -l command

Disk /dev/sdl: 0 MB, 197120 bytes
1 heads, 1 sectors/track, 385 cylinders, total 385 sectors
Units = cylinders of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

And observe that the 10G qcow2 volume shows as 0MB.

This is not seen with the raw image.

Disk /dev/sdm: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Expected Result:

The volume size for the qcow2 volumes should be shown correctly inside the guest to avoid confusion.

Guest XML:
virsh dumpxml rhel64-64
<domain type='kvm' id='4'>
  <name>rhel64-64</name>
  <uuid>48deb0e1-0c23-9be9-da12-2ead34864de2</uuid>
  <memory unit='KiB'>4096000</memory>
  <currentMemory unit='KiB'>4096000</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-1.5'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/local/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/home/images/rhel64-64.qcow2'/>
      <target dev='hda' bus='ide'/>
      <alias name='ide0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/upstream/autotest/virt-test/shared/data/isos/RHEL-6.4-x86_64-DVD.iso'/>
      <target dev='hdb' bus='ide'/>
      <readonly/>
      <alias name='ide0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi11.img'/>
      <target dev='sda' bus='scsi'/>
      <alias name='scsi0-0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi1.img'/>
      <target dev='sdf' bus='scsi'/>
      <alias name='scsi0-0-0-5'/>
      <address type='drive' controller='0' bus='0' target='0' unit='5'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi9.img'/>
      <target dev='sdg' bus='scsi'/>
      <alias name='scsi0-0-0-6'/>
      <address type='drive' controller='0' bus='0' target='0' unit='6'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi8.img'/>
      <target dev='sdh' bus='scsi'/>
      <alias name='scsi1-0-0'/>
      <address type='drive' controller='1' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi10.img'/>
      <target dev='sdi' bus='scsi'/>
      <alias name='scsi1-0-1'/>
      <address type='drive' controller='1' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi7.img'/>
      <target dev='sdk' bus='scsi'/>
      <alias name='scsi1-0-3'/>
      <address type='drive' controller='1' bus='0' target='0' unit='3'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi6.img'/>
      <target dev='sdl' bus='scsi'/>
      <alias name='scsi1-0-4'/>
      <address type='drive' controller='1' bus='0' target='0' unit='4'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi5.img'/>
      <target dev='sdm' bus='scsi'/>
      <alias name='scsi1-0-5'/>
      <address type='drive' controller='1' bus='0' target='0' unit='5'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi12.img'/>
      <target dev='sdn' bus='scsi'/>
      <alias name='scsi1-0-6'/>
      <address type='drive' controller='1' bus='0' target='0' unit='6'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi11.img'/>
      <target dev='sdr' bus='scsi'/>
      <alias name='scsi2-0-3'/>
      <address type='drive' controller='2' bus='0' target='0' unit='3'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi2.img'/>
      <target dev='sdx' bus='scsi'/>
      <alias name='scsi3-0-2'/>
      <address type='drive' controller='3' bus='0' target='0' unit='2'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi4.img'/>
      <target dev='sdy' bus='scsi'/>
      <alias name='scsi3-0-3'/>
      <address type='drive' controller='3' bus='0' target='0' unit='3'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi3.img'/>
      <target dev='sdz' bus='scsi'/>
      <alias name='scsi3-0-4'/>
      <address type='drive' controller='3' bus='0' target='0' unit='4'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci0'/>
    </controller>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <alias name='scsi0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </controller>
    <controller type='scsi' index='1'>
      <alias name='scsi1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </controller>
    <controller type='scsi' index='2'>
      <alias name='scsi2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <controller type='scsi' index='3'>
      <alias name='scsi3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:9d:cf:bb'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/1'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/1'>
      <source path='/dev/pts/1'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none' model='selinux'/>
</domain>

Tags: qemu
Revision history for this message
chandrashekar shastri (cshastri) wrote :

I tried booting with the qemu and observed the same thing.

qemu-system-x86_64 /home/images/rhel64-64.qcow2 -drive if=none,id=hd,file=/home/images/virtio-scsi11.img -device virtio-scsi-pci,id=scsi --enable-kvm -device scsi-hd,drive=hd -m 2000

After creating the filesystem tried running the iozone and noticed disk out of space issue.

Revision history for this message
chandrashekar shastri (cshastri) wrote :
Revision history for this message
Stefan Hajnoczi (stefanha) wrote : Re: [Qemu-devel] [Bug 1197663] [NEW] qcow2 [virtio-scsi] devices when mapped to the guest shows as 0MB irrespective of the volume size

On Thu, Jul 4, 2013 at 9:07 AM, chandrashekar shastri
<email address hidden> wrote:
> Public bug reported:
>
> qcow2 [virtio-scsi] devices when mapped to the guest shows as 0MB
> irrespective of the volume size.

qemu-system-x86_64 -enable-kvm -m 1024 -cpu host,+x2apic \
    -device virtio-scsi-pci,id=virtio-scsi0 \
    -drive if=none,cache=none,file=test2.qcow2,format=qcow2,id=drive0 \
    -device scsi-hd,drive=drive0 \
    -cdrom rhel64_live.iso

Works fine in qemu.git/master with a RHEL6.4 guest.

What happens when you run "blockdev --getsize64 /dev/sdb" in your guest?

Please also post the output of "qemu-img info
/home/images/virtio-scsi11.img" on the host.

Stefan

Revision history for this message
chandrashekar shastri (cshastri) wrote :

Guest output:
-------------------

[root@redhat ~]# ls -lrt /dev/sd
sda sda1 sda2 sdb
[root@redhat ~]# ls -lrt /dev/sd
sda sda1 sda2 sdb
[root@redhat ~]# ls -lrt /dev/sdb
brw-rw----. 1 root disk 8, 16 Jul 4 21:58 /dev/sdb
[root@redhat ~]# blockdev --getsize64 /dev/sdb
197120
[root@redhat ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 0 MB, 197120 bytes
1 heads, 1 sectors/track, 385 cylinders, total 385 sectors
Units = cylinders of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@redhat ~]#

Host Output:
------------------
qemu-img info virtio-scsi23.img
image: virtio-scsi23.img
file format: qcow2
virtual size: 15G (16106127360 bytes)
disk size: 196K
cluster_size: 65536

XML Output:
-----------------

<disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='writethrough'/>
      <source file='/home/images/virtio-scsi23.img'/>
      <target dev='sdz' bus='scsi'/>
      <address type='drive' controller='3' bus='0' target='0' unit='4'/>
    </disk>

Revision history for this message
Stefan Hajnoczi (stefanha) wrote :

<driver name='qemu' type='raw' cache='writethrough'/>
<source file='/home/images/virtio-scsi23.img'/>

You created a qcow2 file but told libvirt it's type='raw'. Therefore the guest sees a raw file and not a qcow2 file. The qcow2 file is only 196 KB on disk (qemu-img output shows this), this matches with the blocksize --getsize64 output inside the guest.

Change type='raw' to type='qcow2' in your XML and the issue will be resolved.

Changed in qemu:
status: New → Invalid
Revision history for this message
chandrashekar shastri (cshastri) wrote :

Thanks Stefanha.

If we use the commad virsh attach-disk rhel64-64 /home/images/virtio-scsi11.img --persistent sdr --cache writethrough the qcow2 images will also gets added as raw which is by default. Hence we should use

"virsh attach-disk rhel64-64 /home/images/virtio-scsi11.img --persistent sdr --cache writethrough --sourcetype file --driver qemu --subdriver qcow2".

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.