Bug 608092 - Libvirt not resolving symlinks correctly, resulting in failed access to relative paths
Summary: Libvirt not resolving symlinks correctly, resulting in failed access to relat...
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.0
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: 6.0
Assignee: Eric Blake
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-06-25 16:18 UTC by Matěj Cepl
Modified: 2010-11-11 14:50 UTC (History)
7 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2010-11-11 14:50:07 UTC


Attachments (Terms of Use)

Description Matěj Cepl 2010-06-25 16:18:57 UTC
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 16:24:24 UTC
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 16:33:39 UTC
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 16:23:12 UTC
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-30 02:11:41 UTC
libvirt-0_8_1-12_el6 has been built in RHEL-6-candidate with the fix.

Dave

Comment 7 dyuan 2010-07-01 10:31:06 UTC
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 13:48:32 UTC
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-05 02:22:51 UTC
(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 14:50:07 UTC
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.