Bug 1343167 - Failure when disk contains an LV with activationskip=y
Summary: Failure when disk contains an LV with activationskip=y
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.2
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On: 1218766
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-06 16:50 UTC by Nat Meo
Modified: 2016-11-03 18:01 UTC (History)
9 users (show)

Fixed In Version: libguestfs-1.32.2-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1306666
Environment:
Last Closed: 2016-11-03 18:01:18 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2576 normal SHIPPED_LIVE Moderate: libguestfs and virt-p2v security, bug fix, and enhancement update 2016-11-03 12:06:51 UTC

Description Nat Meo 2016-06-06 16:50:04 UTC
This was fixed in Fedora 22/23 but I encountered the problem in EL7 which it appears the fix was not made in. Since the fix is already known hopefully it should be a simpler matter to patch.

+++ This bug was initially created as a clone of Bug #1306666 +++

Description of problem:
guestfish -ia … fails with:
libguestfs: Fehler: internal_parse_mountable: internal_parse_mountable_stub: /dev/centos_installed/ovirt-node-ng-1.0-0.0: No such file or directory

When there is an LV inside the disk image which has activationskip=y set.

Version-Release number of selected component (if applicable):
$ rpm -q libguestfs
libguestfs-1.30.5-2.fc22.x86_64


How reproducible:
Always

Steps to Reproduce:
1. Install Fedora with LVm inside a disk image
2. inside the image: Create another volume
3. inside the image: lvchange -k y <other-vol>
4. guestfish -ia <disk-image>

Actual results:
libguestfs: Fehler: internal_parse_mountable: internal_parse_mountable_stub: /dev/centos_installed/ovirt-node-ng-1.0-0.0: No such file or directory

Expected results:
No failure

Additional info:

--- Additional comment from Richard W.M. Jones on 2016-02-11 09:42:33 EST ---

