Bug 987306 - local link files of systemd container link to none exist src files
local link files of systemd container link to none exist src files
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt-sandbox (Show other bugs)
7.0
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Daniel Berrange
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-23 04:23 EDT by Wayne Sun
Modified: 2013-10-02 11:05 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-02 11:05:36 EDT
Type: Bug
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 Wayne Sun 2013-07-23 04:23:27 EDT
Description of problem:
local link files of systemd container link to none exist src files, this is not blocking anything now, but something might be wrong.

Version-Release number of selected component (if applicable):
libvirt-sandbox-0.2.1-1.el7.x86_64
systemd-204-4.el7.x86_64
kernel-3.9.0-0.55.el7.x86_64
libvirt-1.1.0-2.el7.x86_64


How reproducible:
always

Steps to Reproduce:
1. create a systemd container
# virt-sandbox-service -c lxc:/// create -C -u httpd.service -s static,label=system_u:system_r:svirt_lxc_net_t:s0:c1,c2 -N dhcp,source=default apache2

# virt-sandbox-service list
apache2

2. check some local link files
#  ll /var/lib/libvirt/filesystems/apache2/usr/lib/systemd/system/sockets.target.wants/
total 0
lrwxrwxrwx. 1 root root 14 Jul 18 17:33 dbus.socket -> ../dbus.socket
lrwxrwxrwx. 1 root root 25 Jul 18 17:33 systemd-initctl.socket -> ../systemd-initctl.socket
lrwxrwxrwx. 1 root root 26 Jul 18 17:33 systemd-journald.socket -> ../systemd-journald.socket
lrwxrwxrwx. 1 root root 27 Jul 18 17:33 systemd-shutdownd.socket -> ../systemd-shutdownd.socket

#  ll /var/lib/libvirt/filesystems/apache2/usr/lib/systemd/system/sysinit.target.wants/
total 0
lrwxrwxrwx. 1 root root 33 Jul 18 17:33 systemd-tmpfiles-setup.service -> ../systemd-tmpfiles-setup.service

the link src files created under sockets.target.wants and sysinit.target.wants point to upper dir /var/lib/libvirt/filesystems/apache2/usr/lib/systemd/system files which are not exist.

3.

Actual results:
the local link files created point to none exist files

Expected results:
point to exist files

Additional info:
source code for create those files:
# vim bin/virt-sandbox-service +681

        for i, src in self.unit_file_list:
            self.create_container_unit(src, self.dest + unitdir, i)
            if is_template_unit(i):
                i = self.get_expanded_unit_template(i)
            os.symlink("../" + i, self.dest + tgtdir + "/" + i)
Comment 2 Daniel Berrange 2013-10-02 11:05:36 EDT
(In reply to Wayne Sun from comment #0)
> Description of problem:
> local link files of systemd container link to none exist src files, this is
> not blocking anything now, but something might be wrong.
> 
> Version-Release number of selected component (if applicable):
> libvirt-sandbox-0.2.1-1.el7.x86_64
> systemd-204-4.el7.x86_64
> kernel-3.9.0-0.55.el7.x86_64
> libvirt-1.1.0-2.el7.x86_64
> 
> 
> How reproducible:
> always
> 
> Steps to Reproduce:
> 1. create a systemd container
> # virt-sandbox-service -c lxc:/// create -C -u httpd.service -s
> static,label=system_u:system_r:svirt_lxc_net_t:s0:c1,c2 -N
> dhcp,source=default apache2
> 
> # virt-sandbox-service list
> apache2
> 
> 2. check some local link files
> #  ll
> /var/lib/libvirt/filesystems/apache2/usr/lib/systemd/system/sockets.target.
> wants/
> total 0
> lrwxrwxrwx. 1 root root 14 Jul 18 17:33 dbus.socket -> ../dbus.socket
> lrwxrwxrwx. 1 root root 25 Jul 18 17:33 systemd-initctl.socket ->
> ../systemd-initctl.socket
> lrwxrwxrwx. 1 root root 26 Jul 18 17:33 systemd-journald.socket ->
> ../systemd-journald.socket
> lrwxrwxrwx. 1 root root 27 Jul 18 17:33 systemd-shutdownd.socket ->
> ../systemd-shutdownd.socket
> 
> #  ll
> /var/lib/libvirt/filesystems/apache2/usr/lib/systemd/system/sysinit.target.
> wants/
> total 0
> lrwxrwxrwx. 1 root root 33 Jul 18 17:33 systemd-tmpfiles-setup.service ->
> ../systemd-tmpfiles-setup.service
> 
> the link src files created under sockets.target.wants and
> sysinit.target.wants point to upper dir
> /var/lib/libvirt/filesystems/apache2/usr/lib/systemd/system files which are
> not exist.

This test scenario is bogus.

You cannot check symlink validity from files in the /var/lib/libvirt/filesystems/$NAME/ directories. When the container is started, the content under this location is combined with the host filesystem using a variety of bind mounts, so the symlinks *are* valid.

You should check the symlinks only once the container is running

# virsh -c lxc:/// lxc-enter-namespace http1 /bin/sh
sh-4.2# cd /lib/systemd/system/sockets.target.wants/
sh-4.2# ls -al
total 24
drwxr-xr-x.  2 root root  4096 Oct  2 15:42 .
drwxr-xr-x. 27 root root 20480 Oct  2 13:35 ..
lrwxrwxrwx.  1 root root    14 Oct  2 15:42 dbus.socket -> ../dbus.socket
lrwxrwxrwx.  1 root root    25 Oct  2 15:42 systemd-initctl.socket -> ../systemd-initctl.socket
lrwxrwxrwx.  1 root root    26 Oct  2 15:42 systemd-journald.socket -> ../systemd-journald.socket
lrwxrwxrwx.  1 root root    27 Oct  2 15:42 systemd-shutdownd.socket -> ../systemd-shutdownd.socket
sh-4.2# cat dbus.socket 
[Unit]
Description=D-Bus System Message Bus Socket

[Socket]
ListenStream=/var/run/dbus/system_bus_socket

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