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 611443 - User can not delete the volume in a pool built on a mapper device.
Summary: User can not delete the volume in a pool built on a mapper device.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Osier Yang
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-07-05 10:11 UTC by Johnny Liu
Modified: 2018-11-14 14:05 UTC (History)
9 users (show)

Fixed In Version: libvirt-0.8.7-7.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-19 13:19:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0596 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2011-05-18 17:56:36 UTC

Description Johnny Liu 2010-07-05 10:11:16 UTC
Description of problem:
Create a pool on a mapper device, and create some volume in the pool, when trying to delete the volume, the following error is seen:
# virsh vol-delete /dev/mapper/myvm10p1
error: Failed to delete vol /dev/mapper/myvm10p1
error: internal error Volume path 'dm-1' did not start with parent pool source device name.


Version-Release number of selected component (if applicable):
libvirt-0.8.1-13.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a pool on a mapper device
# virsh pool-dumpxml xx
<pool type='disk'>
  <name>xx</name>
  <uuid>08a0a104-cbc3-0b96-bd6a-b1f8d00d9474</uuid>
  <capacity>0</capacity>
  <allocation>0</allocation>
  <available>0</available>
  <source>
    <device path='/dev/mapper/myvm10'/>
    <format type='dos'/>
  </source>
  <target>
    <path>/dev</path>
    <permissions>
      <mode>0700</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>
# virsh vol-list xx
Name                 Path                                    
-----------------------------------------
myvm10p1             /dev/mapper/myvm10p1       
# ll /dev/mapper/myvm10*
lrwxrwxrwx. 1 root root 7 Jul  5 14:07 /dev/mapper/myvm10 -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jul  5 14:07 /dev/mapper/myvm10p1 -> ../dm-1
             
2. Try to delete the volume in the pool
# virsh vol-delete /dev/mapper/myvm10p1
error: Failed to delete vol /dev/mapper/myvm10p1
error: internal error Volume path 'dm-1' did not start with parent pool source device name.

3.
  
Actual results:
User can not delete the volume in a pool built on a mapper device.

Expected results:
User should can delete the volume in the mapper pool.

Additional info:

Comment 2 Dave Allan 2010-07-07 14:12:34 UTC
Libvirt currently has trouble with pools built on dev mapper devices as the partition naming works a little differently.  This BZ is a dup of 593785.

*** This bug has been marked as a duplicate of bug 593785 ***

Comment 3 Johnny Liu 2010-07-15 09:09:02 UTC
Bug 593785 is about volume creation on mapper device, this bug is about volume deletion operation, So they are different bug.

And I also re-tested this bug with libvirt-0.8.1-15.el6.x86_64 (Bug 593785 has been fixed on the -15 version), this issue still reproduced, so I reopened this bug.


# rpm -q libvirt
libvirt-0.8.1-15.el6.x86_64

# virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
xx                   active     no 

# virsh pool-dumpxml xx
<pool type='disk'>
  <name>xx</name>
  <uuid>ec1942d9-0bf3-7793-f46b-83cc839772fd</uuid>
  <capacity>42944186880</capacity>
  <allocation>1052803584</allocation>
  <available>41891351040</available>
  <source>
    <device path='/dev/mapper/mpatha'>
    <freeExtent start='1052835840' end='42944186880'/>
    </device>
    <format type='dos'/>
  </source>
  <target>
    <path>/dev</path>
    <permissions>
      <mode>0700</mode>
      <owner>-1</owner>
      <group>-1</group>
    </permissions>
  </target>
</pool>

# virsh vol-list xx
Name                 Path                                    
-----------------------------------------
mpathap1             /dev/mapper/mpathap1

# ll /dev/mapper/mpatha*
lrwxrwxrwx. 1 root root 7 Jul 15 12:51 /dev/mapper/mpatha -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jul 15 12:51 /dev/mapper/mpathap1 -> ../dm-1

# virsh vol-delete --pool xx mpathap1
error: Failed to delete vol mpathap1
error: internal error Volume path 'dm-1' did not start with parent pool source device name.

