Bug 1251461

Summary: libvirt produced ambiguous error message when create disk pool with a block device which has no disk label
Product: Red Hat Enterprise Linux 7 Reporter: yisun
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dyuan, jferlan, pkrempa, rbalakri, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.1-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:22:31 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:

Description yisun 2015-08-07 11:31:51 UTC
summary:
libvirt produced ambiguous error message when create disk pool with a block device which has no disk label


versions:
kernel-devel-3.10.0-302.el7.x86_64
libvirt-1.2.17-3.el7.x86_64
qemu-kvm-rhev-2.3.0-14.el7.x86_64

how reproducible:
100%

steps:
1. prepare a block device ( such as a usb disk)
2. mkfs the whole block device
#mkfs.ext3 /dev/sdb
...
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
3. prepare a disk pool xml
#cat disk.pool
<pool type='disk'>
<name>sdb</name>
<source>
<device path='/dev/sdb'>
</device>
<format type='dos'/>
</source>
<target>
<path>/dev</path>
<permissions>
<mode>0700</mode>
<owner>0</owner>
<group>0</group>
</permissions>
</target>
</pool>
4. # virsh pool-create disk.pool 
error: Failed to create pool from disk.pool
error: Storage volume not found: no storage vol with matching path '/dev/sdb1'

Actual result:
in step 4, libvirt reports there is no /dev/sdb1 as an error

Expect result:
The error message doesn't make sense, why a disk pool requires the block device must have a partition sdb1? 

Additional info:
If use parted mklabel to that block device, the pool can be started correctly
# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel                                                          
New disk label type? msdos                                                
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
(parted) quit                                                             
Information: You may need to update /etc/fstab.
# virsh pool-create disk.pool                           
Pool sdb created from disk.pool

Comment 2 John Ferlan 2015-10-06 11:41:51 UTC
Pushed upstream as commit id '657f3bea8ded929c16dd96bb3c02d88af4c71a1b'

git describe 657f3bea8ded929c16dd96bb3c02d88af4c71a1b
v1.2.20-27-g657f3be

May require following commits too:

2f177c5a41de50143453aba333774f3023e946b7
05c46f5c2267a52a2011d5ce0cd4fce1f5334761
fba2076f43032632b1cbd29416c57955f943d828

Comment 4 yisun 2016-02-26 10:24:06 UTC
Verified on libvirt-1.3.1-1.el7.x86_64
and PASSED.


Scenarios:
1. check when disk source doesn't exist, proper error message will be produced. 
# cat disk.pool 
<pool type='disk'>
<name>sdz</name>
<source>
<device path='/dev/sdz'>
</device>
<format type='dos'/>
</source>
<target>
<path>/dev</path>
<permissions>
<mode>0700</mode>
<owner>0</owner>
<group>0</group>
</permissions>
</target>
</pool>


#virsh pool-create disk.pool 
error: Failed to create pool from disk.pool
error: invalid argument: device path '/dev/sdz' doesn't exist


# virsh pool-define disk.pool
Pool sdz defined from disk.pool


# virsh pool-start sdz
error: Failed to start pool sdz
error: invalid argument: device path '/dev/sdz' doesn't exist



===========================

2. check when a invalid disk label exist, a warning message will be properly produced.
# virsh pool-list --all
-------------------------------------------
...
 sdb                  inactive   no        
...

# virsh pool-dumpxml sdb
<pool type='disk'>
  <name>sdb</name>
  <uuid>2961824b-a3c2-4b4d-a2b5-9f846cb040ad</uuid>
  <capacity unit='bytes'>0</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>0</available>
  <source>
    <device path='/dev/sdb'/>
    <format type='dos'/>
  </source>
  <target>
    <path>/dev</path>
    <permissions>
      <mode>0700</mode>
      <owner>0</owner>
      <group>0</group>
    </permissions>
  </target>
</pool>
     
# parted /dev/sdb mklabel loop
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
Information: You may need to update /etc/fstab.

# parted /dev/sdb print
Model: IET VIRTUAL-DISK (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 
Number  Start  End  Size  File system  Flags


# virsh pool-build sdb --no-overwrite
error: Failed to build pool sdb
error: operation failed: Unknown Partition Type, requires build --overwrite


# virsh pool-build sdb --overwrite
Pool sdb built




3. check when a valid disk label exists, a warning message will be properly produced. 
# parted /dev/sdb mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
Information: You may need to update /etc/fstab.

# virsh pool-build sdb --no-overwrite              
error: Failed to build pool sdb
error: Requested operation is not valid: Valid disk label already present, requires --overwrite


# virsh pool-build sdb --overwrite
Pool sdb built

# parted /dev/sdb print
Model: IET VIRTUAL-DISK (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 
Number  Start  End  Size  Type  File system  Flags


4. check comment 0's scenario
# parted /dev/sdb mklabel loop
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
Information: You may need to update /etc/fstab.

# virsh pool-create disk.pool                      
error: Failed to create pool from disk.pool
error: operation failed: Unknown Partition Type, requires build --overwrite

Comment 6 errata-xmlrpc 2016-11-03 18:22:31 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/RHSA-2016-2577.html