RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1177219 - [Storage] vol-download / upload works well with an offset which was "too large"
Summary: [Storage] vol-download / upload works well with an offset which was "too large"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Erik Skultety
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-25 08:05 UTC by Pei Zhang
Modified: 2015-11-19 06:05 UTC (History)
9 users (show)

Fixed In Version: libvirt-1.2.14-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 06:05:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description Pei Zhang 2014-12-25 08:05:52 UTC
Description of problem:
Try to do vol-download /upload with an offset which is too large (eg.UINT64_MAX) , it will be successful . But value which is less than UINT64_MAX is invalid and will give error if using it .

Version-Release number of selected component (if applicable):
libvirt-1.2.8-11.el7.x86_64
qemu-kvm-rhev-2.1.2-17.el7.x86_64
kernel-3.10.0-217.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.create two volumes in the default pool

# cat default-volume.xml 
<volume>
  <name>qcow2-vol</name>
  <source>
  </source>
  <capacity unit='bytes'>1024000000</capacity>
  <allocation unit='bytes'>204000</allocation>
  <target>
    <format type='qcow2'/>
   <features>
    <lazy_refcounts/>
    </features>
  </target>
</volume>

 
# virsh vol-create default default-volume.xml 
Vol qcow2-vol created from default-volume.xml


# cat raw-vol.xml 
<volume>
<name>raw-vol</name>
  <source>
  </source>
   <capacity unit='bytes'>589934592</capacity>
  <allocation unit='bytes'>56063232</allocation>
  <target>
    <format type='raw'/>
  </target>
</volume>

# virsh vol-create default raw-vol.xml 
Vol raw-vol created from raw-vol.xml

check volumes in default pool 

# virsh vol-list default
 Name                 Path                                    
------------------------------------------------------------------------------
 qcow2-vol            /var/lib/libvirt/images/qcow2-vol       
 raw-vol              /var/lib/libvirt/images/raw-vol         


2.try to do vol-upload/download with an offset that was "too large" 

2.1  try to download qcow2-vol to raw by passing an offset with too large value 
 
# virsh vol-download --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551614 --length 18446744073709551614
error: cannot download to volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551614: Invalid argument

NOTE : if set an offset that was 18446744073709551615 ,it will download successfully.
# virsh vol-download --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551615 --length 18446744073709551615

# virsh vol-download --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551616 --length 18446744073709551616
error: Unable to parse offset value

2.2   try to upload qcow2 to raw by passing an offset with too large value 

# virsh vol-upload --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551614 --length 18446744073709551615
error: cannot upload to volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551614: Invalid argument

NOTE : if set an offset that was 18446744073709551615 ,it will upload successfully.
# virsh vol-upload --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551615 --length 18446744073709551615

# virsh vol-upload --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551616 --length 18446744073709551616
error: Unable to parse offset value

Actuall result :
As step 2 , the value *1614 and *1616 is invalid and give error message if try to use it . But the *1615 value works well .

Expect result :
The *1615 value should also be invalid and cannot be used .

Comment 1 Peter Krempa 2015-03-04 13:57:42 UTC
Fixed upstream:

commit 3fde7986d6694f122ae919d68ec64eee79bd51db
Author: Erik Skultety <eskultet>
Date:   Tue Mar 3 16:57:38 2015 +0100

    storage: tweak condition to properly test lseek
    
    According to the POSIX standard, off_t (returned by lseek) is defined as
    signed integral type no shorter than int. Because our offset variable is defined
    as unsigned long long, the original check was passed successfully if UINT64_MAX had
    been used as offset value, due to implicit conversion.

v1.2.13-56-g3fde798

Comment 3 yisun 2015-06-03 07:21:21 UTC
Verified 
On Versions:
libvirt-1.2.15-2.el7.x86_64


verify steps:

# cat qcow2.vol
<volume>
  <name>qcow2-vol</name>
  <source>
  </source>
  <capacity unit='bytes'>1024000000</capacity>
  <allocation unit='bytes'>204000</allocation>
  <target>
    <format type='qcow2'/>
   <features>
    <lazy_refcounts/>
    </features>
  </target>
</volume>

 
# virsh vol-create default qcow2.vol
Vol qcow2-vol created from qcow2.vol


# cat raw.vol 
<volume>
<name>raw-vol</name>
  <source>
  </source>
   <capacity unit='bytes'>589934592</capacity>
  <allocation unit='bytes'>56063232</allocation>
  <target>
    <format type='raw'/>
  </target>
</volume>

# virsh vol-create default raw.vol 

Vol raw-vol created from raw.vol 


     



use 2^64-1 (18446744073709551615) as boundary, all produce error messages as expected.  
# virsh vol-download --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551613 --length 18
error: cannot download from volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551613: Invalid argument

# virsh vol-download --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551614 --length 18
error: cannot download from volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551614: Invalid argument

# virsh vol-download --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551615 --length 18
error: cannot download from volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551615: Invalid argument

Comment 4 yisun 2015-06-03 07:25:24 UTC
And the vol-upload check.

# virsh vol-upload --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551613 --length 18446744073709551615
error: cannot upload to volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551613: Invalid argument

# virsh vol-upload --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551614 --length 18446744073709551615
error: cannot upload to volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551614: Invalid argument

# virsh vol-upload --pool default qcow2-vol /var/lib/libvirt/images/raw-vol --offset 18446744073709551615 --length 18446744073709551615
error: cannot upload to volume qcow2-vol
error: Unable to seek /var/lib/libvirt/images/qcow2-vol to 18446744073709551615: Invalid argument

Comment 6 errata-xmlrpc 2015-11-19 06:05:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2202.html


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