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 1439132 - when partition table in formats: dvh, bsd, pc98, disk pool cannot be started even if successfully built
Summary: when partition table in formats: dvh, bsd, pc98, disk pool cannot be started ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: John Ferlan
QA Contact: jiyan
URL:
Whiteboard:
Depends On:
Blocks: 1373711
TreeView+ depends on / blocked
 
Reported: 2017-04-05 10:06 UTC by yisun
Modified: 2017-08-02 01:30 UTC (History)
6 users (show)

Fixed In Version: libvirt-3.2.0-4.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-02 00:05:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description yisun 2017-04-05 10:06:12 UTC
Description of problem:
when partition table in formats: dvh, bsd, pc98, disk pool cannot be started even if successfully built


Versions:
libvirt-3.1.0-2.el7.x86_64
parted-3.1-28.el7.x86_64

How reproduced:
100%

Steps:
1. prepare a pool's xml
root@localhost ~  ## cat disk.pool
<pool type='disk'>
  <name>disk-pool</name>
  <capacity unit='bytes'>0</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>0</available>
  <source>
    <device path='/dev/sdf'/>
    <format type='dvh'/> **or bsd, pc98**
  </source>
  <target>
    <path>/dev</path>
  </target>
</pool>


2. define and build the pool
root@localhost ~  ## virsh pool-define disk.pool
Pool disk-pool defined from disk.pool

root@localhost ~  ## virsh pool-build disk-pool --overwrite
Pool disk-pool built

root@localhost ~  ## parted /dev/sdf p | grep -i partition
Partition Table: dvh

3. start the pool
root@localhost ~  ## virsh pool-start disk-pool
error: Failed to start pool disk-pool
error: operation failed: Known, but different label format present, requires build --overwrite

4. if <format type="bsd"/>, different error message came out
# virsh pool-start disk-pool
error: Failed to start pool disk-pool
error: Storage pool probe failed: Device '/dev/sdf' is unrecognized, requires build

Expected result:
Pool can be started

Actual result:
Pool cannot be started

Additional info:
This is not reproduced with libvirt-1.2.17-13.el7.x86_64
In https://libvirt.org/storage.html , the supported formats listed as follow
=======================
Valid pool format types

The disk volume pool accepts the following pool format types, representing the common partition table types:

    dos
    dvh
    gpt
    mac
    bsd
    pc98
    sun
    lvm2

The dos or gpt formats are recommended for best portability - the latter is needed for disks larger than 2TB.
=======================

Comment 2 John Ferlan 2017-04-07 11:52:00 UTC
Ugh... Not sure exactly what happened, but I easily saw the problem the 'pc98' and 'dvh' types were being left to be "validated" by parted rather than blkid, but for some reason the code missed an 'else' condition when doing a check.  As for the 'bsd' - even stranger. I know I tried every type with the adjusted algorithm, but it seems even though the code can create the 'bsd' table via parted, the recognition of that using blkid is not succeeding - I'll just add it to the list of partitions that parted will check. Finally, I found during some extra matrix testing that if a device is formatted with 'gpt' and then an attempt is made to format using 'mac', the format fails. However, by clearing out '2048' bytes from the beginning of the device that issue goes away - so I've added that too (essentially "reused" the code from bz 1430679).

I have posted patches upstream to resolve the issues:

https://www.redhat.com/archives/libvir-list/2017-April/msg00402.html

Comment 3 John Ferlan 2017-04-07 16:42:23 UTC
After a partially successful review of the series, I pushed separated pieces of patch 3 of the series - a patch dealing with the missed "else" and the one adding "bsd" to the list of format types to not try to decode using blkid:

commit f2a123203105b4fe010aea866e87f8bcf5f31193
Author: John Ferlan <jferlan>
Date:   Fri Apr 7 07:02:40 2017 -0400

    disk: Resolve issues with disk partition build/start checks
    
...
   
    Commit id 'a48c674fb' added a check for format types "dvh" and "pc98"
    to use the parted print processing instead of using blkid processing
    in order to validate the label on the disk was what is expected for
    disk pool startup. However, commit id 'a4cb4a74f' really messed things
    up by missing an else condition causing PARTEDFindLabel to always
    return DIFFERENT.

$ git describe f2a123203105b4fe010aea866e87f8bcf5f31193
v3.2.0-81-gf2a1232


