Bug 974490

Summary: Regression: Fedora inspection broken by change from guestfs_exists to guestfs_is_file
Product: Red Hat Enterprise Linux 7 Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, bfan, leiwang, lkong, mbooth, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.22.4-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 974489 Environment:
Last Closed: 2014-06-13 10:15:40 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: 974489    
Bug Blocks:    

Description Richard W.M. Jones 2013-06-14 09:21:33 UTC
+++ This bug was initially created as a clone of Bug #974489 +++

[Just need to check that we don't ship RHEL 7.0 by
accident with this bug]

Description of problem:

(Bug found by Matt Booth)

The following commit:
https://github.com/libguestfs/libguestfs/commit/e71b2c11f59b3f8ae0c4b31c4ab5b0d1bfcdf181
(also present in libguestfs 1.22) changes various calls to
guestfs_exists to guestfs_is_file.  This was done to make
fuzz-testing of inspection easier.

Unfortunately at least this change:

-  if (guestfs_exists (g, "/etc/redhat-release") > 0) {
+  if (guestfs_is_file (g, "/etc/redhat-release") > 0) { 

breaks inspection of Fedora guests since /etc/redhat-release
is a symlink:

$ ls -l /etc/redhat-release 
lrwxrwxrwx. 1 root root 14 Jan 17 08:28 /etc/redhat-release -> fedora-release

I haven't checked all the other distros but it is possible
the change could break those as well.

What we really want to do is test that these are files or
symlinks to files, since if the test succeeds we usually
open the file and read its contents.

Matt suggests changing the is_file etc APIs to add a
followsymlinks optional boolean flag.  Possible APIs that
would be changed like this are:

is-blockdev          test if block device
is-chardev           test if character device
is-dir               test if a directory
is-fifo              test if FIFO (named pipe)
is-file              test if a regular file
is-socket            test if socket

By using the once_had_no_optargs flag in the generator this
change should be backwards compatible.

Version-Release number of selected component (if applicable):

libguestfs 1.22.2
libguestfs >= 1.23.2

How reproducible:

100%

Steps to Reproduce:
1. Inspect (eg. run virt-inspector) on a Fedora guest.

Actual results:

Inspection "half works", but it doesn't detect that it's a Fedora
VM:

<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/fedora/root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <major_version>0</major_version>
    <minor_version>0</minor_version>

Note there is no <distro>fedora</distro> and the major version number
are bogus.

Expected results:

<distro>fedora</distro> and <major_version/> set to some non-zero value.
List of applications shown.  etc.

Additional info:

Comment 1 Richard W.M. Jones 2013-07-18 16:08:24 UTC
Upstream fix is included in >= 1.22.3.

Comment 3 Lingfei Kong 2013-11-08 09:00:54 UTC
I can reproduce it with libguestfs-1.22.2-1.el7

Steps to reproduce:
1. Prepare a Fedora image such as Fedora18, make sure /etc/redhat-release
is a symlink:
$ ls -l /etc/redhat-release 
lrwxrwxrwx. 1 root root 14 Jan 17 08:28 /etc/redhat-release -> fedora-release

2. #virt-inspector Fedora-18.raw
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/fedora_dhcp-11-24/root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <major_version>0</major_version>
    <minor_version>0</minor_version>

also I can not find some content like: "<distro>fedora</distro>" from the output.

Comment 4 Lingfei Kong 2013-12-06 08:50:31 UTC
Verified with libguestfs-1.22.6-15.el7

Steps to verify:
1. Prepare a Fedora image such as Fedora18, make sure /etc/redhat-release
is a symlink:
#ls -l /etc/redhat-release 
lrwxrwxrwx. 1 root root 14 Apr 24  2013 /etc/redhat-release -> fedora-release

2. #virt-inspector Fedora-18.raw
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/fedora_dhcp-11-24/root</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>fedora</distro>
    <product_name>Fedora release 18 (Spherical Cow)</product_name>
    <major_version>18</major_version>
    <minor_version>0</minor_version>
    <package_format>rpm</package_format>
    <package_management>yum</package_management>


I can see <distro>fedora</distro>,  <product_name>Fedora release 18 (Spherical Cow)</product_name>,     <major_version>18</major_version>, <minor_version>0</minor_version>  in the output.

So the bug is fixed.

Comment 5 Ludek Smid 2014-06-13 10:15:40 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.