Bug 1430597

Summary: cannot create/start a disk pool without indicating disk's --source-format
Product: Red Hat Enterprise Linux 7 Reporter: yisun
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED NOTABUG QA Contact: yisun
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: dyuan, hhan, lmen, rbalakri, weizhan, xuzhang, ydu, yisun
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-24 18:23:03 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 2017-03-09 04:29:28 UTC
Description of problem:
cannot create/start a disk pool without indicating disk's --source-format 

Version-Release number of selected component (if applicable):
libvirt-3.1.0-2.el7.x86_64

How reproducible:
100%


This is a regression. If it's a designed change recently, pls close it and I'll modify our testcases.


Steps to Reproduce:
1. mklabel a disk to gpt
## parted /dev/sdd mklabel gpt -s


2. create disk pool of that disk as follow
## virsh pool-create-as --name virt-disk-pool --type disk --target /dev  --source-dev /dev/sdd
error: Failed to create pool virt-disk-pool
error: Requested operation is not valid: Format of device '/dev/sdd' does not match the expected format 'unknown'



Actual results:
pool creation failed, this doesn't happen with libvirt-2.0.0-10.el7_3.5.x86_64
And if the --source-format provided, it'll be successful.
## virsh pool-create-as --name virt-disk-pool --type disk --target /dev  --source-dev /dev/sdd --source-format gpt
Pool virt-disk-pool created



Expected results:
Should work as previous versions, as follow:

## rpm -qa | grep libvirt-2
libvirt-2.0.0-10.el7_3.5.x86_64

## virsh pool-create-as --name virt-disk-pool --type disk --target /dev  --source-dev /dev/sdd    **here we do not provide --source-format**
Pool virt-disk-pool created

## virsh pool-dumpxml virt-disk-pool
<pool type='disk'>
  <name>virt-disk-pool</name>
  <uuid>016f28b5-5777-4830-b07e-d721ae8688c6</uuid>
  <capacity unit='bytes'>8004288000</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>8004270592</available>
  <source>
    <device path='/dev/sdd'>
      <freeExtent start='17408' end='8004288000'/>
    </device>
    <format type='unknown'/>   **a pool with format type=unknown successfully created**
  </source>
  <target>
    <path>/dev</path>
  </target>
</pool>

Comment 3 John Ferlan 2017-03-24 18:23:03 UTC
There were patches added to the disk backend during libvirt 3.0.0 to "try harder" to check and ensure that there wasn't something on the disk before overwriting. So this is "expected behavior" now.

In this case you specifically put a 'gpt' format on /dev/sdd, then you expected a pool-create-as to succeed "because it did before"; however, as you point out what happened before is that libvirt overwrite /dev/sde with it's default - if you had done a 'parted /dev/sdd print', then you would have seen the Partition Table had been changed to "msdos" - which is the libvirt default as described here http://libvirt.org/storage.html#StorageBackendDisk when a specific format it not requested.


If the partition of the volume had been empty ... e.g. let's say after a:

dd if=/dev/zero of=/dev/sdd bs=1M count=2

re-running your command would give:

virsh pool-create-as --name virt-disk-pool --type disk --target /dev  --source-dev /dev/sdd 
error: Failed to create pool virt-disk-pool
error: Storage pool probe failed: Device '/dev/sdd' is unrecognized, requires build

leading to the obvious:

virsh pool-create-as --name virt-disk-pool --type disk --target /dev  --source-dev /dev/sdd  --build
Pool virt-disk-pool created

where the dumpxml :

virsh pool-dumpxml virt-disk-pool

would show:

 <source>
...
    <format type='dos'/>


Similarly, going back to square 1:

parted /dev/sdd mklabel gpt -s

and using the --overwrite flag would provide the same result


So, providing the '--source-format gpt' and having that work makes perfect sense to me since that's what libvirt finds in the disk partition table.

Closing this as NOTABUG