Bug 735441

Summary: Incorrect hardcoded sector size in disk storage pool
Product: Red Hat Enterprise Linux 6 Reporter: Daniel Berrangé <berrange>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2CC: ajia, dyuan, gsun, mzhan, nzhang, rwu, veillard, whuang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.4-8.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 11:27:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Daniel Berrangé 2011-09-02 16:06:16 UTC
Description of problem:
If creating a 'disk' storage pool on a device which has 4k sectors, the size of the partitions reported by libvirt will be x8 too small. This is because libvirt incorrectly hardcoded a 512 byte sector size.

Version-Release number of selected component (if applicable):
0.9.4-1.el6

How reproducible:
Only with 'disk' storage pool on a device with 4k sectors

Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Upstream fix

commit b6263c18013e99bab1938d112fc927f948df3eef
Author: Daniel P. Berrange <berrange>
Date:   Tue Aug 23 15:25:28 2011 +0100

    Fix parted sector size assumption
    
    Parted does not report disk size in 512 byte units, but
    rather the disks' logical sector size, which with modern
    drives might be 4k.
    
    * src/storage/parthelper.c: Remove hardcoded 512 byte sector
      size

Comment 5 Wayne Sun 2011-11-04 10:13:41 UTC
# fdisk -l
Note: sector size is 4096 (not 512)

Disk /dev/sdb: 162.8 GB, 162842222592 bytes
255 heads, 63 sectors/track, 2474 cylinders
Units = cylinders of 16065 * 4096 = 65802240 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000d2129

   Device Boot      Start         End      Blocks   Id  System

Steps:
1. define disk pool on /dev/sdb
2. build and start /dev/sdb
3. create a vol in the disk pool using vol.xml:
<volume>
  <name>sdb1</name>
  <key>/dev/sdb1</key>
  <source>
    <device path='/dev/sdb'>
    </device>
  </source>
  <capacity unit='M'>10240</capacity>
  <target>
    <path>/dev/sdb1</path>
  </target>
</volume>

# virsh vol-create sdb vol.xml

4. check the vol info
# virsh vol-info sdb1 --pool sdb

Results:
Step 3:
the vol created successfully.

Step 4:
libvirt-0.9.4-7.2:
# virsh vol-info sdb1 --pool sdb
Name:           sdb1
Type:           block
Capacity:       1.25 GB
Allocation:     1.25 GB

libvirt-0.9.4-21:
# virsh vol-info sdb1 --pool sdb
Name:           sdb1
Type:           block
Capacity:       10.00 GB
Allocation:     10.00 GB

So libvirt reports the right size now, no factor x8 defect.

Comment 6 errata-xmlrpc 2011-12-06 11:27:58 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.

http://rhn.redhat.com/errata/RHBA-2011-1513.html