The problem is not the activationskip flag, but that libguestfs
needs to be robust and ignore LVs which were not activated.  (It's
also possible that we could activate them anyway, but there may be
other reasons why that's not a good idea).

--- Additional comment from Richard W.M. Jones on 2016-02-11 09:49:29 EST ---

Something like this (untested):

diff --git a/daemon/lvm.c b/daemon/lvm.c
index 8bef4d5..529e20d 100644
--- a/daemon/lvm.c
+++ b/daemon/lvm.c
@@ -157,6 +157,10 @@ filter_convert_old_lvs_output (char *out)
     if (lv_attr[0] == 't')
       goto skip_line;
 
+    /* Ignore activationskip (RHBZ#1306666). */
+    if (strlen (lv_attr) >= 10 && lv_attr[9] == 'k')
+      goto skip_line;
+
     /* Ignore "unknown device" message (RHBZ#1054761). */
     if (STRNEQ (p, "unknown device")) {
       char buf[256];
@@ -260,7 +264,7 @@ do_lvs (void)
     r = command (&out, &err,
                  str_lvm, "lvs",
                  "-o", "vg_name,lv_name",
-                 "-S", "lv_role=public",
+                 "-S", "lv_role=public && lv_active=active",
                  "--noheadings",
                  "--separator", "/", NULL);
     if (r == -1) {

--- Additional comment from Richard W.M. Jones on 2016-02-12 08:42:06 EST ---

My reproducer for this is a bit involved, but here goes:

$ virt-builder fedora-23
$ truncate -s 20G bigger.img
$ virt-resize fedora-23.img bigger.img
$ virt-rescue bigger.img
><rescue> pvcreate /dev/sda4
><rescue> vgcreate VG /dev/sda4
><rescue> lvcreate -L 2G -n LV1 VG
><rescue> lvcreate -L 2G -n LV2 VG
><rescue> lvcreate -L 2G -n LV3 VG
><rescue> exit

# The following command works as expected:
$ virt-inspector bigger.img

# Now we set the activationskip flag:
$ virt-rescue bigger.img
><rescue> lvchange -k y /dev/VG/LV1
><rescue> lvs -o lv_attr,lv_name,vg_name 
  Attr       LV   VG  
  -wi-a----k LV1  VG  <--- notice the 'k' flag
  -wi-a----- LV2  VG  
  -wi-a----- LV3  VG  
><rescue> exit

# Now the following command will fail:
$ virt-inspector bigger.img
libguestfs: error: internal_parse_mountable: internal_parse_mountable_stub: /dev/VG/LV1: No such file or directory
virt-inspector: no operating system could be detected inside this disk image.

--- Additional comment from Richard W.M. Jones on 2016-02-12 08:44:56 EST ---

Patch posted:
https://www.redhat.com/archives/libguestfs/2016-February/msg00089.html

--- Additional comment from Richard W.M. Jones on 2016-02-12 11:03:11 EST ---

Upstream commit:
https://github.com/libguestfs/libguestfs/commit/2e16e3e99324112845446c82b6a6e8b3e652e10d

--- Additional comment from Fedora Update System on 2016-02-12 12:50:30 EST ---

libguestfs-1.32.2-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-0a73d084ca

--- Additional comment from Fedora Update System on 2016-02-12 16:26:17 EST ---

libguestfs-1.30.6-2.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-c491f221e5

--- Additional comment from Fedora Update System on 2016-02-14 23:52:41 EST ---

libguestfs-1.30.6-2.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-c491f221e5

--- Additional comment from Fedora Update System on 2016-02-15 00:24:36 EST ---

libguestfs-1.32.2-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-0a73d084ca

--- Additional comment from Fabian Deutsch on 2016-02-17 03:23:32 EST ---

$ guestfish -a ovirt-node-ng-image.installed.qcow2

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
><fs> list-filesystems
/dev/sda1: unknown
/dev/sda2: ext4
/dev/centos_installed/ovirt-node-ng-1.0-0.0: ext4
/dev/centos_installed/ovirt-node-ng-1.0-0.0+1: ext4
/dev/centos_installed/root: ext4
/dev/centos_installed/swap: swap
/dev/centos_installed/var: ext4

This works for me.

--- Additional comment from Fabian Deutsch on 2016-02-17 03:26:09 EST ---

In comment 10 there was actually no k used - but I rechecked with k=y and it works as well:

…
><fs> sh "lvchange -k y centos_installed/ovirt-node-ng-1.0-0.0"
  Logical volume "ovirt-node-ng-1.0-0.0" changed.

><fs> sh "lvs"
  LV                      VG               Attr       LSize  Pool   Origin                Data%  Meta%  Move Log Cpy%Sync Convert
  ovirt-node-ng-1.0-0.0   centos_installed Vwi-a-tz-k 14.50g pool00 root                  12.46                                  
  ovirt-node-ng-1.0-0.0+1 centos_installed Vwi-aotz-- 14.50g pool00 ovirt-node-ng-1.0-0.0 12.78                                  
  pool00                  centos_installed twi-aotz-- 14.52g                              15.33  8.72                            
  root                    centos_installed Vwi-a-tz-- 14.50g pool00                       12.46                                  
  swap                    centos_installed -wi-a-----  2.04g                                                                     
  var                     centos_installed Vwi-a-tz--  4.00g pool00                       6.23                                   

><fs> 


------------


$ guestfish -a ovirt-node-ng-image.installed.qcow2

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
><fs> list-filesystems
/dev/sda1: unknown
/dev/sda2: ext4
/dev/centos_installed/ovirt-node-ng-1.0-0.0+1: ext4
/dev/centos_installed/root: ext4
/dev/centos_installed/swap: swap
/dev/centos_installed/var: ext4




/dev/centos_installed/ovirt-node-ng-1.0-0.0 is nto there, this is correct

--- Additional comment from Fedora Update System on 2016-02-22 15:49:41 EST ---

libguestfs-1.30.6-2.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

--- Additional comment from Fedora Update System on 2016-02-22 20:24:28 EST ---

libguestfs-1.32.2-2.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 2 Richard W.M. Jones 2016-06-09 13:38:11 UTC
This is fixed by the rebase planned for RHEL 7.3 (bug 1218766).

Please check the preview packages available below fix the problem
for you too:
https://people.redhat.com/~rjones/libguestfs-RHEL-7.3-preview/

Comment 3 Nat Meo 2016-06-09 13:51:12 UTC
I can confirm the the packages at the link you sent me work. Thank you!

Comment 4 Richard W.M. Jones 2016-06-09 14:24:25 UTC
Setting MODIFIED per comment 3.

For QA, the simplest reproducer is this one:
https://bugzilla.redhat.com/show_bug.cgi?id=1306666#c3

Comment 5 Xianghua Chen 2016-07-19 08:09:33 UTC
Verified with the packages:
libguestfs-1.32.6-1.el7.x86_64

Verify steps:
1.  Prepare a RHEL guest image: RHEL-Server-7.2-64-hvm.raw
Then resize it to 10G:
# truncate -s 10G bigger.img
# virt-resize RHEL-Server-7.2-64-hvm.raw bigger.img

2. 
# virt-rescue bigger.img 
><rescue> pvcreate /dev/sda3
><rescue> vgcreate VG /dev/sda3
><rescue> lvcreate -L 1G -n LV1 VG
><rescue> lvcreate -L 700M -n LV2 VG
><rescue> lvs
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  LV   VG              Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LV1  VG              -wi-a-----   1.00g                                                    
  LV2  VG              -wi-a----- 700.00m                                                    
  root rhel_dhcp-10-28 -wi-a-----   6.67g                                                    
  swap rhel_dhcp-10-28 -wi-a----- 820.00m                                                    
><rescue> exit

# virt-inspector bigger.img

3. 
# virt-rescue bigger.img 
><rescue> lvchange -k y /dev/VG/LV1
><rescue> lvs      
  /run/lvm/lvmetad.socket: connect failed: No such file or directory
  WARNING: Failed to connect to lvmetad. Falling back to internal scanning.
  LV   VG              Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LV1  VG              -wi-a----k   1.00g                                                    
  LV2  VG              -wi-a----- 700.00m                                                    
  root rhel_dhcp-10-28 -wi-a-----   6.67g                                                    
  swap rhel_dhcp-10-28 -wi-a----- 820.00m                                                    
><rescue> exit

# virt-inspector bigger.img


The two virt-inspector command all finished successfully in step 2 & 3.

So verified.

Comment 7 errata-xmlrpc 2016-11-03 18:01:18 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-2576.html


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