Bug 1172468

Summary: Fail to build a disk pool with a disk without disk label
Product: Red Hat Enterprise Linux 7 Reporter: Hao Liu <hliu>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, hliu, jferlan, mprivozn, mzhan, rbalakri, tzheng, yanyang
Target Milestone: rcKeywords: Upstream
Target Release: 7.2   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.13-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 05:57:54 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:

Description Hao Liu 2014-12-10 06:27:20 UTC
Description:
Fail to build a disk pool with a disk without disk label

Product version
libvirt-1.2.8-10.el7.x86_64
parted-3.1-19.el7.x86_64

How producible
100%

Steps:
1. Prepare a disk sdb without label 
(WARNING: data on the disk sdb will be lost)
# dd if=/dev/zero of=/dev/sdb count=1 bs=512

2. Prepare a pool XML file test.xml:
<pool type='disk'>
  <name>test</name>
  <source>
    <device path='/dev/sdb'/>
    <format type='dos'/>
  </source>
  <target>
    <path>/dev</path>
  </target>
</pool>

3. Define the pool:
# virsh define test.xml

4. Build the pool:
# virsh pool-build test
error: Failed to build pool test
error: operation failed: Error checking for disk label

Expected result:
Successfully build the pool.

Comment 2 Hao Liu 2014-12-10 06:51:33 UTC
In old version of parted like parted-2.1-25, error message is shown in
stdout when printing a disk info without disk label.

    Error: /dev/sda: unrecognised disk label

This line has been moved to stderr in newer version of parted. So we
should check both stdout and stderr when locating this message.

Patch posted in upstream:
https://www.redhat.com/archives/libvir-list/2014-December/msg00546.html

Comment 3 Michal Privoznik 2014-12-10 10:29:54 UTC
And I've just pushed the patch upstream:

commit 97880078922049b08ae28af2579cca9610e642dc
Author:     Hao Liu <hliu>
AuthorDate: Wed Dec 10 15:14:26 2014 +0800
Commit:     Michal Privoznik <mprivozn>
CommitDate: Wed Dec 10 10:55:23 2014 +0100

    storage: Check stderr when matching parted output
    
    In old version of parted like parted-2.1-25, error message is shown in
    stdout when printing a disk info without disk label.
    
        Error: /dev/sda: unrecognised disk label
    
    This line has been moved to stderr in newer version of parted. So we
    should check both stdout and stderr when locating this message.
    
    This should fix bug:
        https://bugzilla.redhat.com/show_bug.cgi?id=1172468
    
    Signed-off-by: Hao Liu <hliu>

v1.2.11-rc1-24-g9788007

Comment 5 Yang Yang 2015-04-30 09:18:16 UTC
Verified on libvirt-1.2.14-1.el7.x86_64

Steps
1.define a disk pool with following xml
# virsh pool-dumpxml disk
<pool type='disk'>
  <name>disk</name>
  <uuid>b0b3c21e-31df-44d0-913e-f8f7bda080d1</uuid>
  <capacity unit='bytes'>0</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>0</available>
  <source>
    <device path='/dev/sdc'/>
    <format type='dos'/>
  </source>
  <target>
    <path>/dev</path>
    <permissions>
      <mode>0755</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

2. # parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Error: /dev/sdc: unrecognised disk label
Model: Alcor Flash Disk (scsi)                                            
Disk /dev/sdc: 1048MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 
(parted) 

3. build the disk pool
# virsh pool-build disk
Pool disk built

4. # parted /dev/sdc
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: Alcor Flash Disk (scsi)
Disk /dev/sdc: 1048MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Comment 7 Yang Yang 2015-05-14 06:26:23 UTC
Set it to verified status according to comment #5

Comment 9 errata-xmlrpc 2015-11-19 05:57:54 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