Bug 1122830 - qemu-img convert doesn't print "No space left on device" strings error when the destination lv has no enough space
Summary: qemu-img convert doesn't print "No space left on device" strings error when t...
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm-rhev
Version: 7.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Max Reitz
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1122847
TreeView+ depends on / blocked
 
Reported: 2014-07-24 07:47 UTC by Sibiao Luo
Modified: 2015-05-20 22:47 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1122847 (view as bug list)
Environment:
Last Closed: 2014-07-24 23:10:14 UTC


Attachments (Terms of Use)

Description Sibiao Luo 2014-07-24 07:47:41 UTC
Description of problem:
prepare a block storage, and create to a 10G raw lvm and a 4G qcow2 lvm, then use qemu-img convert  the raw lvm to the qcow2 lvm, it should fail to convert with "No space left on device" error prompt message.
we has fixed such issue for rhel6 in bug 803344.

Version-Release number of selected component (if applicable):
# uname -r && rpm -q qemu-kvm-rhev
3.10.0-128.el7.x86_64
qemu-kvm-rhev-2.1.0-3.el7ev.preview.x86_64

How reproducible:
100%

Steps to Reproduce:
1.prepare a block storage and create two lvm.
# fdisk -l | grep /dev/sdb
Disk /dev/sdb: 15.5 GB, 15513354240 bytes, 30299520 sectors
# pvcreate /dev/sdb
WARNING: ext4 signature detected on /dev/sdb at offset 1080. Wipe it? [y/n] y
  Wiping ext4 signature on /dev/sdb.
  Physical volume "/dev/sdb" successfully created
# vgcreate vg /dev/sdb
  Volume group "vg" successfully created
# lvcreate -L 10G -n lv1 vg
  Logical volume "lv1" created
# lvcreate -L 4G -n lv2 vg
  Logical volume "lv2" created
2.# qemu-img create -f raw /dev/vg/lv1 10G
# qemu-img create -f qcow2 /dev/vg/lv2 4G
Formatting '/dev/vg/lv2', fmt=qcow2 size=4294967296 encryption=off cluster_size=65536 lazy_refcounts=off
3.write fully for lv1.
# dd if=/dev/zero of=/dev/vg/lv1 bs=10M
4.convert the raw to qcow2 lvm.
# qemu-img convert -p -t none -f raw /dev/vg/lv1 -O qcow2 /dev/vg/lv2

Actual results:
after step 4,
# qemu-img convert -p -t none -f raw /dev/vg/lv1 -O qcow2 /dev/vg/lv2
    (100.00/100%)

Expected results:
it should fail to convet and print "No space left on device" strings error.
e.g. qemu-img: error while writing sector 11321344: No space left on device

Additional info:

Comment 1 Sibiao Luo 2014-07-24 08:12:18 UTC
# lvdisplay /dev/vg/lv1
  --- Logical volume ---
  LV Path                /dev/vg/lv1
  LV Name                lv1
  VG Name                vg
  LV UUID                P8zOCk-QILD-AKaV-mon0-CT9F-c76r-8FPBB3
  LV Write Access        read/write
  LV Creation host, time dhcp-11-154.nay.redhat.com, 2014-07-24 15:06:41 +0800
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

# lvdisplay /dev/vg/lv2
  --- Logical volume ---
  LV Path                /dev/vg/lv2
  LV Name                lv2
  VG Name                vg
  LV UUID                tlp3RM-sQGW-vs8O-6std-3ECf-IO65-MUoiDe
  LV Write Access        read/write
  LV Creation host, time dhcp-11-154.nay.redhat.com, 2014-07-24 15:06:50 +0800
  LV Status              available
  # open                 0
  LV Size                4.00 GiB
  Current LE             1024
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

Comment 2 Max Reitz 2014-07-24 23:10:14 UTC
Hi,

Without filling lv1 (dd if=/dev/zero of=/dev/vg/lv1 bs=16M count=1) I in fact get the error message you expected (kernel 3.14.8-200.fc20.x86_64, both with RHEL 6's and RHEL 7's qemu):

$ lvcreate -L 16M -n lv1 vg
$ lvcreate -L 4M -n lv2 vg
$ ./qemu-img convert -p -f raw -O qcow2 /dev/vg/lv1 /dev/vg/lv2
error while writing sector 4096: No space left on device

With having used dd if=/dev/zero before, the error message disappears. However, interestingly, when using /dev/urandom instead of /dev/zero, the message reappears. Therefore, I saved the qcow2 image somewhere else and checked its size:

$ dd if=/dev/urandom of=/dev/vg/lv1 bs=16M count=1
$ ./qemu-img convert -f raw -O qcow2 /dev/vg/lv1 foo.qcow2
$ ls -lh foo.qcow2 
-rw-r--r--. 1 root root 17M 25. Jul 01:02 foo.qcow2
$ dd if=/dev/zero of=/dev/vg/lv1 bs=16M count=1
$ ./qemu-img convert -f raw -O qcow2 /dev/vg/lv1 foo.qcow2
$ ls -lh foo.qcow2
-rw-r--r--. 1 root root 193K 25. Jul 01:02 foo.qcow2
$ ./qemu-img map foo.qcow2 
Offset          Length          Mapped to       File

And indeed, qemu-img's img_convert() checks whether the read data is zero (through is_allocated_sectors_min()) and only writes to the output if it is.

Thus, the resulting qcow2 file is very small and indeed fits into the smaller volume.


Max

Comment 3 Sibiao Luo 2014-07-25 03:23:25 UTC
# lvscan | grep /dev/vg/
  ACTIVE            '/dev/vg/lv1' [100.00 MiB] inherit
  ACTIVE            '/dev/vg/lv2' [20.00 MiB] inherit
# qemu-img create -f qcow2 /dev/vg/lv2 20M
Formatting '/dev/vg/lv2', fmt=qcow2 size=20971520 encryption=off cluster_size=65536 lazy_refcounts=off 
# qemu-img info /dev/vg/lv1
image: /dev/vg/lv1
file format: raw
virtual size: 100M (104857600 bytes)
disk size: 0
# qemu-img info /dev/vg/lv2
image: /dev/vg/lv2
file format: qcow2
virtual size: 20M (20971520 bytes)
disk size: 0
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
# dd if=/dev/urandom of=/dev/vg/lv1 bs=1M
dd: error writing ‘/dev/vg/lv1’: No space left on device
101+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 10.8566 s, 9.7 MB/s
# qemu-img convert -p -f raw -O qcow2 /dev/vg/lv1 /dev/vg/lv2
qemu-img: error while writing sector 36864: No space left on device

Best Regards,
sluo


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