Bug 1673280

Summary: virt-inspector fails with "error: int_of_string" on a Linux image when /etc/fstab contains a partionless device [rhel-7.6.z]
Product: Red Hat Enterprise Linux 7 Reporter: RAD team bot copy to z-stream <autobot-eus-copy>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: YongkuiGuo <yoguo>
Severity: medium Docs Contact:
Priority: high    
Version: 7.7CC: linl, mxie, ptoscano, tzheng, yoguo
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.38.2-12.el7_6.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1672951 Environment:
Last Closed: 2019-03-13 18:46:19 UTC Type: ---
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: 1672951    
Bug Blocks:    

Description RAD team bot copy to z-stream 2019-02-07 08:51:18 UTC
This bug has been copied from bug #1672951 and has been proposed to be backported to 7.6 z-stream (EUS).

Comment 3 YongkuiGuo 2019-02-12 02:28:22 UTC
Verified with package:
libguestfs-1.38.2-12.el7_6.2.x86_64

Steps:

1. Download the condor-fedora-24-64-master-2016080801.qcow2 image from the link: https://platform.swampinabox.org/platform-images/condor-fedora-24-64-master-2016080801.qcow2.gz
2. 
# virt-inspector -a condor-fedora-24-64-master-2016080801.qcow2
libguestfs: error: mount_ro: mount_ro_stub: /dev/vdb: expecting a device name
libguestfs: error: mount_ro: mount_ro_stub: /dev/vdc: expecting a device name
virt-inspector: some filesystems could not be mounted (ignored)
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/vg0/lv_root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>fedora</distro>
    <product_name>Fedora 24 (Twenty Four)</product_name>
    <major_version>24</major_version>
    <minor_version>0</minor_version>
    <package_format>rpm</package_format>
    <package_management>dnf</package_management>
    <hostname>localhost.localdomain</hostname>
    <osinfo>fedora24</osinfo>
    <mountpoints>
      <mountpoint dev="/dev/vg0/lv_root">/</mountpoint>
      <mountpoint dev="/dev/sda2">/boot</mountpoint>
      <mountpoint dev="/dev/sdb">/mnt/in</mountpoint>
      <mountpoint dev="/dev/sdc">/mnt/out</mountpoint>
    </mountpoints>
    <filesystems>
      <filesystem dev="/dev/sda2">
        <type>ext4</type>
        <uuid>4c029e08-3e60-4227-8a5b-de2c500daf08</uuid>
      </filesystem>
      <filesystem dev="/dev/sdb"/>
      <filesystem dev="/dev/sdc"/>
      <filesystem dev="/dev/vg0/lv_root">
        <type>ext4</type>
        <uuid>36ef4986-e9a4-4177-b251-455618165972</uuid>
      </filesystem>
      <filesystem dev="/dev/vg0/lv_swap">
        <type>swap</type>
        <uuid>299e4b2f-4946-4b48-97ce-6b6afd4735e7</uuid>
      </filesystem>
    </filesystems>
...

The virt-inspector command can inspect the linux image when /etc/fstab contains a partionless device. Verified this bug.

Comment 4 mxie@redhat.com 2019-02-12 06:40:29 UTC
Reproduce the bug with builds:
virt-v2v-1.38.2-12.el7_6.1.x86_64
libguestfs-1.38.2-12.el7_6.1.x86_64

Steps to reproduce:
1.Add one disk to a linux guest on VMware host, then create partition for the new added disk and format the disk as ext3

2.Create /mnt/in and add below info in /etc/fstab (the new disk has no partition number)
# cat /etc/fstab
....
/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=3c069c5d-9497-4d39-808c-011354d29760 /boot                   xfs     defaults        0 0
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/dev/sdb        /mnt/in                ext3        defaults        0 0
      

3.Reboot the guest, guest will boot into emergency mode

4.Power off guest, then use virt-v2v to convert it to rhv
# virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1  --password-file /tmp/passwd esx6.7-rhel7.6-x86_64-fstab-partionless -o rhv -os 10.66.144.40:/home/nfs_export
[   0.0] Opening the source -i libvirt -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-x86_64-fstab-partionless
[   3.9] Creating an overlay to protect the source from being modified
[   5.3] Initializing the target -o rhv -os 10.66.144.40:/home/nfs_export
[   5.6] Opening the overlay
[  45.4] Inspecting the overlay
virt-v2v: error: libguestfs error: inspect_os: int_of_string

If reporting bugs, run virt-v2v with debugging enabled and include the 
complete output:

  virt-v2v -v -x [...]


Verify the bug with builds:
virt-v2v-1.38.2-12.el7_6.2.x86_64
libguestfs-1.38.2-12.el7_6.2.x86_64

Steps:
1.Convert above guest by virt-v2v again
# virt-v2v -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1  --password-file /tmp/passwd esx6.7-rhel7.6-x86_64-fstab-partionless -o rhv -os 10.66.144.40:/home/nfs_export
[   0.0] Opening the source -i libvirt -ic vpx://root.73.141/data/10.73.75.219/?no_verify=1 esx6.7-rhel7.6-x86_64-fstab-partionless
[   4.2] Creating an overlay to protect the source from being modified
[   5.7] Initializing the target -o rhv -os 10.66.144.40:/home/nfs_export
[   6.2] Opening the overlay
[  28.8] Inspecting the overlay
virt-v2v: warning: mount: mount exited with status 32: mount: /dev/sdb is 
write-protected, mounting read-only
mount: unknown filesystem type '(null)' (ignored)
[ 216.5] Checking for sufficient free disk space in the guest
[ 216.5] Estimating space required on target for each disk
[ 216.5] Converting Red Hat Enterprise Linux Server 7.6 (Maipo) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[1443.4] Mapping filesystem data to avoid copying unused and blank areas
[1453.1] Closing the overlay
[1453.6] Checking if the guest needs BIOS or UEFI to boot
[1453.6] Assigning disks to buses
[1453.6] Copying disk 1/2 to /tmp/v2v.8vzNy7/c980b640-cb59-47f7-a0fe-90312d33deae/images/c9412985-5146-4db6-8fc5-7796771199d8/cf6212ac-7e65-452d-a81f-907aefdfd991 (raw)
    (100.00/100%)
[2094.6] Copying disk 2/2 to /tmp/v2v.8vzNy7/c980b640-cb59-47f7-a0fe-90312d33deae/images/ac4552f7-ad1f-4cdd-9543-52d8af036eb7/64d2aa7d-0761-4f8a-8166-0ebee5cbeb7c (raw)
    (100.00/100%)
[2176.4] Creating output metadata
[2176.5] Finishing off

2.After finishing conversion,import guest from export domain to data domain and power on, guest will boot into emergency mode

Comment 6 errata-xmlrpc 2019-03-13 18:46:19 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/RHBA-2019:0513