Bug 1100138 - some operation cause "lvremove" can not find the object
Summary: some operation cause "lvremove" can not find the object
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks: 1100140 1288337
TreeView+ depends on / blocked
 
Reported: 2014-05-22 05:58 UTC by bfan
Modified: 2021-04-19 10:34 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
: 1100140 (view as bug list)
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description bfan 2014-05-22 05:58:40 UTC
Description of problem:
1. create a LV on /dev/sda1, then re-partition /dev/sda1 without remove LV
2. reload disk and re-partition again, we can see LV still exists.
3. LV can't be removed


Version-Release number of selected component (if applicable):
libguestfs-1.22.6-22.el7.x86_64


How reproducible:
100%


Steps to Reproduce:
1. create a disk.
# dd if=/dev/zero of=/tmp/lvmtest.img bs=1M count=1024

2.  create a lvm on /dev/sda1, then re-partition /dev/sda1 without remove lvm.
(All commands in one line)
# guestfish -a /tmp/lvmtest.img run : part-disk /dev/sda msdos : pvcreate /dev/sda1 : vgcreate vg /dev/sda1 : lvcreate lv vg 50 : lvs : part-disk /dev/sda msdos
/dev/vg/lv
libguestfs: error: part_disk: parted: /dev/sda: Error: Partition(s) 1 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.

3. reload disk , re-partition and do lvremove
# guestfish -a /tmp/lvmtest.img run : part-disk /dev/sda msdos : lvs : lvremove /dev/vg/lv


Actual results:
libguestfs: error: lvremove: lvremove_stub: /dev/vg/lv: No such file or directory


Expected results:
lv can be removed.


Additional info:
Same operation on rhel7 guest, LV can be removed successfully

# parted -s -- /dev/xvdb mklabel msdos mkpart primary 128s -128s
# lvm pvcreate --force /dev/xvdb1
# lvm vgcreate vg /dev/xvdb1
# lvm lvcreate -L 50 -n lv vg
# parted -s -- /dev/xvdb mklabel msdos mkpart primary 128s -128s

After reboot,
# parted -s -- /dev/xvdb mklabel msdos mkpart primary 128s -128s
# lvremove /dev/vg/lv

Comment 1 Richard W.M. Jones 2014-05-22 07:39:34 UTC
I think LVM gets confused temporarily, but it doesn't seem to
be "exploitable" in any way.  ie. You cannot create a disk image
which libguestfs cannot handle.

Simpler procedure for displaying the error:

$ guestfish -N lv -- -part-disk /dev/sda mbr
$ guestfish -a test1.img run : part-disk /dev/sda mbr : lvs : lvremove /dev/VG/LV

The second command prints:

/dev/VG/LV
libguestfs: error: lvremove: lvremove_stub: /dev/VG/LV: No such file or directory

I guess we might consider doing a wipefs all operations that
create a new partition table.

Comment 2 Richard W.M. Jones 2014-05-22 07:42:47 UTC
(In reply to Richard W.M. Jones from comment #1)
> I guess we might consider doing a wipefs all operations that
                                       ^before^
> create a new partition table.

Comment 5 Richard W.M. Jones 2015-09-23 14:34:09 UTC
Bug still happens (even upstream).

Comment 7 Richard W.M. Jones 2016-06-27 15:44:59 UTC
Still happens (even upstream).  However as this is low priority
I'm moving it to RHEL 7.4.

Comment 8 Richard W.M. Jones 2017-02-16 14:50:53 UTC
We may as well handle this upstream.  It's a very contrived test
case which would not affect RHEL customers.


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