Refactor device handling code

We now have one place that keeps track of (most) devices that are allowed and created within the container.  That place is pkg/libcontainer/devices/devices.go

This fixes several inconsistencies between which devices were created in the lxc backend and the native backend.  It also fixes inconsistencies between wich devices were created and which were allowed.  For example, /dev/full was being created but it was not allowed within the cgroup.  It also declares the file modes and permissions of the default devices, rather than copying them from the host.  This is in line with docker's philosphy of not being host dependent.

Docker-DCO-1.1-Signed-off-by: Timothy Hobbs <timothyhobbs@seznam.cz> (github: https://github.com/timthelion)
This commit is contained in:
Timothy Hobbs 2014-02-17 15:14:30 -08:00 committed by Timothy
parent c8a8176936
commit 193f9894c0
11 changed files with 377 additions and 144 deletions

View file

@ -2,6 +2,7 @@ package libcontainer
import (
"github.com/dotcloud/docker/pkg/libcontainer/cgroups"
"github.com/dotcloud/docker/pkg/libcontainer/devices"
)
// Context is a generic key value pair that allows arbatrary data to be sent
@ -60,13 +61,8 @@ type Container struct {
// rootfs and mount namespace if specified
Mounts Mounts `json:"mounts,omitempty"`
// RequiredDeviceNodes are a list of device nodes that will be mknod into the container's rootfs at /dev
// If the host system does not support the device that the container requests an error is returned
RequiredDeviceNodes []string `json:"required_device_nodes,omitempty"`
// OptionalDeviceNodes are a list of device nodes that will be mknod into the container's rootfs at /dev
// If the host system does not support the device that the container requests the error is ignored
OptionalDeviceNodes []string `json:"optional_device_nodes,omitempty"`
// The device nodes that should be automatically created within the container upon container start. Note, make sure that the node is marked as allowed in the cgroup as well!
DeviceNodes []devices.Device `json:"device_nodes,omitempty"`
}
// Network defines configuration for a container's networking stack