Bug 1018651 - qemu-img fail to open the disk format image its created correctly (block device only)
qemu-img fail to open the disk format image its created correctly (block devi...
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.5
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Virtualization Maintenance
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-14 01:31 EDT by Sibiao Luo
Modified: 2013-10-14 05:51 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-14 04:37:58 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sibiao Luo 2013-10-14 01:31:43 EDT
Description of problem:
create a lvm qcow2 disk format with qemu-img, then create it to raw format, it fail to open the disk format image its created correctly (block device only).
BTW, also tried the rhel6.4GA qemu-kvm-0.12.1.2-2.355.el6.x86_64 also hit this issue, so it's not a regression issue.

Version-Release number of selected component (if applicable):
host info:
# uname -r && rpm -q qemu-kvm-rhev
2.6.32-422.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.412.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.logging in to a iSCSI and create a lvm.
# lvcreate -L 10G -n sluo_lv sluo_vg
  Logical volume "sluo_lv" created
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
...
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 0
2.create a lvm qcow2 disk format with qemu-img and check the info.
# qemu-img create -f qcow2 /dev/sluo_vg/sluo_lv 10G
Formatting '/dev/sluo_vg/sluo_lv', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
...
3.then create it to raw format and check it.
# qemu-img create -f qcow2 /dev/sluo_vg/sluo_lv 10G
Formatting '/dev/sluo_vg/sluo_lv', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_home' [407.49 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_swap' [7.78 GiB] inherit
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: qcow2                       <------------------wrong.
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
# qemu-img create -f qcow2 /dev/sluo_vg/sluo_lv 10G
Formatting '/dev/sluo_vg/sluo_lv', fmt=qcow2 size=10737418240 encryption=off cluster_size=65536 
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_home' [407.49 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_swap' [7.78 GiB] inherit
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: qcow2                       <------------------wrong.
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
4.boot a guest and attach this lvm specified qcow2/raw format.
e.g:...-drive file=/dev/sluo_vg/sluo_lv,if=none,id=drive-virtio-disk1,*format=qcow2|raw*,cache=none,aio=native,werror=stop,rerror=stop -device virtio-blk-pci,vectors=0,bus=pci.0,addr=0x7,scsi=off,drive=drive-virtio-disk1,id=virtio-disk1,bootindex=2

Actual results:
after step 3, it was wrong file format.
after step 4, both qcow2 and raw format can boot up.

Expected results:
step 3: it can create it to raw format correctly and read it to raw format correctly.
step 4: qemu should quit with prompt message when specified qcow2 format, like:
qemu-kvm: -drive file=/dev/sluo_vg/sluo_lv,if=none,id=drive-virtio-disk1,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop: could not open disk image /dev/sluo_vg/sluo_lv: Invalid argument

Additional info:
Comment 1 Sibiao Luo 2013-10-14 01:34:03 EDT
Aslo tried the local file image with the same testing that did not meet such issue. so this issue is specified block device only.
Comment 2 Sibiao Luo 2013-10-14 01:37:04 EDT
(In reply to Sibiao Luo from comment #0)
> Description of problem:
> create a lvm qcow2 disk format with qemu-img, then create it to raw format,
> it fail to open the disk format image its created correctly (block device
> only).
> BTW, also tried the rhel6.4GA qemu-kvm-0.12.1.2-2.355.el6.x86_64 also hit
> this issue, so it's not a regression issue.
> 
> Version-Release number of selected component (if applicable):
> host info:
> # uname -r && rpm -q qemu-kvm-rhev
> 2.6.32-422.el6.x86_64
> qemu-kvm-rhev-0.12.1.2-2.412.el6.x86_64
> 
> How reproducible:
> 100%
> 
> Steps to Reproduce:
> 1.logging in to a iSCSI and create a lvm.
> # lvcreate -L 10G -n sluo_lv sluo_vg
>   Logical volume "sluo_lv" created
> # lvscan 
>   ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
> ...
> # qemu-img info /dev/sluo_vg/sluo_lv
> image: /dev/sluo_vg/sluo_lv
> file format: raw
> virtual size: 10G (10737418240 bytes)
> disk size: 0
> 2.create a lvm qcow2 disk format with qemu-img and check the info.
> # qemu-img create -f qcow2 /dev/sluo_vg/sluo_lv 10G
> Formatting '/dev/sluo_vg/sluo_lv', fmt=qcow2 size=10737418240 encryption=off
> cluster_size=65536 
> # qemu-img info /dev/sluo_vg/sluo_lv
> image: /dev/sluo_vg/sluo_lv
> file format: qcow2
> virtual size: 10G (10737418240 bytes)
> disk size: 0
> cluster_size: 65536
> # lvscan 
>   ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
> ...
> 3.then create it to raw format and check it.
sorry for wrong pasting.
# qemu-img create -f raw /dev/sluo_vg/sluo_lv 10G
Formatting '/dev/sluo_vg/sluo_lv', fmt=raw size=10737418240
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: qcow2                       <------------------wrong.
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
# lvscan
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_home' [407.49 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_swap' [7.78 GiB] inherit
> 4.boot a guest and attach this lvm specified qcow2/raw format.
> e.g:...-drive
> file=/dev/sluo_vg/sluo_lv,if=none,id=drive-virtio-disk1,*format=qcow2|raw*,
> cache=none,aio=native,werror=stop,rerror=stop -device
> virtio-blk-pci,vectors=0,bus=pci.0,addr=0x7,scsi=off,drive=drive-virtio-
> disk1,id=virtio-disk1,bootindex=2
> 
> Actual results:
> after step 3, it was wrong file format.
> after step 4, both qcow2 and raw format can boot up.
> 
> Expected results:
> step 3: it can create it to raw format correctly and read it to raw format
> correctly.
> step 4: qemu should quit with prompt message when specified qcow2 format,
> like:
> qemu-kvm: -drive
> file=/dev/sluo_vg/sluo_lv,if=none,id=drive-virtio-disk1,format=qcow2,
> cache=none,aio=native,werror=stop,rerror=stop: could not open disk image
> /dev/sluo_vg/sluo_lv: Invalid argument
> 
> Additional info:
Comment 3 Sibiao Luo 2013-10-14 01:41:41 EDT
Also can be reproduce this issue with the following testing: create the lvm to qed first and then create it into raw agian, the qemu-img will fail to open the disk format image its created correctly (block device only).

# lvcreate -L 10G -n sluo_lv sluo_vg
  Logical volume "sluo_lv" created
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_home' [407.49 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_swap' [7.78 GiB] inherit
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: raw
virtual size: 10G (10737418240 bytes)
disk size: 0
# qemu-img create -f qed /dev/sluo_vg/sluo_lv 10G
Formatting '/dev/sluo_vg/sluo_lv', fmt=qed size=10737418240 cluster_size=0 table_size=0 
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: qed
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_home' [407.49 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_swap' [7.78 GiB] inherit
# qemu-img create -f raw /dev/sluo_vg/sluo_lv 10G
Formatting '/dev/sluo_vg/sluo_lv', fmt=raw size=10737418240 
# qemu-img info /dev/sluo_vg/sluo_lv
image: /dev/sluo_vg/sluo_lv
file format: qed
virtual size: 10G (10737418240 bytes)
disk size: 0
cluster_size: 65536
# lvscan 
  ACTIVE            '/dev/sluo_vg/sluo_lv' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_home' [407.49 GiB] inherit
  ACTIVE            '/dev/vg_dhcp9242/lv_swap' [7.78 GiB] inherit
Comment 4 Paolo Bonzini 2013-10-14 04:37:42 EDT
This is not a bug.  It happens because block devices are not initialized to zero.  For this reason it is always preferrable to "scrub" devices when you create them as raw.

We are working on it upstream and we might get a fix in RHEL7 together with bug 1007815.

Note You need to log in before you can comment on or make changes to this bug.