Bug 974489 - Regression: Fedora inspection broken by change from guestfs_exists to guestfs_is_file
Summary: Regression: Fedora inspection broken by change from guestfs_exists to guestfs...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libguestfs
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 974490
TreeView+ depends on / blocked
 
Reported: 2013-06-14 09:20 UTC by Richard W.M. Jones
Modified: 2013-06-14 19:29 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 974490 (view as bug list)
Environment:
Last Closed: 2013-06-14 19:29:22 UTC
Embargoed:


Attachments (Terms of Use)

Description Richard W.M. Jones 2013-06-14 09:20:01 UTC
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-06-14 10:07:04 UTC
Patches posted:

https://www.redhat.com/archives/libguestfs/2013-June/msg00055.html

Comment 2 Kashyap Chamarthy 2013-06-14 12:18:58 UTC
VERIFIED on the latest git, after applying the above patches:


$ git log --pretty=oneline | head -2
159ed220beaf9e8970f24163b75023fcf84ca9e0 inspection: Fix inspection of Fedora guests (RHBZ#974489).
20b5bac996102e6ef5d73155a7a3c85bd06170b1 Add followsymlinks flag to is-file, is-dir, is-blockdev, is-chardev, is-fifo and is-socket APIs.


$ ./autogen.sh && make -j 7 \
  && time make -k check LIBGUESTFS_DEBUG=1 \
  LIBGUESTFS_TRACE=1 | \
  tee /var/tmp/extra-tests-make-check-libugestfs-14-JUN.log


$ ./run ./inspector/virt-inspector \
  -a /var/lib/libvirt/images/fed18.qcow2 \
  | tee /tmp/inspection.txt

$ egrep -i 'distro|major_version' /tmp/inspection.txt 
    <distro>fedora</distro>
    <major_version>18</major_version>

Comment 3 Kashyap Chamarthy 2013-06-14 12:20:17 UTC
Works on a RHEL image too:

$ ./run ./inspector/virt-inspector -a \
  /var/lib/libvirt/images/el6box1.qcow2 2>&1 | tee /tmp/inspection2.txt

$ egrep -i 'distro|major_version' /tmp/inspection2.txt 
    <distro>rhel</distro>
    <major_version>6</major_version>

Comment 4 Richard W.M. Jones 2013-06-14 19:29:22 UTC
This is now fixed upstream and in libguestfs >= 1.22.3.


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