Bug 834896

Summary: 'mount' command hangs if you try to mount an extended partition
Product: [Community] Virtualization Tools Reporter: Steven Dake <sdake>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: dyasny, mbooth, rjones, sandro, virt-maint, walkerrichardj
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 835019 (view as bug list) Environment:
Last Closed: 2013-02-21 16:16:54 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:
Bug Depends On: 835019, 835084    
Bug Blocks:    

Description Steven Dake 2012-06-24 17:40:29 UTC
Description of problem:
Nice work on implementing guestfs - very helpful...

This bug reports a regression in behavior.

libguestfs locks up when presented with an unknown partition type during mounting.  It appears that guestfs thinks an extended partition table is an unknown type as well, which may be commonly presented during vm installation with legacy operating systems.

This wouldn't be much of a problem except of that oz attempts to run an inspect-os on U10/U12 which leads to a lockup.  I'll look into changing the partitioning of oz to remove the extended partition table.

Version-Release number of selected component (if applicable):
libguestfs-tools-c-1.18.2-1.fc17.x86_64

also tried 1.18.1 (shipped with F17)

How reproducible:
100%

Steps to Reproduce:
Create a U10 oz image.  For an example template, see:
https://github.com/heat-api/heat-jeos/blob/master/heat_jeos/jeos/U10-amd64-cfntools-jeos.tdl

oz-install -d3 U10-amd64-cfntools-jeos.tdl (this works)