Comment 4 Dave Allan 2010-07-15 17:58:32 UTC
Ok, fair enough; I'll look into it.

Comment 5 Dave Allan 2010-07-15 23:18:05 UTC
So, it turns out that it is essentially the same problem as the BZ I thought it was a dup of, but it is indeed a separate bug.  I'm working on a fix.

Comment 11 Osier Yang 2011-01-29 10:37:55 UTC
the problem is the logic of "virStorageBackendDiskDeleteVol" doesn't work for device mapper volume at all.


    devname = basename(devpath);
    srcname = basename(pool->def->source.devices[0].path);
    DEBUG("devname=%s, srcname=%s", devname, srcname);

    if (!STRPREFIX(devname, srcname)) {
        virStorageReportError(VIR_ERR_INTERNAL_ERROR,
                              _("Volume path '%s' did not start with parent "
                                "pool source device name '%s'."), devname,
                              srcname);
        goto cleanup;
    }

e.g. For jialiu's case:

devname = "dm-1"
srcname = "mpatha"

And the method to calculate partion number also not correct for a device mapper volume.

    part_num = devname + strlen(srcname);

Fortunately, we quit with the check before, we need a new logic for device mapper volume.

Comment 12 Dave Allan 2011-01-31 02:35:38 UTC
As you've noticed, the problem here is that the logic to calculate the partition number isn't correct when the underlying device is a dm device.  The logic I used in the create case is at:

https://www.redhat.com/archives/libvir-list/2010-July/msg00186.html

committed upstream as:

ae3275c0bb538e29eab840153ccc748cd5023cf7

Comment 13 Osier Yang 2011-02-17 08:22:03 UTC
http://post-office.corp.redhat.com/archives/rhvirt-patches/2011-February/msg01080.html

patch posted internally. move to POST.

Comment 15 zhanghaiyan 2011-02-21 11:06:50 UTC
Verified this bug PASS with libvirt-0.8.7-7.el6.x86_64
- kernel-2.6.32-113.el6.x86_64
- qemu-kvm-0.12.1.2-2.147.el6.x86_64

1. # cat xx.xml
<pool type='disk'>
  <name>xx</name>
  <source>
    <device path='/dev/mapper/mpathc'/>
  </source>
  <target>
    <path>/dev</path>
  </target>
</pool>
# virsh pool-create xx.xml
Pool xx created from xx.xml

2. # virsh vol-create-as --pool xx --name xx-1 --capacity 2G
Vol xx-1 created
# virsh vol-list xx
Name                 Path                                    
-----------------------------------------
xx-1                 /dev/mapper/mpathcp1 
# ll /dev/mapper/
total 0
crw-rw----. 1 root root  10, 58 Feb 21 13:11 control
lrwxrwxrwx. 1 root root       7 Feb 21 13:42 mpathb -> ../dm-1
lrwxrwxrwx. 1 root root       7 Feb 21 13:42 mpathc -> ../dm-0
brw-rw----. 1 root disk 253,  2 Feb 21 14:03 mpathcp1
# fdisk /dev/mapper/mpathc

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/mapper/mpathc: 21.3 GB, 21346910208 bytes
23 heads, 16 sectors/track, 113296 cylinders
Units = cylinders of 368 * 512 = 188416 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c1644

             Device Boot      Start         End      Blocks   Id  System
/dev/mapper/mpathcp1               1       11398     2097152   83  Linux

3. # virsh vol-delete /dev/mapper/mpathcp1 --pool xx
Vol /dev/mapper/mpathcp1 deleted

4. # virsh pool-list --all
Name                 State      Autostart 
-----------------------------------------
default              active     yes       
xx                   active     no 
# virsh vol-list xx
Name                 Path                                    
-----------------------------------------
# ll /dev/mapper/
total 0
crw-rw----. 1 root root 10, 58 Feb 21 13:11 control
lrwxrwxrwx. 1 root root      7 Feb 21 13:42 mpathb -> ../dm-1
lrwxrwxrwx. 1 root root      7 Feb 21 13:42 mpathc -> ../dm-0

Comment 18 errata-xmlrpc 2011-05-19 13:19:23 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

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


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