|
@@ -45,8 +45,6 @@ type Container struct {
|
|
AppArmorProfile string
|
|
AppArmorProfile string
|
|
HostnamePath string
|
|
HostnamePath string
|
|
HostsPath string
|
|
HostsPath string
|
|
- ShmPath string
|
|
|
|
- MqueuePath string
|
|
|
|
MountPoints map[string]*mountPoint
|
|
MountPoints map[string]*mountPoint
|
|
ResolvConfPath string
|
|
ResolvConfPath string
|
|
UpdateDns bool
|
|
UpdateDns bool
|
|
@@ -186,16 +184,6 @@ func populateCommand(c *Container, env []string) error {
|
|
}
|
|
}
|
|
|
|
|
|
ipc := &execdriver.Ipc{}
|
|
ipc := &execdriver.Ipc{}
|
|
- var err error
|
|
|
|
- c.ShmPath, err = c.shmPath()
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- c.MqueuePath, err = c.mqueuePath()
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
|
|
|
|
if c.hostConfig.IpcMode.IsContainer() {
|
|
if c.hostConfig.IpcMode.IsContainer() {
|
|
ic, err := c.getIpcContainer()
|
|
ic, err := c.getIpcContainer()
|
|
@@ -203,14 +191,8 @@ func populateCommand(c *Container, env []string) error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
ipc.ContainerID = ic.ID
|
|
ipc.ContainerID = ic.ID
|
|
- c.ShmPath = ic.ShmPath
|
|
|
|
- c.MqueuePath = ic.MqueuePath
|
|
|
|
} else {
|
|
} else {
|
|
ipc.HostIpc = c.hostConfig.IpcMode.IsHost()
|
|
ipc.HostIpc = c.hostConfig.IpcMode.IsHost()
|
|
- if ipc.HostIpc {
|
|
|
|
- c.ShmPath = "/dev/shm"
|
|
|
|
- c.MqueuePath = "/dev/mqueue"
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
pid := &execdriver.Pid{}
|
|
pid := &execdriver.Pid{}
|
|
@@ -1217,85 +1199,3 @@ func (container *Container) removeMountPoints() error {
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
-
|
|
|
|
-func (container *Container) shmPath() (string, error) {
|
|
|
|
- return container.GetRootResourcePath("shm")
|
|
|
|
-}
|
|
|
|
-func (container *Container) mqueuePath() (string, error) {
|
|
|
|
- return container.GetRootResourcePath("mqueue")
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (container *Container) setupIpcDirs() error {
|
|
|
|
- shmPath, err := container.shmPath()
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if err := os.MkdirAll(shmPath, 0700); err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if err := syscall.Mount("shm", shmPath, "tmpfs", uintptr(syscall.MS_NOEXEC|syscall.MS_NOSUID|syscall.MS_NODEV), label.FormatMountLabel("mode=1777,size=65536k", container.GetMountLabel())); err != nil {
|
|
|
|
- return fmt.Errorf("mounting shm tmpfs: %s", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mqueuePath, err := container.mqueuePath()
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if err := os.MkdirAll(mqueuePath, 0700); err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if err := syscall.Mount("mqueue", mqueuePath, "mqueue", uintptr(syscall.MS_NOEXEC|syscall.MS_NOSUID|syscall.MS_NODEV), ""); err != nil {
|
|
|
|
- return fmt.Errorf("mounting mqueue mqueue : %s", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (container *Container) unmountIpcMounts() error {
|
|
|
|
- if container.hostConfig.IpcMode.IsContainer() || container.hostConfig.IpcMode.IsHost() {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- shmPath, err := container.shmPath()
|
|
|
|
- if err != nil {
|
|
|
|
- return fmt.Errorf("shm path does not exist %v", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if err := syscall.Unmount(shmPath, syscall.MNT_DETACH); err != nil {
|
|
|
|
- return fmt.Errorf("failed to umount %s filesystem %v", shmPath, err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- mqueuePath, err := container.mqueuePath()
|
|
|
|
- if err != nil {
|
|
|
|
- return fmt.Errorf("mqueue path does not exist %v", err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if err := syscall.Unmount(mqueuePath, syscall.MNT_DETACH); err != nil {
|
|
|
|
- return fmt.Errorf("failed to umount %s filesystem %v", mqueuePath, err)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return nil
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func (container *Container) ipcMounts() []execdriver.Mount {
|
|
|
|
- var mounts []execdriver.Mount
|
|
|
|
- label.SetFileLabel(container.ShmPath, container.MountLabel)
|
|
|
|
- mounts = append(mounts, execdriver.Mount{
|
|
|
|
- Source: container.ShmPath,
|
|
|
|
- Destination: "/dev/shm",
|
|
|
|
- Writable: true,
|
|
|
|
- Private: true,
|
|
|
|
- })
|
|
|
|
- label.SetFileLabel(container.MqueuePath, container.MountLabel)
|
|
|
|
- mounts = append(mounts, execdriver.Mount{
|
|
|
|
- Source: container.MqueuePath,
|
|
|
|
- Destination: "/dev/mqueue",
|
|
|
|
- Writable: true,
|
|
|
|
- Private: true,
|
|
|
|
- })
|
|
|
|
- return mounts
|
|
|
|
-}
|
|
|