oz-customize U10*tdl U10* (this doesn't work since guestfs locks up)

[root@bigiron images]# guestfish -a U12*

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

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

><fs> run
><fs> list-filesystems
/dev/vda1: ext4
/dev/vda2: unknown
/dev/vda5: swap
/dev/vda6: ext4
><fs> mount mount /dev/vda1 /
mount should have 2 parameter(s)
type 'help mount' for help on mount
><fs> mount /dev/vda /
libguestfs: error: mount: /dev/vda on / (options: ''): mount: wrong fs type, bad option, bad superblock on /dev/vda,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so
><fs> mount /dev/vda6 /
><fs> mount /dev/vda2 /

Locks up here

Another go:
[root@bigiron images]# guestfish -a U12*

Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.

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

><fs> run
><fs> inspect-os

Locks up here
  
Actual results:
inspect-os or mounting a filesystem type with an unknown partition type locks up guestfs

Expected results:
no lockup - revert regression introduced in F17 and later F16 guestfs.

Additional info:
root@unassigned-hostname:~# fdisk /dev/vda 

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/vda: 10.7 GB, 10737418240 bytes
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000f1f

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           3        5880     2962432   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2            5882       20804     7520257    5  Extended
Partition 2 does not end on cylinder boundary.
/dev/vda5            5882        6654      389120   82  Linux swap / Solaris
/dev/vda6            6657       20804     7130112   83  Linux

Comment 1 Richard W.M. Jones 2012-06-25 08:47:52 UTC
Here is a simple reproducer:

guestfish -x <<EOF
  sparse test1.img 100M
  run
  part-init /dev/sda mbr
  part-add /dev/sda p 32 127
  part-add /dev/sda e 128 -32
  part-add /dev/sda l 140 499
  part-add /dev/sda l 501 -64
  part-list /dev/sda
  mount /dev/sda2 /
EOF

It hangs at the last (mount) line where it's trying to mount
the extended partition.  Of course that makes no sense, but
it shouldn't hang.

You can get additional debug information by adding the '-v'
flag to the guestfish command line.

guestfsd is just executing this command:

  mount -o  /dev/vda2 /sysroot/

So it appears to be a kernel bug.

Comment 2 Richard W.M. Jones 2012-06-25 08:48:39 UTC
>   mount -o  /dev/vda2 /sysroot/

I should have written:

 mount -o '' /dev/vda2 /sysroot/

Comment 3 Richard W.M. Jones 2012-06-25 09:13:31 UTC
Affected systems:

Distro      Kernel                   Affected?

Fedora 16   3.1.0-7.fc16.x86_64      N
Fedora 16   3.4.2-1.fc16.x86_64      Y
Fedora 17   3.4.0-1.fc17.x86_64      Y
Rawhide     3.5.0-0.rc2.git0.1.fc18.x86_64  Y
Rawhide     3.5.0-0.rc3.git0.2.fc18.x86_64  Y
RHEL 6      2.6.32-221.el6.x86_64    N

So it appears to be a bug that has been introduced to
the kernel between 3.1.0 and 3.4.2 (unfortunately rather
a large range of versions!)

Next step is to work out where exactly in kernel or
userspace it is spinning.

Comment 4 Richard W.M. Jones 2012-07-31 12:32:48 UTC
This has been fixed in the kernel and the fixes have been
backported to earlier kernel stable branches.  On that basis
I'm closing this bug.  If you still have this bug, update
your kernel.

Comment 5 Sandro Mathys 2013-02-21 14:35:44 UTC
Is it possible that this issue has been reintroduced?

$ uname -a
Linux tiphares.ethz.ch 3.7.6-102.fc17.x86_64 #1 SMP Mon Feb 4 17:40:25 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

But oz-install will give me:

Traceback (most recent call last):
  File "/bin/oz-install", line 143, in <module>
    guest.generate_install_media(force_download)
  File "/usr/lib/python2.7/site-packages/oz/RedHat.py", line 732, in generate_install_media
    return self._iso_generate_install_media(fetchurl, force_download)
  File "/usr/lib/python2.7/site-packages/oz/Guest.py", line 1565, in _iso_generate_install_media
    self._copy_iso()
  File "/usr/lib/python2.7/site-packages/oz/Guest.py", line 1269, in _copy_iso
    gfs.mount_options('ro', "/dev/sda", "/")
  File "/usr/lib/python2.7/site-packages/guestfs.py", line 2743, in mount_options
    return libguestfsmod.mount_options (self._o, options, device, mountpoint)
RuntimeError: mount_options: /dev/vda on / (options: 'ro'): mount: wrong fs type, bad option, bad superblock on /dev/vda,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail or so

Comment 6 Richard W.M. Jones 2013-02-21 16:16:35 UTC
(In reply to comment #5)
> Is it possible that this issue has been reintroduced?
> 
> $ uname -a
> Linux tiphares.ethz.ch 3.7.6-102.fc17.x86_64 #1 SMP Mon Feb 4 17:40:25 UTC
> 2013 x86_64 x86_64 x86_64 GNU/Linux
> 
> But oz-install will give me:
> 
> Traceback (most recent call last):
>   File "/bin/oz-install", line 143, in <module>
>     guest.generate_install_media(force_download)
>   File "/usr/lib/python2.7/site-packages/oz/RedHat.py", line 732, in
> generate_install_media
>     return self._iso_generate_install_media(fetchurl, force_download)
>   File "/usr/lib/python2.7/site-packages/oz/Guest.py", line 1565, in
> _iso_generate_install_media
>     self._copy_iso()
>   File "/usr/lib/python2.7/site-packages/oz/Guest.py", line 1269, in
> _copy_iso
>     gfs.mount_options('ro', "/dev/sda", "/")
>   File "/usr/lib/python2.7/site-packages/guestfs.py", line 2743, in
> mount_options
>     return libguestfsmod.mount_options (self._o, options, device, mountpoint)
> RuntimeError: mount_options: /dev/vda on / (options: 'ro'): mount: wrong fs
> type, bad option, bad superblock on /dev/vda,
>        missing codepage or helper program, or other error
>        In some cases useful info is found in syslog - try
>        dmesg | tail or so

While it's possible, it doesn't seem likely.  That error
can mean many different things.

Enable debugging
http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
and open a new bug if you think there is a problem
http://libguestfs.org/guestfs-faq.1.html#getting-help-and-reporting-bugs