Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 608092 - Libvirt not resolving symlinks correctly, resulting in failed access to relative paths
Libvirt not resolving symlinks correctly, resulting in failed access to relat...
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.0
All Linux
low Severity medium
: rc
: 6.0
Assigned To: Eric Blake
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-25 12:18 EDT by Matěj Cepl
Modified: 2010-11-11 09:50 EST (History)
7 users (show)

See Also:
Fixed In Version: libvirt-0_8_1-12_el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-11-11 09:50:07 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Matěj Cepl 2010-06-25 12:18:57 EDT
Description of problem:
I run modprobe -v -r vhost_net and then virt-manager cannot start a virtual machine:

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/engine.py", line 878, in run_domain
    vm.startup()
  File "/usr/share/virt-manager/virtManager/domain.py", line 1314, in startup
    self._backend.create()
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 333, in create
    if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: cannot stat ../dm-3: No such file or directory

and really

there is no /dev/dm-3

although it has nothing to do with networking

johanka:~# ls -l /dev/vg_bradford/lv_tikanga
lrwxrwxrwx. 1 root root 7 25. čen 17.11 /dev/vg_bradford/lv_tikanga -> ../dm-3

Version-Release number of selected component (if applicable):
johanka:~$ rpm -q libvirt lvm2 kernel udev
libvirt-0.8.1-10.el6.x86_64
lvm2-2.02.66-3.el6.x86_64
kernel-2.6.32-33.el6.x86_64
kernel-2.6.32-36.el6.x86_64
kernel-2.6.32-37.el6.x86_64
udev-147-2.18.el6.x86_64
johanka:~$ uname -r
2.6.32-37.el6.x86_64
johanka:~$
Comment 2 Daniel Berrange 2010-06-25 12:24:24 EDT
This error message is coming from the SELinux security driver restore method

    if (virFileResolveLink(path, &newpath) < 0) {
        VIR_WARN("cannot resolve symlink %s: %s", path,
                 virStrerror(errno, ebuf, sizeof(ebuf)));
        goto err;
    }

    if (stat(newpath, &buf) != 0) {
        VIR_WARN("cannot stat %s: %s", newpath,
                 virStrerror(errno, ebuf, sizeof(ebuf)));
        goto err;
    }


So for some reason virFileResolveLink("/dev/vg_bradford/lv_tikanga") is returning "../dm-3" instead of "/dev/dm-3"

This code just calls gnulib's  areadlink(), so either there's a bug in that function, or we need to manually canonicalize the path to make it absolute instead of relative.
Comment 3 RHEL Product and Program Management 2010-06-25 12:33:39 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.
Comment 4 Eric Blake 2010-06-28 12:23:12 EDT
areadlink() intentionally returns relative paths (it is a thin wrapper around readlink(2), which does likewise), so if libvirt needs an absolute path, it needs to do manual canonicalization after the fact.
Comment 6 Dave Allan 2010-06-29 22:11:41 EDT
libvirt-0_8_1-12_el6 has been built in RHEL-6-candidate with the fix.

Dave
Comment 7 dyuan 2010-07-01 06:31:06 EDT
Hi, MCepl

I cannot reproduce the bug with libvirt-0.8.1-10.el6 and kernel-2.6.32-37.el6.x86_64. There must be some missing in my steps, could you help to check it ?

# modprobe -v -r vhost
# ll /dev/lv_pool/lv_test 
lrwxrwxrwx. 1 root root 7 Jul  1 18:21 /dev/lv_pool/lv_test -> ../dm-0

add lv_test as the second disk to guest, start guest successfully, when I shutdown the guest, only the following warning shown in /var/log/messages but not error:

Jul  1 18:16:36 dhcp-66-70-43 libvirtd: 18:16:36.632: warning : SELinuxRestoreSecurityFileLabel:372 : cannot stat ../dm-0: No such file or directory

** No warning output with libvirt-0.8.1-13.el6.
Comment 9 Eric Blake 2010-08-04 09:48:32 EDT
dyuan - it may be that you are seeing a warning rather than an error because you used a second disk.  At any rate, the warning is evidence of the bug; since it disappeared in -13, you have demonstrated that the bug was fixed.
Comment 10 dyuan 2010-08-04 22:22:51 EDT
(In reply to comment #9)
> dyuan - it may be that you are seeing a warning rather than an error because
> you used a second disk.  At any rate, the warning is evidence of the bug; since
> it disappeared in -13, you have demonstrated that the bug was fixed.    

Ah, Thanks very much:-)
Comment 11 releng-rhel@redhat.com 2010-11-11 09:50:07 EST
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

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