[lxc-devel] [lxd/master] device/config: Moves types.* to device.config.*

tomponline on Github lxc-bot at linuxcontainers.org
Mon Jul 22 07:42:35 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 417 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190722/26bb3fe8/attachment-0001.bin>
-------------- next part --------------
From d13dec6c6d686af2280ef5c212b78d864a2b2ec5 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Tue, 16 Jul 2019 18:00:13 +0100
Subject: [PATCH] device/config: Moves types.* to device.config.*

Updates all references to types.* to device.config.*

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxc-to-lxd/main_migrate.go                    |   8 +-
 lxc-to-lxd/main_migrate_test.go               |  24 ++--
 lxd/api_project.go                            |   4 +-
 lxd/container.go                              |  12 +-
 lxd/container_lxc.go                          | 116 +++++++++---------
 lxd/container_test.go                         |  12 +-
 lxd/containers_post.go                        |   4 +-
 lxd/db/containers.go                          |   6 +-
 lxd/db/containers_test.go                     |   6 +-
 lxd/db/db_internal_test.go                    |  18 +--
 lxd/db/devices.go                             |  12 +-
 lxd/db/profiles.go                            |   8 +-
 lxd/{types => device/config}/devices.go       |   2 +-
 lxd/{types => device/config}/devices_sort.go  |   2 +-
 lxd/{types => device/config}/devices_test.go  |   2 +-
 lxd/{types => device/config}/devices_utils.go |   2 +-
 lxd/device/device_instance_id.go              |   4 +-
 lxd/seccomp.go                                |   6 +-
 lxd/storage_migration.go                      |   4 +-
 test/suites/static_analysis.sh                |   3 +-
 20 files changed, 127 insertions(+), 128 deletions(-)
 rename lxd/{types => device/config}/devices.go (99%)
 rename lxd/{types => device/config}/devices_sort.go (98%)
 rename lxd/{types => device/config}/devices_test.go (96%)
 rename lxd/{types => device/config}/devices_utils.go (97%)

