Bug 1196698

Summary: qemu: qemu-img isn't equipped to handle many sectors resulting in error on writing
Product: Red Hat OpenStack Reporter: Dafna Ron <dron>
Component: qemu-kvm-rhevAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED DUPLICATE QA Contact: Ami Jeain <ajeain>
Severity: high Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: stefanha, yeylon
Target Milestone: ---   
Target Release: 7.0 (Kilo)   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-27 12:18:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1194743    

Description Dafna Ron 2015-02-26 14:44:04 UTC
Description of problem:

Based on bug: 1194743 cinder storage team has been investigating along with Stephan. 

The issue appears in cinder when we try to copy an image to a newly created cinder volume and we get an error from qemu. 

2015-02-20 18:33:45.841 4784 TRACE oslo.messaging.rpc.dispatcher ImageCopyFailure: Failed to copy image to volume: qemu-img: error writing zeroes at sector 0: Invalid argument

following investigating, Eric and Stephan agree on the following: 

qemu-img's img_convert calls bdrv_make_zero/bdrv_write_zeroes().  This
results in a call to bdrv_rw_co with nb_sectors=20971520.  The block
device is of length 10737418240 with 512 byte sectors AFAICT from
looking at an strace of qemu-img:

32679
open("/dev/mapper/cinder--volumes-volume--bde9673e--3678--453f--89c6--000294730b43",
O_RDWR|O_DIRECT|O_CLOEXEC) = 8
...
32679 lseek(8, 0, SEEK_END)             = 10737418240
32679 ioctl(8, BLKSSZGET, 512)          = 0


This means nb_sectors is greater than INT_MAX / BDRV_SECTOR_SIZE so
bdrv_rw_co() returns -EINVAL.  [1]

Not really sure how to interpret this, but it seems to be the root
failure.  It looks like qemu-img isn't equipped to handle that many
sectors, basically?  What should we do about this?


#0  bdrv_rw_co (bs=bs@entry=0x555555db4cb0,
sector_num=sector_num@entry=0, buf=buf@entry=0x0, nb_sectors=20971520,
is_write=is_write@entry=true,
    flags=flags@entry=(BDRV_REQ_ZERO_WRITE | BDRV_REQ_MAY_UNMAP)) at
block.c:2762
#1  0x0000555555572a33 in bdrv_write_zeroes (flags=<optimized out>,
nb_sectors=<optimized out>, sector_num=0, bs=0x555555db4cb0) at block.c:2814
#2  bdrv_make_zero (bs=0x555555db4cb0, flags=<optimized out>) at
block.c:2856
#3  0x00005555555691a1 in img_convert (argc=<optimized out>,
argv=<optimized out>) at qemu-img.c:1609
#4  0x00007ffff311baf5 in __libc_start_main () from /lib64/libc.so.6
#5  0x000055555556594d in _start ()


Version-Release number of selected component (if applicable):

qemu-img-rhev-2.1.2-23.el7.x86_64

How reproducible:

100% on all in one openstack 

Steps to Reproduce:
1. install all in one openstack on bare metal machine
2. create an image
3. create a new cinder volume from an image 

Actual results:

we fail to create the cinder volume with error from qemu on writing

Expected results:

we should succeed to create the volume 

Additional info:

Stephan mentioned that there is a patch on line for this that needs to be backported: 

Thanks for investigating this!  I agree with your analysis and there is
a fix upstream which will be backported:

http://git.qemu-project.org/?p=qemu.git;a=commitdiff;h=f3a9cfddaec127078ac1898de6b063db8ac3bb48

Stefan

Comment 3 Stefan Hajnoczi 2015-02-27 12:18:16 UTC

*** This bug has been marked as a duplicate of bug 1196688 ***