commit 98f424d5038b362d1b62549930d0b9253106bdca
Author: John Ferlan <jferlan>
Date:   Fri Apr 7 09:38:44 2017 -0400

    disk: Force usage of parted when checking disk format for "bsd"

...    
    
    Add "bsd" to the list of format types to not checked during blkid
    processing even though it supposedly knows the format - for some
    (now unknown) reason it's returning partition table not found. So
    let's just let PARTED handle "bsd" too.
    
$ git describe 98f424d5038b362d1b62549930d0b9253106bdca
v3.2.0-82-g98f424d

I sent a new series to handle review feedback regarding the gpt and mac issue, see here:

https://www.redhat.com/archives/libvir-list/2017-April/msg00461.html

The new series will wipe 1M from both the head and tail of the device since as it turns out the GPT table writes information on both ends of the device.

Comment 4 John Ferlan 2017-04-26 12:21:46 UTC
With a slight adjustment to the clearing algorithm from review, this series is now pushed upstream:

$ git describe 3c4f2e3fb725054921f855a229afc7daca7119ae
v3.2.0-239-g3c4f2e3
$ git show
commit 3c4f2e3fb725054921f855a229afc7daca7119ae
Author: John Ferlan <jferlan>
Date:   Fri Apr 7 09:36:05 2017 -0400

    disk: Use virStorageBackendZeroPartitionTable
    
...
    
    During 'matrix' testing of all possible combinations I found that if
    device is formated with "gpt" first, then an attempt is made to format
    using "mac", a startup will fail.
    
    Deeper analysis by Peter Krempa indicates that the "mac" table fits
    into the first block on the disk. Since the GPT disklabel is stored
    at LBA address 1 it is not overwritten at all. Thus it's apparent that
    the (blkid) detection tool then prefers GPT over a older disklabel.
    
    The GPT disklabel has also a secondary copy at the last LBA of the disk.
    
    So, follow the same logic as the logical pool in clearing a 1MB swath
    at the beginning and end of the device to avoid potential issues with
    larger sector sizes for the device.
    
    Also fixed a minor formatting nit in virStorageBackendDeviceIsEmpty call.

Comment 7 jiyan 2017-05-11 05:24:14 UTC
Versions:
libvirt-3.2.0-4.el7.x86_64
qemu-kvm-rhev-2.9.0-3.el7.x86_64
kernel-3.10.0-664.el7.x86_64

Step to verify:
the script is as follows:
# cat action.sh 
virsh pool-define pool.xml
virsh pool-build disk-pool --overwrite
virsh pool-start disk-pool
parted /dev/sdb p |grep -i partition
virsh pool-destroy disk-pool
virsh pool-undefine disk-pool
mkfs.ext4 /dev/sdb

the pool.xml is as follows:
# cat pool.xml 
<pool type='disk'>
  <name>disk-pool</name>
  <capacity unit='bytes'>0</capacity>
  <allocation unit='bytes'>0</allocation>
  <available unit='bytes'>0</available>
  <source>
    <device path='/dev/sdb'/>
    <format type='**'/>
  </source>
  <target>
    <path>/dev</path>
  </target>
</pool>

1:when the value in "<format type='**'/>" is dvh
	# sh action.sh 
	Pool disk-pool defined from pool.xml

	Pool disk-pool built

	Pool disk-pool started

	Partition Table: dvh
	Pool disk-pool destroyed

	Pool disk-pool has been undefined

2:when the value in "<format type='**'/>" is bsd
	# sh action.sh 
	Pool disk-pool defined from pool.xml

	Pool disk-pool built

	Pool disk-pool started

	Partition Table: bsd
	Pool disk-pool destroyed

	Pool disk-pool has been undefined

3:when the value in "<format type='**'/>" is pc98
	# sh action.sh 
	Pool disk-pool defined from pool.xml

	Pool disk-pool built

	Pool disk-pool started

	Partition Table: pc98
	Pool disk-pool destroyed

	Pool disk-pool has been undefined

Comment 8 errata-xmlrpc 2017-08-02 00:05: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://access.redhat.com/errata/RHEA-2017:1846

Comment 9 errata-xmlrpc 2017-08-02 01:30:05 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://access.redhat.com/errata/RHEA-2017:1846


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