diff --git a/lxc-to-lxd/main_migrate.go b/lxc-to-lxd/main_migrate.go
index 42fadbcdbd..d5c478b891 100644
--- a/lxc-to-lxd/main_migrate.go
+++ b/lxc-to-lxd/main_migrate.go
@@ -14,7 +14,7 @@ import (
 	lxd "github.com/lxc/lxd/client"
 	"github.com/lxc/lxd/lxc/config"
 	"github.com/lxc/lxd/lxc/utils"
-	"github.com/lxc/lxd/lxd/types"
+	deviceConfig "github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/i18n"
@@ -232,7 +232,7 @@ func convertContainer(d lxd.ContainerServer, container *lxc.Container, storage s
 		newConfig["security.privileged"] = "false"
 	}
 
-	newDevices := make(types.Devices, 0)
+	newDevices := make(deviceConfig.Devices, 0)
 
 	// Convert network configuration
 	err = convertNetworkConfig(container, newDevices)
@@ -449,7 +449,7 @@ func convertContainer(d lxd.ContainerServer, container *lxc.Container, storage s
 	return nil
 }
 
-func convertNetworkConfig(container *lxc.Container, devices types.Devices) error {
+func convertNetworkConfig(container *lxc.Container, devices deviceConfig.Devices) error {
 	networkDevice := func(network map[string]string) map[string]string {
 		if network == nil {
 			return nil
@@ -525,7 +525,7 @@ func convertNetworkConfig(container *lxc.Container, devices types.Devices) error
 	return nil
 }
 
-func convertStorageConfig(conf []string, devices types.Devices) error {
+func convertStorageConfig(conf []string, devices deviceConfig.Devices) error {
 	fmt.Println("Processing storage configuration")
 
 	i := 0
diff --git a/lxc-to-lxd/main_migrate_test.go b/lxc-to-lxd/main_migrate_test.go
index 3f779b2ca0..02ab931605 100644
--- a/lxc-to-lxd/main_migrate_test.go
+++ b/lxc-to-lxd/main_migrate_test.go
@@ -7,7 +7,7 @@ import (
 	"strings"
 	"testing"
 
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/stretchr/testify/require"
 	lxc "gopkg.in/lxc/go-lxc.v2"
 )
@@ -116,14 +116,14 @@ func TestConvertNetworkConfig(t *testing.T) {
 	tests := []struct {
 		name            string
 		config          []string
-		expectedDevices types.Devices
+		expectedDevices config.Devices
 		expectedError   string
 		shouldFail      bool
 	}{
 		{
 			"loopback only",
 			[]string{},
-			types.Devices{
+			config.Devices{
 				"eth0": map[string]string{
 					"type": "none",
 				},
@@ -144,7 +144,7 @@ func TestConvertNetworkConfig(t *testing.T) {
 				"lxc.net.1.hwaddr = 00:16:3e:a2:7d:54",
 				"lxc.net.1.name = eth2",
 			},
-			types.Devices{
+			config.Devices{
 				"net1": map[string]string{
 					"type":    "nic",
 					"nictype": "bridged",
@@ -179,7 +179,7 @@ func TestConvertNetworkConfig(t *testing.T) {
 				"lxc.net.1.link = lxcbr0",
 				"lxc.net.1.hwaddr = 00:16:3e:a2:7d:54",
 			},
-			types.Devices{
+			config.Devices{
 				"net1": map[string]string{
 					"type":    "nic",
 					"nictype": "bridged",
@@ -226,7 +226,7 @@ func TestConvertNetworkConfig(t *testing.T) {
 			require.NoError(t, err)
 		}
 
-		devices := make(types.Devices, 0)
+		devices := make(config.Devices, 0)
 		err = convertNetworkConfig(c, devices)
 		if tt.shouldFail {
 			require.EqualError(t, err, tt.expectedError)
@@ -244,7 +244,7 @@ func TestConvertStorageConfig(t *testing.T) {
 	tests := []struct {
 		name            string
 		config          []string
-		expectedDevices types.Devices
+		expectedDevices config.Devices
 		expectedError   string
 		shouldFail      bool
 	}{
@@ -253,7 +253,7 @@ func TestConvertStorageConfig(t *testing.T) {
 			[]string{
 				"lxc.mount.entry = /foo lib none ro,bind 0 0",
 			},
-			types.Devices{},
+			config.Devices{},
 			"Invalid path: /foo",
 			true,
 		},
@@ -262,7 +262,7 @@ func TestConvertStorageConfig(t *testing.T) {
 			[]string{
 				"lxc.mount.entry = proc /proc proc defaults 0 0",
 			},
-			types.Devices{},
+			config.Devices{},
 			"",
 			false,
 		},
@@ -271,7 +271,7 @@ func TestConvertStorageConfig(t *testing.T) {
 			[]string{
 				"lxc.mount.entry = shm /dev/shm tmpfs defaults 0 0",
 			},
-			types.Devices{},
+			config.Devices{},
 			"",
 			false,
 		},
@@ -285,7 +285,7 @@ func TestConvertStorageConfig(t *testing.T) {
 				"lxc.mount.entry = /sys/kernel/security /sys/kernel/security none ro,bind,optional 1 0",
 				"lxc.mount.entry = /mnt /tmp/mnt none ro,bind 0 0",
 			},
-			types.Devices{
+			config.Devices{
 				"mount0": map[string]string{
 					"type":     "disk",
 					"readonly": "true",
@@ -325,7 +325,7 @@ func TestConvertStorageConfig(t *testing.T) {
 
 	for i, tt := range tests {
 		log.Printf("Running test #%d: %s", i, tt.name)
-		devices := make(types.Devices, 0)
+		devices := make(config.Devices, 0)
 		err := convertStorageConfig(tt.config, devices)
 		if tt.shouldFail {
 			require.EqualError(t, err, tt.expectedError)
diff --git a/lxd/api_project.go b/lxd/api_project.go
index 0ca44d03d6..bcac34b722 100644
--- a/lxd/api_project.go
+++ b/lxd/api_project.go
@@ -12,7 +12,7 @@ import (
 	"github.com/pkg/errors"
 
 	"github.com/lxc/lxd/lxd/db"
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/lxd/util"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
@@ -168,7 +168,7 @@ func projectCreateDefaultProfile(tx *db.ClusterTx, project string) error {
 	profile.Name = "default"
 	profile.Description = fmt.Sprintf("Default LXD profile for project %s", project)
 	profile.Config = map[string]string{}
-	profile.Devices = types.Devices{}
+	profile.Devices = config.Devices{}
 
 	_, err := tx.ProfileCreate(profile)
 	if err != nil {
diff --git a/lxd/container.go b/lxd/container.go
index 71c176456b..a690fff70c 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -18,10 +18,10 @@ import (
 	"github.com/flosch/pongo2"
 	"github.com/lxc/lxd/lxd/cluster"
 	"github.com/lxc/lxd/lxd/db"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/lxd/state"
 	"github.com/lxc/lxd/lxd/sys"
 	"github.com/lxc/lxd/lxd/task"
-	"github.com/lxc/lxd/lxd/types"
 	"github.com/lxc/lxd/lxd/util"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
@@ -342,7 +342,7 @@ func containerValidConfig(sysOS *sys.OS, config map[string]string, profile bool,
 	return nil
 }
 
-func containerValidDevices(cluster *db.Cluster, devices types.Devices, profile bool, expanded bool) error {
+func containerValidDevices(cluster *db.Cluster, devices config.Devices, profile bool, expanded bool) error {
 	// Empty device list
 	if devices == nil {
 		return nil
@@ -714,9 +714,9 @@ type container interface {
 	CreationDate() time.Time
 	LastUsedDate() time.Time
 	ExpandedConfig() map[string]string
-	ExpandedDevices() types.Devices
+	ExpandedDevices() config.Devices
 	LocalConfig() map[string]string
-	LocalDevices() types.Devices
+	LocalDevices() config.Devices
 	Profiles() []string
 	InitPID() int
 	State() string
@@ -744,7 +744,7 @@ type container interface {
 	Storage() storage
 	TemplateApply(trigger string) error
 	DaemonState() *state.State
-	InsertSeccompUnixDevice(prefix string, m types.Device, pid int) error
+	InsertSeccompUnixDevice(prefix string, m config.Device, pid int) error
 
 	CurrentIdmap() (*idmap.IdmapSet, error)
 	DiskIdmap() (*idmap.IdmapSet, error)
@@ -1206,7 +1206,7 @@ func containerCreateInternal(s *state.State, args db.ContainerArgs) (container,
 	}
 
 	if args.Devices == nil {
-		args.Devices = types.Devices{}
+		args.Devices = config.Devices{}
 	}
 
 	if args.Architecture == 0 {
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 18169763ec..1b5ca2ccd0 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -32,13 +32,13 @@ import (
 	"github.com/lxc/lxd/lxd/db"
 	"github.com/lxc/lxd/lxd/db/query"
 	"github.com/lxc/lxd/lxd/device"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/lxd/dnsmasq"
 	"github.com/lxc/lxd/lxd/iptables"
 	"github.com/lxc/lxd/lxd/maas"
 	"github.com/lxc/lxd/lxd/project"
 	"github.com/lxc/lxd/lxd/state"
 	"github.com/lxc/lxd/lxd/template"
-	"github.com/lxc/lxd/lxd/types"
 	"github.com/lxc/lxd/lxd/util"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
@@ -602,10 +602,10 @@ type containerLXC struct {
 
 	// Config
 	expandedConfig  map[string]string
-	expandedDevices types.Devices
+	expandedDevices config.Devices
 	fromHook        bool
 	localConfig     map[string]string
-	localDevices    types.Devices
+	localDevices    config.Devices
 	profiles        []string
 
 	// Cache
@@ -2039,7 +2039,7 @@ func (c *containerLXC) expandDevices(profiles []api.Profile) error {
 
 // setupUnixDevice() creates the unix device and sets up the necessary low-level
 // liblxc configuration items.
-func (c *containerLXC) setupUnixDevice(prefix string, dev types.Device, major int, minor int, path string, createMustSucceed bool, defaultMode bool) error {
+func (c *containerLXC) setupUnixDevice(prefix string, dev config.Device, major int, minor int, path string, createMustSucceed bool, defaultMode bool) error {
 	if c.isCurrentlyPrivileged() && !c.state.OS.RunningInUserNS && c.state.OS.CGroupDevicesController {
 		err := lxcSetConfigItem(c.c, "lxc.cgroup.devices.allow", fmt.Sprintf("c %d:%d rwm", major, minor))
 		if err != nil {
@@ -2047,7 +2047,7 @@ func (c *containerLXC) setupUnixDevice(prefix string, dev types.Device, major in
 		}
 	}
 
-	temp := types.Device{}
+	temp := config.Device{}
 	err := shared.DeepCopy(&dev, &temp)
 	if err != nil {
 		return err
@@ -2309,7 +2309,7 @@ func (c *containerLXC) startCommon() (string, error) {
 
 	var usbs []usbDevice
 	var sriov []string
-	diskDevices := map[string]types.Device{}
+	diskDevices := map[string]config.Device{}
 
 	// Create the devices
 	for _, k := range c.expandedDevices.DeviceNames() {
@@ -2552,7 +2552,7 @@ func (c *containerLXC) startCommon() (string, error) {
 		}
 	}
 
-	err = c.addDiskDevices(diskDevices, func(name string, d types.Device) error {
+	err = c.addDiskDevices(diskDevices, func(name string, d config.Device) error {
 		_, err := c.createDiskDevice(name, d)
 		return err
 	})
@@ -2670,7 +2670,7 @@ func (c *containerLXC) snapshotPhysicalNic(deviceName string, hostName string, v
 // setupPhysicalParent creates a VLAN device on parent if needed and tracks original properties of
 // the physical device if not just created so they can be restored when the device is detached.
 // Returns the parent device name detected.
-func (c *containerLXC) setupPhysicalParent(deviceName string, m types.Device) (string, error) {
+func (c *containerLXC) setupPhysicalParent(deviceName string, m config.Device) (string, error) {
 	if m["parent"] == "" {
 		return "", errors.New("No parent property on device")
 	}
@@ -2776,7 +2776,7 @@ func (c *containerLXC) restorePhysicalNic(deviceName string, hostName string) er
 
 // restorePhysicalParent restores parent device settings when removed from a container using the
 // volatile data that was stored when the device was first added with setupPhysicalParent().
-func (c *containerLXC) restorePhysicalParent(deviceName string, m types.Device) {
+func (c *containerLXC) restorePhysicalParent(deviceName string, m config.Device) {
 	// Clear volatile data when function finishes.
 	defer func() {
 		// Volatile keys used for parent restore.
@@ -2804,7 +2804,7 @@ func (c *containerLXC) restorePhysicalParent(deviceName string, m types.Device)
 
 // setupSriovParent configures a SR-IOV virtual function (VF) device on parent and tracks original
 // properties of the physical device for restoration on detach.
-func (c *containerLXC) setupSriovParent(deviceName string, m types.Device) error {
+func (c *containerLXC) setupSriovParent(deviceName string, m config.Device) error {
 	// Check for required fields in device config.
 	if m["parent"] == "" {
 		return fmt.Errorf("Missing parent for 'sriov' nic '%s'", deviceName)
@@ -2940,7 +2940,7 @@ func (c *containerLXC) setupSriovParent(deviceName string, m types.Device) error
 
 // restoreSriovParent restores SR-IOV parent device settings when removed from a container using the
 // volatile data that was stored when the device was first added with setupSriovParent().
-func (c *containerLXC) restoreSriovParent(deviceName string, m types.Device) {
+func (c *containerLXC) restoreSriovParent(deviceName string, m config.Device) {
 	// Volatile keys used for parent restore.
 	hostNameKey := "volatile." + deviceName + ".host_name"
 	vfIDKey := "volatile." + deviceName + ".last_state.vf.id"
@@ -3628,7 +3628,7 @@ func (c *containerLXC) cleanupHostVethDevices() {
 	}
 }
 
-func (c *containerLXC) cleanupHostVethDevice(deviceName string, m types.Device) {
+func (c *containerLXC) cleanupHostVethDevice(deviceName string, m config.Device) {
 	// If not configured, check if volatile data contains the most recently added host_name.
 	if m["host_name"] == "" {
 		m["host_name"] = c.getVolatileHostName(deviceName)
@@ -3712,13 +3712,13 @@ func (c *containerLXC) OnNetworkUp(deviceName string, hostName string) error {
 		}
 	}
 
-	_, err := c.setupHostVethDevice(deviceName, device, types.Device{})
+	_, err := c.setupHostVethDevice(deviceName, device, config.Device{})
 
 	return err
 }
 
 // setupHostVethDevice configures a nic device's host side veth settings.
-func (c *containerLXC) setupHostVethDevice(deviceName string, device types.Device, oldDevice types.Device) ([]string, error) {
+func (c *containerLXC) setupHostVethDevice(deviceName string, device config.Device, oldDevice config.Device) ([]string, error) {
 	bounceInterfaces := []string{} // A place to store interfaces we would like to be bounced.
 
 	// If not configured, check if volatile data contains the most recently added host_name.
@@ -4783,7 +4783,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 	}
 
 	if args.Devices == nil {
-		args.Devices = types.Devices{}
+		args.Devices = config.Devices{}
 	}
 
 	if args.Profiles == nil {
@@ -4866,7 +4866,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 		return err
 	}
 
-	oldExpandedDevices := types.Devices{}
+	oldExpandedDevices := config.Devices{}
 	err = shared.DeepCopy(&c.expandedDevices, &oldExpandedDevices)
 	if err != nil {
 		return err
@@ -4878,7 +4878,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 		return err
 	}
 
-	oldLocalDevices := types.Devices{}
+	oldLocalDevices := config.Devices{}
 	err = shared.DeepCopy(&c.localDevices, &oldLocalDevices)
 	if err != nil {
 		return err
@@ -5514,7 +5514,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 			}
 		}
 
-		diskDevices := map[string]types.Device{}
+		diskDevices := map[string]config.Device{}
 		for k, m := range addDevices {
 			if shared.StringInSlice(m["type"], []string{"unix-char", "unix-block"}) {
 				err = c.insertUnixDevice(fmt.Sprintf("unix.%s", k), m, true)
@@ -5804,7 +5804,7 @@ func (c *containerLXC) Update(args db.ContainerArgs, userRequested bool) error {
 
 	// Update network leases if a bridged device has changed.
 	needsUpdate := false
-	deviceLists := []map[string]types.Device{removeDevices, addDevices, updateDevices}
+	deviceLists := []map[string]config.Device{removeDevices, addDevices, updateDevices}
 	for _, deviceList := range deviceLists {
 		for _, m := range deviceList {
 			if m["type"] == "nic" && m["nictype"] == "bridged" {
@@ -7388,7 +7388,7 @@ func (c *containerLXC) deviceExistsInDevicesFolder(prefix string, path string) b
 }
 
 // Unix devices handling
-func (c *containerLXC) createUnixDevice(prefix string, m types.Device, defaultMode bool) ([]string, error) {
+func (c *containerLXC) createUnixDevice(prefix string, m config.Device, defaultMode bool) ([]string, error) {
 	var err error
 	var major, minor int
 
@@ -7530,7 +7530,7 @@ func (c *containerLXC) createUnixDevice(prefix string, m types.Device, defaultMo
 	return []string{devPath, relativeDestPath}, nil
 }
 
-func (c *containerLXC) insertUnixDevice(prefix string, m types.Device, defaultMode bool) error {
+func (c *containerLXC) insertUnixDevice(prefix string, m config.Device, defaultMode bool) error {
 	// Check that the container is running
 	if !c.IsRunning() {
 		return fmt.Errorf("Can't insert device into stopped container")
@@ -7592,7 +7592,7 @@ func (c *containerLXC) insertUnixDevice(prefix string, m types.Device, defaultMo
 	return nil
 }
 
-func (c *containerLXC) InsertSeccompUnixDevice(prefix string, m types.Device, pid int) error {
+func (c *containerLXC) InsertSeccompUnixDevice(prefix string, m config.Device, pid int) error {
 	if pid < 0 {
 		return fmt.Errorf("Invalid request PID specified")
 	}
@@ -7641,8 +7641,8 @@ func (c *containerLXC) InsertSeccompUnixDevice(prefix string, m types.Device, pi
 	return c.insertMountLXD(devPath, tgtPath, "none", unix.MS_BIND, pid)
 }
 
-func (c *containerLXC) insertUnixDeviceNum(name string, m types.Device, major int, minor int, path string, defaultMode bool) error {
-	temp := types.Device{}
+func (c *containerLXC) insertUnixDeviceNum(name string, m config.Device, major int, minor int, path string, defaultMode bool) error {
+	temp := config.Device{}
 	if err := shared.DeepCopy(&m, &temp); err != nil {
 		return err
 	}
@@ -7654,7 +7654,7 @@ func (c *containerLXC) insertUnixDeviceNum(name string, m types.Device, major in
 	return c.insertUnixDevice(name, temp, defaultMode)
 }
 
-func (c *containerLXC) removeUnixDevice(prefix string, m types.Device, eject bool) error {
+func (c *containerLXC) removeUnixDevice(prefix string, m config.Device, eject bool) error {
 	// Check that the container is running
 	pid := c.InitPID()
 	if pid == -1 {
@@ -7736,13 +7736,13 @@ func (c *containerLXC) removeUnixDevice(prefix string, m types.Device, eject boo
 	return nil
 }
 
-func (c *containerLXC) removeUnixDeviceNum(prefix string, m types.Device, major int, minor int, path string) error {
+func (c *containerLXC) removeUnixDeviceNum(prefix string, m config.Device, major int, minor int, path string) error {
 	pid := c.InitPID()
 	if pid == -1 {
 		return fmt.Errorf("Can't remove device from stopped container")
 	}
 
-	temp := types.Device{}
+	temp := config.Device{}
 	if err := shared.DeepCopy(&m, &temp); err != nil {
 		return err
 	}
@@ -7768,7 +7768,7 @@ func (c *containerLXC) addInfinibandDevicesPerPort(deviceName string, ifDev *IBF
 		devPrefix := fmt.Sprintf("infiniband.unix.%s", deviceName)
 
 		// Unix device
-		dummyDevice := types.Device{
+		dummyDevice := config.Device{
 			"source": destPath,
 		}
 
@@ -7850,7 +7850,7 @@ func (c *containerLXC) addInfinibandDevicesPerFun(deviceName string, ifDev *IBF,
 		uniqueDevName := fmt.Sprintf("%s.%s", uniqueDevPrefix, strings.Replace(relativeDestPath, "/", "-", -1))
 		hostDevPath := filepath.Join(c.DevicesPath(), uniqueDevName)
 
-		dummyDevice := types.Device{
+		dummyDevice := config.Device{
 			"source": destPath,
 		}
 
@@ -7907,7 +7907,7 @@ func (c *containerLXC) addInfinibandDevices(deviceName string, ifDev *IBF, injec
 	return c.addInfinibandDevicesPerFun(deviceName, ifDev, inject)
 }
 
-func (c *containerLXC) removeInfinibandDevices(deviceName string, device types.Device) error {
+func (c *containerLXC) removeInfinibandDevices(deviceName string, device config.Device) error {
 	// load all devices
 	dents, err := ioutil.ReadDir(c.DevicesPath())
 	if err != nil {
@@ -7959,7 +7959,7 @@ func (c *containerLXC) removeInfinibandDevices(deviceName string, device types.D
 		rPath = strings.Replace(rPath, "-", "/", -1)
 		absPath := fmt.Sprintf("/%s", rPath)
 
-		dummyDevice := types.Device{
+		dummyDevice := config.Device{
 			"path": absPath,
 		}
 
@@ -8018,7 +8018,7 @@ func (c *containerLXC) removeUnixDevices() error {
 	return nil
 }
 
-func (c *containerLXC) insertProxyDevice(devName string, m types.Device) error {
+func (c *containerLXC) insertProxyDevice(devName string, m config.Device) error {
 	if !c.IsRunning() {
 		return fmt.Errorf("Can't add proxy device to stopped container")
 	}
@@ -8060,7 +8060,7 @@ func (c *containerLXC) insertProxyDevice(devName string, m types.Device) error {
 	return nil
 }
 
-func (c *containerLXC) doNat(proxy string, device types.Device) error {
+func (c *containerLXC) doNat(proxy string, device config.Device) error {
 	listenAddr, err := proxyParseAddr(device["listen"])
 	if err != nil {
 		return err
@@ -8234,7 +8234,7 @@ func (c *containerLXC) removeProxyDevices() error {
 	return nil
 }
 
-func (c *containerLXC) updateProxyDevice(devName string, m types.Device) error {
+func (c *containerLXC) updateProxyDevice(devName string, m config.Device) error {
 	if !c.IsRunning() {
 		return fmt.Errorf("Can't update proxy device in stopped container")
 	}
@@ -8264,7 +8264,7 @@ func (c *containerLXC) restartProxyDevices() error {
 }
 
 // Network device handling
-func (c *containerLXC) createNetworkDevice(name string, m types.Device) (string, error) {
+func (c *containerLXC) createNetworkDevice(name string, m config.Device) (string, error) {
 	var dev, n1 string
 
 	if shared.StringInSlice(m["nictype"], []string{"bridged", "p2p", "macvlan"}) {
@@ -8364,7 +8364,7 @@ func (c *containerLXC) createNetworkDevice(name string, m types.Device) (string,
 	return dev, nil
 }
 
-func (c *containerLXC) fillSriovNetworkDevice(name string, m types.Device, reserved []string) (types.Device, error) {
+func (c *containerLXC) fillSriovNetworkDevice(name string, m config.Device, reserved []string) (config.Device, error) {
 	if m["nictype"] != "sriov" {
 		return m, nil
 	}
@@ -8373,7 +8373,7 @@ func (c *containerLXC) fillSriovNetworkDevice(name string, m types.Device, reser
 		return nil, fmt.Errorf("Missing parent for 'sriov' nic '%s'", name)
 	}
 
-	newDevice := types.Device{}
+	newDevice := config.Device{}
 	err := shared.DeepCopy(&m, &newDevice)
 	if err != nil {
 		return nil, err
@@ -8505,8 +8505,8 @@ func (c *containerLXC) fillSriovNetworkDevice(name string, m types.Device, reser
 	return newDevice, nil
 }
 
-func (c *containerLXC) fillNetworkDevice(name string, m types.Device) (types.Device, error) {
-	newDevice := types.Device{}
+func (c *containerLXC) fillNetworkDevice(name string, m config.Device) (config.Device, error) {
+	newDevice := config.Device{}
 	err := shared.DeepCopy(&m, &newDevice)
 	if err != nil {
 		return nil, err
@@ -8685,7 +8685,7 @@ func (c *containerLXC) getVolatileHwaddr(deviceName string) string {
 }
 
 // generateNetworkFilterEbtablesRules returns a customised set of ebtables filter rules based on the device.
-func (c *containerLXC) generateNetworkFilterEbtablesRules(m types.Device, IPv4 net.IP, IPv6 net.IP) [][]string {
+func (c *containerLXC) generateNetworkFilterEbtablesRules(m config.Device, IPv4 net.IP, IPv6 net.IP) [][]string {
 	// MAC source filtering rules. Blocks any packet coming from container with an incorrect Ethernet source MAC.
 	// This is required for IP filtering too.
 	rules := [][]string{
@@ -8724,7 +8724,7 @@ func (c *containerLXC) generateNetworkFilterEbtablesRules(m types.Device, IPv4 n
 }
 
 // generateNetworkFilterIptablesRules returns a customised set of iptables filter rules based on the device.
-func (c *containerLXC) generateNetworkFilterIptablesRules(m types.Device, IPv6 net.IP) (rules [][]string, err error) {
+func (c *containerLXC) generateNetworkFilterIptablesRules(m config.Device, IPv6 net.IP) (rules [][]string, err error) {
 	mac, err := net.ParseMAC(m["hwaddr"])
 	if err != nil {
 		return
@@ -8758,7 +8758,7 @@ func (c *containerLXC) generateNetworkFilterIptablesRules(m types.Device, IPv6 n
 
 // setNetworkFilters sets up any network level filters defined for the container.
 // These are controlled by the security.mac_filtering, security.ipv4_Filtering and security.ipv6_filtering config keys.
-func (c *containerLXC) setNetworkFilters(deviceName string, m types.Device) (err error) {
+func (c *containerLXC) setNetworkFilters(deviceName string, m config.Device) (err error) {
 	if m["hwaddr"] == "" {
 		return fmt.Errorf("Failed to set network filters: require hwaddr defined")
 	}
@@ -8813,7 +8813,7 @@ func (c *containerLXC) setNetworkFilters(deviceName string, m types.Device) (err
 }
 
 // allocateNetworkFilterIPs retrieves previously allocated IPs, or allocate new ones if needed.
-func (c *containerLXC) allocateNetworkFilterIPs(deviceName string, m types.Device) (net.IP, net.IP, error) {
+func (c *containerLXC) allocateNetworkFilterIPs(deviceName string, m config.Device) (net.IP, net.IP, error) {
 	var IPv4, IPv6 net.IP
 
 	// Check if there is a valid static IPv4 address defined.
@@ -8936,7 +8936,7 @@ func (c *containerLXC) allocateNetworkFilterIPs(deviceName string, m types.Devic
 }
 
 // removeNetworkFilters removes any network level filters defined for the container.
-func (c *containerLXC) removeNetworkFilters(deviceName string, m types.Device) {
+func (c *containerLXC) removeNetworkFilters(deviceName string, m config.Device) {
 	if m["hwaddr"] == "" {
 		logger.Error("Failed to remove network filters", log.Ctx{"container": c.Name(), "device": deviceName, "err": "hwaddr not defined"})
 		return
@@ -9022,7 +9022,7 @@ func (c *containerLXC) matchEbtablesRule(activeRule []string, matchRule []string
 	return true
 }
 
-func (c *containerLXC) insertNetworkDevice(name string, m types.Device) (types.Device, error) {
+func (c *containerLXC) insertNetworkDevice(name string, m config.Device) (config.Device, error) {
 	// Load the go-lxc struct
 	err := c.initLXC(false)
 	if err != nil {
@@ -9075,7 +9075,7 @@ func (c *containerLXC) insertNetworkDevice(name string, m types.Device) (types.D
 	}
 
 	if m["type"] == "nic" && shared.StringInSlice(m["nictype"], []string{"bridged", "p2p"}) {
-		_, err = c.setupHostVethDevice(name, m, types.Device{})
+		_, err = c.setupHostVethDevice(name, m, config.Device{})
 		if err != nil {
 			return nil, err
 		}
@@ -9094,7 +9094,7 @@ func (c *containerLXC) checkIPVLANSupport() error {
 	return errors.New("LXC is missing one or more API extensions: network_ipvlan, network_l2proxy, network_gateway_device_route")
 }
 
-func (c *containerLXC) updateNetworkDevice(name string, m types.Device, oldDevice types.Device) ([]string, error) {
+func (c *containerLXC) updateNetworkDevice(name string, m config.Device, oldDevice config.Device) ([]string, error) {
 	if shared.StringInSlice(m["nictype"], []string{"bridged", "p2p"}) {
 		// Populate network device with container nic names.
 		m, err := c.fillNetworkDevice(name, m)
@@ -9113,7 +9113,7 @@ func (c *containerLXC) updateNetworkDevice(name string, m types.Device, oldDevic
 	return []string{}, nil
 }
 
-func (c *containerLXC) removeNetworkDevice(name string, m types.Device) error {
+func (c *containerLXC) removeNetworkDevice(name string, m config.Device) error {
 	// Fill in some fields from volatile
 	m, err := c.fillNetworkDevice(name, m)
 	if err != nil {
@@ -9178,7 +9178,7 @@ func (c *containerLXC) removeNetworkDevice(name string, m types.Device) error {
 }
 
 // Disk device handling
-func (c *containerLXC) createDiskDevice(name string, m types.Device) (string, error) {
+func (c *containerLXC) createDiskDevice(name string, m config.Device) (string, error) {
 	// source paths
 	relativeDestPath := strings.TrimPrefix(m["path"], "/")
 	devName := fmt.Sprintf("disk.%s.%s", strings.Replace(name, "/", "-", -1), strings.Replace(relativeDestPath, "/", "-", -1))
@@ -9305,7 +9305,7 @@ func (c *containerLXC) createDiskDevice(name string, m types.Device) (string, er
 	return devPath, nil
 }
 
-func (c *containerLXC) insertDiskDevice(name string, m types.Device) error {
+func (c *containerLXC) insertDiskDevice(name string, m config.Device) error {
 	// Check that the container is running
 	if !c.IsRunning() {
 		return fmt.Errorf("Can't insert device into stopped container")
@@ -9338,7 +9338,7 @@ func (c *containerLXC) insertDiskDevice(name string, m types.Device) error {
 	return nil
 }
 
-type byPath []types.Device
+type byPath []config.Device
 
 func (a byPath) Len() int {
 	return len(a)
@@ -9352,7 +9352,7 @@ func (a byPath) Less(i, j int) bool {
 	return a[i]["path"] < a[j]["path"]
 }
 
-func (c *containerLXC) addDiskDevices(devices map[string]types.Device, handler func(string, types.Device) error) error {
+func (c *containerLXC) addDiskDevices(devices map[string]config.Device, handler func(string, config.Device) error) error {
 	ordered := byPath{}
 
 	for _, d := range devices {
@@ -9379,7 +9379,7 @@ func (c *containerLXC) addDiskDevices(devices map[string]types.Device, handler f
 	return nil
 }
 
-func (c *containerLXC) removeDiskDevice(name string, m types.Device) error {
+func (c *containerLXC) removeDiskDevice(name string, m config.Device) error {
 	// Check that the container is running
 	pid := c.InitPID()
 	if pid == -1 {
@@ -9661,7 +9661,7 @@ func (c *containerLXC) setNetworkPriority() error {
 }
 
 // setNetworkRoutes applies any static routes configured from the host to the container nic.
-func (c *containerLXC) setNetworkRoutes(m types.Device) error {
+func (c *containerLXC) setNetworkRoutes(m config.Device) error {
 	if !shared.PathExists(fmt.Sprintf("/sys/class/net/%s", m["host_name"])) {
 		return fmt.Errorf("Unknown or missing host side veth: %s", m["host_name"])
 	}
@@ -9699,7 +9699,7 @@ func (c *containerLXC) setNetworkRoutes(m types.Device) error {
 
 // removeNetworkRoutes removes any routes created for this device on the host that were first added
 // with setNetworkRoutes(). Expects to be passed the device config from the oldExpandedDevices.
-func (c *containerLXC) removeNetworkRoutes(deviceName string, m types.Device) {
+func (c *containerLXC) removeNetworkRoutes(deviceName string, m config.Device) {
 	// Decide whether the route should point to the veth parent or the bridge parent
 	routeDev := m["host_name"]
 	if m["nictype"] == "bridged" {
@@ -9740,7 +9740,7 @@ func (c *containerLXC) removeNetworkRoutes(deviceName string, m types.Device) {
 	}
 }
 
-func (c *containerLXC) setNetworkLimits(m types.Device) error {
+func (c *containerLXC) setNetworkLimits(m config.Device) error {
 	var err error
 	// We can only do limits on some network type
 	if m["nictype"] != "bridged" && m["nictype"] != "p2p" {
@@ -9870,7 +9870,7 @@ func (c *containerLXC) ExpandedConfig() map[string]string {
 	return c.expandedConfig
 }
 
-func (c *containerLXC) ExpandedDevices() types.Devices {
+func (c *containerLXC) ExpandedDevices() config.Devices {
 	return c.expandedDevices
 }
 
@@ -9892,7 +9892,7 @@ func (c *containerLXC) LocalConfig() map[string]string {
 	return c.localConfig
 }
 
-func (c *containerLXC) LocalDevices() types.Devices {
+func (c *containerLXC) LocalDevices() config.Devices {
 	return c.localDevices
 }
 
diff --git a/lxd/container_test.go b/lxd/container_test.go
index a7a5b199c0..4bbebde328 100644
--- a/lxd/container_test.go
+++ b/lxd/container_test.go
@@ -5,7 +5,7 @@ import (
 	"testing"
 
 	"github.com/lxc/lxd/lxd/db"
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/idmap"
@@ -46,7 +46,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesMulti() {
 			Name:        "unprivileged",
 			Description: "unprivileged",
 			Config:      map[string]string{"security.privileged": "true"},
-			Devices:     types.Devices{},
+			Devices:     config.Devices{},
 			Project:     "default",
 		}
 		_, err := tx.ProfileCreate(profile)
@@ -87,8 +87,8 @@ func (suite *containerTestSuite) TestContainer_ProfilesOverwriteDefaultNic() {
 		Ctype:     db.CTypeRegular,
 		Ephemeral: false,
 		Config:    map[string]string{"security.privileged": "true"},
-		Devices: types.Devices{
-			"eth0": types.Device{
+		Devices: config.Devices{
+			"eth0": config.Device{
 				"type":    "nic",
 				"nictype": "bridged",
 				"parent":  "unknownbr0"}},
@@ -117,8 +117,8 @@ func (suite *containerTestSuite) TestContainer_LoadFromDB() {
 		Ctype:     db.CTypeRegular,
 		Ephemeral: false,
 		Config:    map[string]string{"security.privileged": "true"},
-		Devices: types.Devices{
-			"eth0": types.Device{
+		Devices: config.Devices{
+			"eth0": config.Device{
 				"type":    "nic",
 				"nictype": "bridged",
 				"parent":  "unknownbr0"}},
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index ef9e2a732e..3f0069916a 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -19,8 +19,8 @@ import (
 
 	"github.com/lxc/lxd/lxd/cluster"
 	"github.com/lxc/lxd/lxd/db"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/lxd/migration"
-	"github.com/lxc/lxd/lxd/types"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/ioprogress"
@@ -760,7 +760,7 @@ func containersPost(d *Daemon, r *http.Request) Response {
 	}
 
 	if req.Devices == nil {
-		req.Devices = types.Devices{}
+		req.Devices = config.Devices{}
 	}
 
 	if req.Config == nil {
diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 68dbaa8c38..3d11bd4537 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -8,7 +8,7 @@ import (
 	"time"
 
 	"github.com/lxc/lxd/lxd/db/query"
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/logger"
@@ -113,7 +113,7 @@ func ContainerToArgs(container *Container) ContainerArgs {
 	}
 
 	if args.Devices == nil {
-		args.Devices = types.Devices{}
+		args.Devices = config.Devices{}
 	}
 
 	return args
@@ -135,7 +135,7 @@ type ContainerArgs struct {
 	Architecture int
 	Config       map[string]string
 	Description  string
-	Devices      types.Devices
+	Devices      config.Devices
 	Ephemeral    bool
 	LastUsedDate time.Time
 	Name         string
diff --git a/lxd/db/containers_test.go b/lxd/db/containers_test.go
index cd09227d2c..9cd62f0f52 100644
--- a/lxd/db/containers_test.go
+++ b/lxd/db/containers_test.go
@@ -6,7 +6,7 @@ import (
 	"time"
 
 	"github.com/lxc/lxd/lxd/db"
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/stretchr/testify/assert"
 	"github.com/stretchr/testify/require"
@@ -324,8 +324,8 @@ func TestContainerPool(t *testing.T) {
 			Project: "default",
 			Name:    "c1",
 			Node:    "none",
-			Devices: types.Devices{
-				"root": types.Device{
+			Devices: config.Devices{
+				"root": config.Device{
 					"path": "/",
 					"pool": "default",
 					"type": "disk",
diff --git a/lxd/db/db_internal_test.go b/lxd/db/db_internal_test.go
index b0372dd41d..3a672851d7 100644
--- a/lxd/db/db_internal_test.go
+++ b/lxd/db/db_internal_test.go
@@ -8,7 +8,7 @@ import (
 
 	"github.com/stretchr/testify/suite"
 
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/logger"
 	"github.com/lxc/lxd/shared/logging"
@@ -331,14 +331,14 @@ func (s *dbTestSuite) Test_ContainerProfiles() {
 
 func (s *dbTestSuite) Test_dbDevices_profiles() {
 	var err error
-	var result types.Devices
-	var subresult types.Device
-	var expected types.Device
+	var result config.Devices
+	var subresult config.Device
+	var expected config.Device
 
 	result, err = s.db.Devices("default", "theprofile", true)
 	s.Nil(err)
 
-	expected = types.Device{"type": "nic", "devicekey": "devicevalue"}
+	expected = config.Device{"type": "nic", "devicekey": "devicevalue"}
 	subresult = result["devicename"]
 
 	for key, value := range expected {
@@ -349,14 +349,14 @@ func (s *dbTestSuite) Test_dbDevices_profiles() {
 
 func (s *dbTestSuite) Test_dbDevices_containers() {
 	var err error
-	var result types.Devices
-	var subresult types.Device
-	var expected types.Device
+	var result config.Devices
+	var subresult config.Device
+	var expected config.Device
 
 	result, err = s.db.Devices("default", "thename", false)
 	s.Nil(err)
 
-	expected = types.Device{"type": "nic", "configkey": "configvalue"}
+	expected = config.Device{"type": "nic", "configkey": "configvalue"}
 	subresult = result["somename"]
 
 	for key, value := range expected {
diff --git a/lxd/db/devices.go b/lxd/db/devices.go
index cfadc8ff5e..ac51b3f73d 100644
--- a/lxd/db/devices.go
+++ b/lxd/db/devices.go
@@ -4,7 +4,7 @@ import (
 	"database/sql"
 	"fmt"
 
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 )
 
 func dbDeviceTypeToString(t int) (string, error) {
@@ -58,7 +58,7 @@ func dbDeviceTypeToInt(t string) (int, error) {
 }
 
 // DevicesAdd adds a new device.
-func DevicesAdd(tx *sql.Tx, w string, cID int64, devices types.Devices) error {
+func DevicesAdd(tx *sql.Tx, w string, cID int64, devices config.Devices) error {
 	// Prepare the devices entry SQL
 	str1 := fmt.Sprintf("INSERT INTO %ss_devices (%s_id, name, type) VALUES (?, ?, ?)", w, w)
 	stmt1, err := tx.Prepare(str1)
@@ -109,10 +109,10 @@ func DevicesAdd(tx *sql.Tx, w string, cID int64, devices types.Devices) error {
 	return nil
 }
 
-func dbDeviceConfig(db *sql.DB, id int, isprofile bool) (types.Device, error) {
+func dbDeviceConfig(db *sql.DB, id int, isprofile bool) (config.Device, error) {
 	var query string
 	var key, value string
-	newdev := types.Device{} // That's a map[string]string
+	newdev := config.Device{} // That's a map[string]string
 	inargs := []interface{}{id}
 	outfmt := []interface{}{key, value}
 
@@ -138,7 +138,7 @@ func dbDeviceConfig(db *sql.DB, id int, isprofile bool) (types.Device, error) {
 }
 
 // Devices returns the devices matching the given filters.
-func (c *Cluster) Devices(project, qName string, isprofile bool) (types.Devices, error) {
+func (c *Cluster) Devices(project, qName string, isprofile bool) (config.Devices, error) {
 	err := c.Transaction(func(tx *ClusterTx) error {
 		enabled, err := tx.ProjectHasProfiles(project)
 		if err != nil {
@@ -176,7 +176,7 @@ func (c *Cluster) Devices(project, qName string, isprofile bool) (types.Devices,
 		return nil, err
 	}
 
-	devices := types.Devices{}
+	devices := config.Devices{}
 	for _, r := range results {
 		id = r[0].(int)
 		name = r[1].(string)
diff --git a/lxd/db/profiles.go b/lxd/db/profiles.go
index d8a27dada6..c59de7d3cb 100644
--- a/lxd/db/profiles.go
+++ b/lxd/db/profiles.go
@@ -4,7 +4,7 @@ import (
 	"database/sql"
 	"fmt"
 
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/pkg/errors"
 )
@@ -378,11 +378,11 @@ func ProfilesExpandConfig(config map[string]string, profiles []api.Profile) map[
 
 // ProfilesExpandDevices expands the given container devices with the devices
 // defined in the given profiles.
-func ProfilesExpandDevices(devices types.Devices, profiles []api.Profile) types.Devices {
-	expandedDevices := types.Devices{}
+func ProfilesExpandDevices(devices config.Devices, profiles []api.Profile) config.Devices {
+	expandedDevices := config.Devices{}
 
 	// Apply all the profiles
-	profileDevices := make([]types.Devices, len(profiles))
+	profileDevices := make([]config.Devices, len(profiles))
 	for i, profile := range profiles {
 		profileDevices[i] = profile.Devices
 	}
diff --git a/lxd/types/devices.go b/lxd/device/config/devices.go
similarity index 99%
rename from lxd/types/devices.go
rename to lxd/device/config/devices.go
index 22cb753426..b4842cc813 100644
--- a/lxd/types/devices.go
+++ b/lxd/device/config/devices.go
@@ -1,4 +1,4 @@
-package types
+package config
 
 import (
 	"sort"
diff --git a/lxd/types/devices_sort.go b/lxd/device/config/devices_sort.go
similarity index 98%
rename from lxd/types/devices_sort.go
rename to lxd/device/config/devices_sort.go
index 359431ee42..d53314d257 100644
--- a/lxd/types/devices_sort.go
+++ b/lxd/device/config/devices_sort.go
@@ -1,4 +1,4 @@
-package types
+package config
 
 type namedDevice struct {
 	name   string
diff --git a/lxd/types/devices_test.go b/lxd/device/config/devices_test.go
similarity index 96%
rename from lxd/types/devices_test.go
rename to lxd/device/config/devices_test.go
index 1c5d612715..7cee0dec90 100644
--- a/lxd/types/devices_test.go
+++ b/lxd/device/config/devices_test.go
@@ -1,4 +1,4 @@
-package types
+package config
 
 import (
 	"reflect"
diff --git a/lxd/types/devices_utils.go b/lxd/device/config/devices_utils.go
similarity index 97%
rename from lxd/types/devices_utils.go
rename to lxd/device/config/devices_utils.go
index 4ded0cceed..4b1c26b420 100644
--- a/lxd/types/devices_utils.go
+++ b/lxd/device/config/devices_utils.go
@@ -1,4 +1,4 @@
-package types
+package config
 
 func deviceEquals(old Device, d Device) bool {
 	// Check for any difference and addition/removal of properties
diff --git a/lxd/device/device_instance_id.go b/lxd/device/device_instance_id.go
index 10bcaa0815..c65c4eb774 100644
--- a/lxd/device/device_instance_id.go
+++ b/lxd/device/device_instance_id.go
@@ -1,7 +1,7 @@
 package device
 
-// instanceIdentifier is an interface that allows us to identify an Instance and its properties.
-type instanceIdentifier interface {
+// InstanceIdentifier is an interface that allows us to identify an Instance and its properties.
+type InstanceIdentifier interface {
 	Name() string
 	Type() string
 	Project() string
diff --git a/lxd/seccomp.go b/lxd/seccomp.go
index fb904a0368..2217d98aaa 100644
--- a/lxd/seccomp.go
+++ b/lxd/seccomp.go
@@ -18,7 +18,7 @@ import (
 
 	"golang.org/x/sys/unix"
 
-	"github.com/lxc/lxd/lxd/types"
+	"github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/lxd/util"
 	"github.com/lxc/lxd/shared"
 	log "github.com/lxc/lxd/shared/log15"
@@ -863,7 +863,7 @@ func taskIds(pid int) (error, int64, int64, int64, int64) {
 	return nil, uid, gid, fsuid, fsgid
 }
 
-func CallForkmknod(c container, dev types.Device, requestPID int, permissionsOnly int) int {
+func CallForkmknod(c container, dev config.Device, requestPID int, permissionsOnly int) int {
 	rootLink := fmt.Sprintf("/proc/%d/root", requestPID)
 	rootPath, err := os.Readlink(rootLink)
 	if err != nil {
@@ -927,7 +927,7 @@ func (s *SeccompServer) doDeviceSyscall(c container, args *MknodArgs, siov *Secc
 		return int(-C.EPERM)
 	}
 
-	dev := types.Device{}
+	dev := config.Device{}
 	dev["type"] = "unix-char"
 	dev["mode"] = fmt.Sprintf("%#o", args.cMode)
 	dev["major"] = fmt.Sprintf("%d", unix.Major(uint64(args.cDev)))
diff --git a/lxd/storage_migration.go b/lxd/storage_migration.go
index 16341e0297..7767f0eafa 100644
--- a/lxd/storage_migration.go
+++ b/lxd/storage_migration.go
@@ -7,9 +7,9 @@ import (
 	"github.com/gorilla/websocket"
 
 	"github.com/lxc/lxd/lxd/db"
+	deviceConfig "github.com/lxc/lxd/lxd/device/config"
 	"github.com/lxc/lxd/lxd/migration"
 	"github.com/lxc/lxd/lxd/project"
-	"github.com/lxc/lxd/lxd/types"
 	"github.com/lxc/lxd/shared"
 	"github.com/lxc/lxd/shared/api"
 	"github.com/lxc/lxd/shared/logger"
@@ -190,7 +190,7 @@ func snapshotProtobufToContainerArgs(project string, containerName string, snap
 		config[ent.GetKey()] = ent.GetValue()
 	}
 
-	devices := types.Devices{}
+	devices := deviceConfig.Devices{}
 	for _, ent := range snap.LocalDevices {
 		props := map[string]string{}
 		for _, prop := range ent.Config {
diff --git a/test/suites/static_analysis.sh b/test/suites/static_analysis.sh
index 91faee47c5..1c601e9019 100644
--- a/test/suites/static_analysis.sh
+++ b/test/suites/static_analysis.sh
@@ -85,7 +85,6 @@ test_static_analysis() {
       golint -set_exit_status lxd/sys
       golint -set_exit_status lxd/task
       golint -set_exit_status lxd/template
-      golint -set_exit_status lxd/types
       golint -set_exit_status lxd/util
       golint -set_exit_status lxd/device/...
       golint -set_exit_status lxd/dnsmasq/...
@@ -111,7 +110,7 @@ test_static_analysis() {
 
     ## deadcode
     if which deadcode >/dev/null 2>&1; then
-      OUT=$(deadcode ./fuidshift ./lxc ./lxd ./lxd/types ./shared ./shared/api ./shared/i18n ./shared/ioprogress ./shared/logging ./shared/osarch ./shared/simplestreams ./shared/termios ./shared/version ./lxd-benchmark 2>&1 | grep -v lxd/migrate.pb.go: | grep -v /C: | grep -vi _cgo | grep -vi _cfunc || true)
+      OUT=$(deadcode ./fuidshift ./lxc ./lxd ./shared ./shared/api ./shared/i18n ./shared/ioprogress ./shared/logging ./shared/osarch ./shared/simplestreams ./shared/termios ./shared/version ./lxd-benchmark 2>&1 | grep -v lxd/migrate.pb.go: | grep -v /C: | grep -vi _cgo | grep -vi _cfunc || true)
       if [ -n "${OUT}" ]; then
         echo "${OUT}" >&2
         false


More information about the lxc-devel mailing list