[lxc-devel] [lxd/master] Bugfixes

stgraber on Github lxc-bot at linuxcontainers.org
Wed Jan 11 15:01:16 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170111/4e8ba63a/attachment.bin>
-------------- next part --------------
From 4546b78577b541b25b031e2e4a1a890ebdad898d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 11:46:44 +0200
Subject: [PATCH 01/12] lxc: Export image last use date
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/image.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lxc/image.go b/lxc/image.go
index b81191d..b4ad827 100644
--- a/lxc/image.go
+++ b/lxc/image.go
@@ -356,6 +356,11 @@ func (c *imageCmd) run(config *lxd.Config, args []string) error {
 		} else {
 			fmt.Printf("    " + i18n.G("Expires: never") + "\n")
 		}
+		if info.LastUsedAt.UTC().Unix() != 0 {
+			fmt.Printf("    "+i18n.G("Last used: %s")+"\n", info.LastUsedAt.UTC().Format(layout))
+		} else {
+			fmt.Printf("    " + i18n.G("Last used: never") + "\n")
+		}
 		fmt.Println(i18n.G("Properties:"))
 		for key, value := range info.Properties {
 			fmt.Printf("    %s: %s\n", key, value)

From 2d1c4a4c4ad67ced574cac58f3a57a7a1b9294ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:21:50 +0200
Subject: [PATCH 02/12] lxc: Better handle network modifications
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #2785

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/network.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lxc/network.go b/lxc/network.go
index 777615b..e4d68d2 100644
--- a/lxc/network.go
+++ b/lxc/network.go
@@ -318,6 +318,10 @@ func (c *networkCmd) doNetworkEdit(client *lxd.Client, name string) error {
 		return err
 	}
 
+	if !network.Managed {
+		return fmt.Errorf(i18n.G("Only managed networks can be modified."))
+	}
+
 	data, err := yaml.Marshal(&network)
 	if err != nil {
 		return err
@@ -441,6 +445,10 @@ func (c *networkCmd) doNetworkSet(client *lxd.Client, name string, args []string
 		return err
 	}
 
+	if !network.Managed {
+		return fmt.Errorf(i18n.G("Only managed networks can be modified."))
+	}
+
 	key := args[0]
 	var value string
 	if len(args) < 2 {
@@ -452,7 +460,7 @@ func (c *networkCmd) doNetworkSet(client *lxd.Client, name string, args []string
 	if !termios.IsTerminal(int(syscall.Stdin)) && value == "-" {
 		buf, err := ioutil.ReadAll(os.Stdin)
 		if err != nil {
-			return fmt.Errorf("Can't read from stdin: %s", err)
+			return fmt.Errorf(i18n.G("Can't read from stdin: %s"), err)
 		}
 		value = string(buf[:])
 	}

From 77152604eb7de5a76e90bc9b64d736792e8eec62 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:24:55 +0200
Subject: [PATCH 03/12] "gofmt -s" run
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 client.go                             |  4 +--
 config.go                             |  2 +-
 lxc/list.go                           | 24 ++++++-------
 lxc/main_test.go                      |  6 ++--
 lxc/manpage.go                        |  2 +-
 lxd/container.go                      |  2 +-
 lxd/container_lxc.go                  | 10 +++---
 lxd/daemon_config.go                  | 48 ++++++++++++-------------
 lxd/db_update.go                      | 68 +++++++++++++++++------------------
 lxd/devices.go                        |  2 +-
 lxd/devlxd.go                         |  6 ++--
 lxd/main_forkexec.go                  |  2 +-
 lxd/main_test.go                      |  4 +--
 lxd/networks.go                       | 28 +++++++--------
 lxd/networks_utils.go                 |  2 +-
 lxd/patches.go                        |  4 +--
 lxd/types/devices.go                  |  4 +--
 shared/idmapset_linux_test.go         |  8 ++---
 shared/osarch/architectures.go        | 30 ++++++++--------
 shared/simplestreams/simplestreams.go |  2 +-
 shared/stringset.go                   |  2 +-
 shared/util_linux.go                  |  2 +-
 22 files changed, 131 insertions(+), 131 deletions(-)

diff --git a/client.go b/client.go
index 6d4a867..36ab676 100644
--- a/client.go
+++ b/client.go
@@ -2505,7 +2505,7 @@ func (c *Client) ContainerDeviceDelete(container, devname string) (*api.Response
 		return nil, err
 	}
 
-	for n, _ := range st.Devices {
+	for n := range st.Devices {
 		if n == devname {
 			delete(st.Devices, n)
 			return c.put(fmt.Sprintf("containers/%s", container), st, api.AsyncResponse)
@@ -2576,7 +2576,7 @@ func (c *Client) ProfileDeviceDelete(profile, devname string) (*api.Response, er
 		return nil, err
 	}
 
-	for n, _ := range st.Devices {
+	for n := range st.Devices {
 		if n == devname {
 			delete(st.Devices, n)
 			return c.put(fmt.Sprintf("profiles/%s", profile), st, api.SyncResponse)
diff --git a/config.go b/config.go
index 8cd47bb..9492740 100644
--- a/config.go
+++ b/config.go
@@ -116,7 +116,7 @@ func LoadConfig(path string) (*Config, error) {
 
 // SaveConfig writes the provided configuration to the config file.
 func SaveConfig(c *Config, fname string) error {
-	for k, _ := range StaticRemotes {
+	for k := range StaticRemotes {
 		delete(c.Remotes, k)
 	}
 
diff --git a/lxc/list.go b/lxc/list.go
index 8311e90..c5e2f4e 100644
--- a/lxc/list.go
+++ b/lxc/list.go
@@ -134,7 +134,7 @@ func (c *listCmd) dotPrefixMatch(short string, full string) bool {
 		return false
 	}
 
-	for i, _ := range fullMembs {
+	for i := range fullMembs {
 		if !strings.HasPrefix(fullMembs[i], shortMembs[i]) {
 			return false
 		}
@@ -422,17 +422,17 @@ func (c *listCmd) run(config *lxd.Config, args []string) error {
 
 func (c *listCmd) parseColumns() ([]column, error) {
 	columnsShorthandMap := map[rune]column{
-		'4': column{i18n.G("IPV4"), c.IP4ColumnData, true, false},
-		'6': column{i18n.G("IPV6"), c.IP6ColumnData, true, false},
-		'a': column{i18n.G("ARCHITECTURE"), c.ArchitectureColumnData, false, false},
-		'c': column{i18n.G("CREATED AT"), c.CreatedColumnData, false, false},
-		'l': column{i18n.G("LAST USED AT"), c.LastUsedColumnData, false, false},
-		'n': column{i18n.G("NAME"), c.nameColumnData, false, false},
-		'p': column{i18n.G("PID"), c.PIDColumnData, true, false},
-		'P': column{i18n.G("PROFILES"), c.ProfilesColumnData, false, false},
-		'S': column{i18n.G("SNAPSHOTS"), c.numberSnapshotsColumnData, false, true},
-		's': column{i18n.G("STATE"), c.statusColumnData, false, false},
-		't': column{i18n.G("TYPE"), c.typeColumnData, false, false},
+		'4': {i18n.G("IPV4"), c.IP4ColumnData, true, false},
+		'6': {i18n.G("IPV6"), c.IP6ColumnData, true, false},
+		'a': {i18n.G("ARCHITECTURE"), c.ArchitectureColumnData, false, false},
+		'c': {i18n.G("CREATED AT"), c.CreatedColumnData, false, false},
+		'l': {i18n.G("LAST USED AT"), c.LastUsedColumnData, false, false},
+		'n': {i18n.G("NAME"), c.nameColumnData, false, false},
+		'p': {i18n.G("PID"), c.PIDColumnData, true, false},
+		'P': {i18n.G("PROFILES"), c.ProfilesColumnData, false, false},
+		'S': {i18n.G("SNAPSHOTS"), c.numberSnapshotsColumnData, false, true},
+		's': {i18n.G("STATE"), c.statusColumnData, false, false},
+		't': {i18n.G("TYPE"), c.typeColumnData, false, false},
 	}
 
 	if c.fast {
diff --git a/lxc/main_test.go b/lxc/main_test.go
index 5545894..30fc0cb 100644
--- a/lxc/main_test.go
+++ b/lxc/main_test.go
@@ -40,15 +40,15 @@ func TestExpandAliases(t *testing.T) {
 	}
 
 	testcases := []aliasTestcase{
-		aliasTestcase{
+		{
 			input:    []string{"lxc", "list"},
 			expected: []string{"lxc", "list"},
 		},
-		aliasTestcase{
+		{
 			input:    []string{"lxc", "tester", "12"},
 			expected: []string{"lxc", "list", "--no-alias"},
 		},
-		aliasTestcase{
+		{
 			input:    []string{"lxc", "foo", "asdf"},
 			expected: []string{"lxc", "list", "--no-alias", "asdf", "-c", "n"},
 		},
diff --git a/lxc/manpage.go b/lxc/manpage.go
index 101dc2c..084ae0a 100644
--- a/lxc/manpage.go
+++ b/lxc/manpage.go
@@ -28,7 +28,7 @@ func (c *manpageCmd) run(_ *lxd.Config, args []string) error {
 	}
 
 	keys := []string{}
-	for k, _ := range commands {
+	for k := range commands {
 		keys = append(keys, k)
 	}
 	sort.Strings(keys)
diff --git a/lxd/container.go b/lxd/container.go
index 1a7556a..2721f47 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -233,7 +233,7 @@ func containerValidDevices(devices types.Devices, profile bool, expanded bool) e
 			return fmt.Errorf("Invalid device type for device '%s'", name)
 		}
 
-		for k, _ := range m {
+		for k := range m {
 			if !containerValidDeviceConfigKey(m["type"], k) {
 				return fmt.Errorf("Invalid device configuration key for %s: %s", m["type"], k)
 			}
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index fb9f1c8..d6e9b3c 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -640,8 +640,8 @@ func findIdmap(daemon *Daemon, cName string, isolatedStr string, configSize stri
 
 	mkIdmap := func(offset int, size int) *shared.IdmapSet {
 		set := &shared.IdmapSet{Idmap: []shared.IdmapEntry{
-			shared.IdmapEntry{Isuid: true, Nsid: 0, Hostid: offset, Maprange: size},
-			shared.IdmapEntry{Isgid: true, Nsid: 0, Hostid: offset, Maprange: size},
+			{Isuid: true, Nsid: 0, Hostid: offset, Maprange: size},
+			{Isgid: true, Nsid: 0, Hostid: offset, Maprange: size},
 		}}
 
 		for _, ent := range rawMaps {
@@ -1757,7 +1757,7 @@ func (c *containerLXC) startCommon() (string, error) {
 		}
 	}
 
-	for k, _ := range c.localConfig {
+	for k := range c.localConfig {
 		// We only care about volatile
 		if !strings.HasPrefix(k, "volatile.") {
 			continue
@@ -3014,7 +3014,7 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
 
 	// Diff the configurations
 	changedConfig := []string{}
-	for key, _ := range oldExpandedConfig {
+	for key := range oldExpandedConfig {
 		if oldExpandedConfig[key] != c.expandedConfig[key] {
 			if !shared.StringInSlice(key, changedConfig) {
 				changedConfig = append(changedConfig, key)
@@ -3022,7 +3022,7 @@ func (c *containerLXC) Update(args containerArgs, userRequested bool) error {
 		}
 	}
 
-	for key, _ := range c.expandedConfig {
+	for key := range c.expandedConfig {
 		if oldExpandedConfig[key] != c.expandedConfig[key] {
 			if !shared.StringInSlice(key, changedConfig) {
 				changedConfig = append(changedConfig, key)
diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go
index 3a1ec33..1e5e791 100644
--- a/lxd/daemon_config.go
+++ b/lxd/daemon_config.go
@@ -173,29 +173,29 @@ func (k *daemonConfigKey) GetInt64() int64 {
 func daemonConfigInit(db *sql.DB) error {
 	// Set all the keys
 	daemonConfig = map[string]*daemonConfigKey{
-		"core.https_address":             &daemonConfigKey{valueType: "string", setter: daemonConfigSetAddress},
-		"core.https_allowed_headers":     &daemonConfigKey{valueType: "string"},
-		"core.https_allowed_methods":     &daemonConfigKey{valueType: "string"},
-		"core.https_allowed_origin":      &daemonConfigKey{valueType: "string"},
-		"core.https_allowed_credentials": &daemonConfigKey{valueType: "bool"},
-		"core.proxy_http":                &daemonConfigKey{valueType: "string", setter: daemonConfigSetProxy},
-		"core.proxy_https":               &daemonConfigKey{valueType: "string", setter: daemonConfigSetProxy},
-		"core.proxy_ignore_hosts":        &daemonConfigKey{valueType: "string", setter: daemonConfigSetProxy},
-		"core.trust_password":            &daemonConfigKey{valueType: "string", hiddenValue: true, setter: daemonConfigSetPassword},
-
-		"images.auto_update_cached":    &daemonConfigKey{valueType: "bool", defaultValue: "true"},
-		"images.auto_update_interval":  &daemonConfigKey{valueType: "int", defaultValue: "6"},
-		"images.compression_algorithm": &daemonConfigKey{valueType: "string", validator: daemonConfigValidateCompression, defaultValue: "gzip"},
-		"images.remote_cache_expiry":   &daemonConfigKey{valueType: "int", defaultValue: "10", trigger: daemonConfigTriggerExpiry},
-
-		"storage.lvm_fstype":           &daemonConfigKey{valueType: "string", defaultValue: "ext4", validValues: []string{"ext4", "xfs"}},
-		"storage.lvm_mount_options":    &daemonConfigKey{valueType: "string", defaultValue: "discard"},
-		"storage.lvm_thinpool_name":    &daemonConfigKey{valueType: "string", defaultValue: "LXDPool", validator: storageLVMValidateThinPoolName},
-		"storage.lvm_vg_name":          &daemonConfigKey{valueType: "string", validator: storageLVMValidateVolumeGroupName, setter: daemonConfigSetStorage},
-		"storage.lvm_volume_size":      &daemonConfigKey{valueType: "string", defaultValue: "10GiB"},
-		"storage.zfs_pool_name":        &daemonConfigKey{valueType: "string", validator: storageZFSValidatePoolName, setter: daemonConfigSetStorage},
-		"storage.zfs_remove_snapshots": &daemonConfigKey{valueType: "bool"},
-		"storage.zfs_use_refquota":     &daemonConfigKey{valueType: "bool"},
+		"core.https_address":             {valueType: "string", setter: daemonConfigSetAddress},
+		"core.https_allowed_headers":     {valueType: "string"},
+		"core.https_allowed_methods":     {valueType: "string"},
+		"core.https_allowed_origin":      {valueType: "string"},
+		"core.https_allowed_credentials": {valueType: "bool"},
+		"core.proxy_http":                {valueType: "string", setter: daemonConfigSetProxy},
+		"core.proxy_https":               {valueType: "string", setter: daemonConfigSetProxy},
+		"core.proxy_ignore_hosts":        {valueType: "string", setter: daemonConfigSetProxy},
+		"core.trust_password":            {valueType: "string", hiddenValue: true, setter: daemonConfigSetPassword},
+
+		"images.auto_update_cached":    {valueType: "bool", defaultValue: "true"},
+		"images.auto_update_interval":  {valueType: "int", defaultValue: "6"},
+		"images.compression_algorithm": {valueType: "string", validator: daemonConfigValidateCompression, defaultValue: "gzip"},
+		"images.remote_cache_expiry":   {valueType: "int", defaultValue: "10", trigger: daemonConfigTriggerExpiry},
+
+		"storage.lvm_fstype":           {valueType: "string", defaultValue: "ext4", validValues: []string{"ext4", "xfs"}},
+		"storage.lvm_mount_options":    {valueType: "string", defaultValue: "discard"},
+		"storage.lvm_thinpool_name":    {valueType: "string", defaultValue: "LXDPool", validator: storageLVMValidateThinPoolName},
+		"storage.lvm_vg_name":          {valueType: "string", validator: storageLVMValidateVolumeGroupName, setter: daemonConfigSetStorage},
+		"storage.lvm_volume_size":      {valueType: "string", defaultValue: "10GiB"},
+		"storage.zfs_pool_name":        {valueType: "string", validator: storageZFSValidatePoolName, setter: daemonConfigSetStorage},
+		"storage.zfs_remove_snapshots": {valueType: "bool"},
+		"storage.zfs_use_refquota":     {valueType: "bool"},
 	}
 
 	// Load the values from the DB
@@ -311,7 +311,7 @@ func daemonConfigSetProxy(d *Daemon, key string, value string) (string, error) {
 
 	// Clear the simplestreams cache as it's tied to the old proxy config
 	imageStreamCacheLock.Lock()
-	for k, _ := range imageStreamCache {
+	for k := range imageStreamCache {
 		delete(imageStreamCache, k)
 	}
 	imageStreamCacheLock.Unlock()
diff --git a/lxd/db_update.go b/lxd/db_update.go
index 35f7032..a22d35c 100644
--- a/lxd/db_update.go
+++ b/lxd/db_update.go
@@ -34,40 +34,40 @@ import (
 */
 
 var dbUpdates = []dbUpdate{
-	dbUpdate{version: 1, run: dbUpdateFromV0},
-	dbUpdate{version: 2, run: dbUpdateFromV1},
-	dbUpdate{version: 3, run: dbUpdateFromV2},
-	dbUpdate{version: 4, run: dbUpdateFromV3},
-	dbUpdate{version: 5, run: dbUpdateFromV4},
-	dbUpdate{version: 6, run: dbUpdateFromV5},
-	dbUpdate{version: 7, run: dbUpdateFromV6},
-	dbUpdate{version: 8, run: dbUpdateFromV7},
-	dbUpdate{version: 9, run: dbUpdateFromV8},
-	dbUpdate{version: 10, run: dbUpdateFromV9},
-	dbUpdate{version: 11, run: dbUpdateFromV10},
-	dbUpdate{version: 12, run: dbUpdateFromV11},
-	dbUpdate{version: 13, run: dbUpdateFromV12},
-	dbUpdate{version: 14, run: dbUpdateFromV13},
-	dbUpdate{version: 15, run: dbUpdateFromV14},
-	dbUpdate{version: 16, run: dbUpdateFromV15},
-	dbUpdate{version: 17, run: dbUpdateFromV16},
-	dbUpdate{version: 18, run: dbUpdateFromV17},
-	dbUpdate{version: 19, run: dbUpdateFromV18},
-	dbUpdate{version: 20, run: dbUpdateFromV19},
-	dbUpdate{version: 21, run: dbUpdateFromV20},
-	dbUpdate{version: 22, run: dbUpdateFromV21},
-	dbUpdate{version: 23, run: dbUpdateFromV22},
-	dbUpdate{version: 24, run: dbUpdateFromV23},
-	dbUpdate{version: 25, run: dbUpdateFromV24},
-	dbUpdate{version: 26, run: dbUpdateFromV25},
-	dbUpdate{version: 27, run: dbUpdateFromV26},
-	dbUpdate{version: 28, run: dbUpdateFromV27},
-	dbUpdate{version: 29, run: dbUpdateFromV28},
-	dbUpdate{version: 30, run: dbUpdateFromV29},
-	dbUpdate{version: 31, run: dbUpdateFromV30},
-	dbUpdate{version: 32, run: dbUpdateFromV31},
-	dbUpdate{version: 33, run: dbUpdateFromV32},
-	dbUpdate{version: 34, run: dbUpdateFromV33},
+	{version: 1, run: dbUpdateFromV0},
+	{version: 2, run: dbUpdateFromV1},
+	{version: 3, run: dbUpdateFromV2},
+	{version: 4, run: dbUpdateFromV3},
+	{version: 5, run: dbUpdateFromV4},
+	{version: 6, run: dbUpdateFromV5},
+	{version: 7, run: dbUpdateFromV6},
+	{version: 8, run: dbUpdateFromV7},
+	{version: 9, run: dbUpdateFromV8},
+	{version: 10, run: dbUpdateFromV9},
+	{version: 11, run: dbUpdateFromV10},
+	{version: 12, run: dbUpdateFromV11},
+	{version: 13, run: dbUpdateFromV12},
+	{version: 14, run: dbUpdateFromV13},
+	{version: 15, run: dbUpdateFromV14},
+	{version: 16, run: dbUpdateFromV15},
+	{version: 17, run: dbUpdateFromV16},
+	{version: 18, run: dbUpdateFromV17},
+	{version: 19, run: dbUpdateFromV18},
+	{version: 20, run: dbUpdateFromV19},
+	{version: 21, run: dbUpdateFromV20},
+	{version: 22, run: dbUpdateFromV21},
+	{version: 23, run: dbUpdateFromV22},
+	{version: 24, run: dbUpdateFromV23},
+	{version: 25, run: dbUpdateFromV24},
+	{version: 26, run: dbUpdateFromV25},
+	{version: 27, run: dbUpdateFromV26},
+	{version: 28, run: dbUpdateFromV27},
+	{version: 29, run: dbUpdateFromV28},
+	{version: 30, run: dbUpdateFromV29},
+	{version: 31, run: dbUpdateFromV30},
+	{version: 32, run: dbUpdateFromV31},
+	{version: 33, run: dbUpdateFromV32},
+	{version: 34, run: dbUpdateFromV33},
 }
 
 type dbUpdate struct {
diff --git a/lxd/devices.go b/lxd/devices.go
index 62b0a82..9e0e413 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -1210,7 +1210,7 @@ func loadRawValues(p string) (map[string]string, error) {
 		"devnum":    "",
 	}
 
-	for k, _ := range values {
+	for k := range values {
 		v, err := ioutil.ReadFile(path.Join(p, k))
 		if err != nil {
 			return nil, err
diff --git a/lxd/devlxd.go b/lxd/devlxd.go
index bf4edc8..7e27a16 100644
--- a/lxd/devlxd.go
+++ b/lxd/devlxd.go
@@ -43,7 +43,7 @@ type devLxdHandler struct {
 
 var configGet = devLxdHandler{"/1.0/config", func(c container, r *http.Request) *devLxdResponse {
 	filtered := []string{}
-	for k, _ := range c.ExpandedConfig() {
+	for k := range c.ExpandedConfig() {
 		if strings.HasPrefix(k, "user.") {
 			filtered = append(filtered, fmt.Sprintf("/1.0/config/%s", k))
 		}
@@ -71,10 +71,10 @@ var metadataGet = devLxdHandler{"/1.0/meta-data", func(c container, r *http.Requ
 }}
 
 var handlers = []devLxdHandler{
-	devLxdHandler{"/", func(c container, r *http.Request) *devLxdResponse {
+	{"/", func(c container, r *http.Request) *devLxdResponse {
 		return okResponse([]string{"/1.0"}, "json")
 	}},
-	devLxdHandler{"/1.0", func(c container, r *http.Request) *devLxdResponse {
+	{"/1.0", func(c container, r *http.Request) *devLxdResponse {
 		return okResponse(shared.Jmap{"api_version": version.APIVersion}, "json")
 	}},
 	configGet,
diff --git a/lxd/main_forkexec.go b/lxd/main_forkexec.go
index 8ebb0a6..b9c6cbb 100644
--- a/lxd/main_forkexec.go
+++ b/lxd/main_forkexec.go
@@ -63,7 +63,7 @@ func cmdForkExec(args []string) (int, error) {
 	cmd := []string{}
 
 	section := ""
-	for _, arg := range args[5:len(args)] {
+	for _, arg := range args[5:] {
 		// The "cmd" section must come last as it may contain a --
 		if arg == "--" && section != "cmd" {
 			section = ""
diff --git a/lxd/main_test.go b/lxd/main_test.go
index 262c541..f5f4518 100644
--- a/lxd/main_test.go
+++ b/lxd/main_test.go
@@ -24,8 +24,8 @@ func mockStartDaemon() (*Daemon, error) {
 	}
 
 	d.IdmapSet = &shared.IdmapSet{Idmap: []shared.IdmapEntry{
-		shared.IdmapEntry{Isuid: true, Hostid: 100000, Nsid: 0, Maprange: 500000},
-		shared.IdmapEntry{Isgid: true, Hostid: 100000, Nsid: 0, Maprange: 500000},
+		{Isuid: true, Hostid: 100000, Nsid: 0, Maprange: 500000},
+		{Isgid: true, Hostid: 100000, Nsid: 0, Maprange: 500000},
 	}}
 
 	// Call this after Init so we have a log object.
diff --git a/lxd/networks.go b/lxd/networks.go
index 8ad97ec..867844a 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -666,12 +666,12 @@ func (n *network) Start() error {
 	if n.config["bridge.mode"] == "fan" || !shared.StringInSlice(n.config["ipv4.address"], []string{"", "none"}) {
 		// Setup basic iptables overrides
 		rules := [][]string{
-			[]string{"ipv4", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "67", "-j", "ACCEPT"},
-			[]string{"ipv4", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "53", "-j", "ACCEPT"},
-			[]string{"ipv4", n.name, "", "INPUT", "-i", n.name, "-p", "tcp", "--dport", "53", "-j", "ACCEPT"},
-			[]string{"ipv4", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "67", "-j", "ACCEPT"},
-			[]string{"ipv4", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "53", "-j", "ACCEPT"},
-			[]string{"ipv4", n.name, "", "OUTPUT", "-o", n.name, "-p", "tcp", "--sport", "53", "-j", "ACCEPT"}}
+			{"ipv4", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "67", "-j", "ACCEPT"},
+			{"ipv4", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "53", "-j", "ACCEPT"},
+			{"ipv4", n.name, "", "INPUT", "-i", n.name, "-p", "tcp", "--dport", "53", "-j", "ACCEPT"},
+			{"ipv4", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "67", "-j", "ACCEPT"},
+			{"ipv4", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "53", "-j", "ACCEPT"},
+			{"ipv4", n.name, "", "OUTPUT", "-o", n.name, "-p", "tcp", "--sport", "53", "-j", "ACCEPT"}}
 
 		for _, rule := range rules {
 			err = networkIptablesPrepend(rule[0], rule[1], rule[2], rule[3], rule[4:]...)
@@ -837,12 +837,12 @@ func (n *network) Start() error {
 
 		// Setup basic iptables overrides
 		rules := [][]string{
-			[]string{"ipv6", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "546", "-j", "ACCEPT"},
-			[]string{"ipv6", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "53", "-j", "ACCEPT"},
-			[]string{"ipv6", n.name, "", "INPUT", "-i", n.name, "-p", "tcp", "--dport", "53", "-j", "ACCEPT"},
-			[]string{"ipv6", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "546", "-j", "ACCEPT"},
-			[]string{"ipv6", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "53", "-j", "ACCEPT"},
-			[]string{"ipv6", n.name, "", "OUTPUT", "-o", n.name, "-p", "tcp", "--sport", "53", "-j", "ACCEPT"}}
+			{"ipv6", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "546", "-j", "ACCEPT"},
+			{"ipv6", n.name, "", "INPUT", "-i", n.name, "-p", "udp", "--dport", "53", "-j", "ACCEPT"},
+			{"ipv6", n.name, "", "INPUT", "-i", n.name, "-p", "tcp", "--dport", "53", "-j", "ACCEPT"},
+			{"ipv6", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "546", "-j", "ACCEPT"},
+			{"ipv6", n.name, "", "OUTPUT", "-o", n.name, "-p", "udp", "--sport", "53", "-j", "ACCEPT"},
+			{"ipv6", n.name, "", "OUTPUT", "-o", n.name, "-p", "tcp", "--sport", "53", "-j", "ACCEPT"}}
 
 		for _, rule := range rules {
 			err = networkIptablesPrepend(rule[0], rule[1], rule[2], rule[3], rule[4:]...)
@@ -1263,7 +1263,7 @@ func (n *network) Update(newNetwork api.NetworkPut) error {
 	// Diff the configurations
 	changedConfig := []string{}
 	userOnly := true
-	for key, _ := range oldConfig {
+	for key := range oldConfig {
 		if oldConfig[key] != newConfig[key] {
 			if !strings.HasPrefix(key, "user.") {
 				userOnly = false
@@ -1275,7 +1275,7 @@ func (n *network) Update(newNetwork api.NetworkPut) error {
 		}
 	}
 
-	for key, _ := range newConfig {
+	for key := range newConfig {
 		if oldConfig[key] != newConfig[key] {
 			if !strings.HasPrefix(key, "user.") {
 				userOnly = false
diff --git a/lxd/networks_utils.go b/lxd/networks_utils.go
index b5f2199..f632121 100644
--- a/lxd/networks_utils.go
+++ b/lxd/networks_utils.go
@@ -151,7 +151,7 @@ func networkGetIP(subnet *net.IPNet, host int64) net.IP {
 func networkGetTunnels(config map[string]string) []string {
 	tunnels := []string{}
 
-	for k, _ := range config {
+	for k := range config {
 		if !strings.HasPrefix(k, "tunnel.") {
 			continue
 		}
diff --git a/lxd/patches.go b/lxd/patches.go
index 3d303dd..ae1e258 100644
--- a/lxd/patches.go
+++ b/lxd/patches.go
@@ -26,8 +26,8 @@ import (
 */
 
 var patches = []patch{
-	patch{name: "invalid_profile_names", run: patchInvalidProfileNames},
-	patch{name: "leftover_profile_config", run: patchLeftoverProfileConfig},
+	{name: "invalid_profile_names", run: patchInvalidProfileNames},
+	{name: "leftover_profile_config", run: patchLeftoverProfileConfig},
 }
 
 type patch struct {
diff --git a/lxd/types/devices.go b/lxd/types/devices.go
index 04cd766..263f4c4 100644
--- a/lxd/types/devices.go
+++ b/lxd/types/devices.go
@@ -33,13 +33,13 @@ func (list Devices) Contains(k string, d Device) bool {
 
 func deviceEquals(old Device, d Device) bool {
 	// Check for any difference and addition/removal of properties
-	for k, _ := range d {
+	for k := range d {
 		if d[k] != old[k] {
 			return false
 		}
 	}
 
-	for k, _ := range old {
+	for k := range old {
 		if d[k] != old[k] {
 			return false
 		}
diff --git a/shared/idmapset_linux_test.go b/shared/idmapset_linux_test.go
index 588b847..d8582c8 100644
--- a/shared/idmapset_linux_test.go
+++ b/shared/idmapset_linux_test.go
@@ -6,7 +6,7 @@ import (
 )
 
 func TestIdmapSetAddSafe_split(t *testing.T) {
-	orig := IdmapSet{Idmap: []IdmapEntry{IdmapEntry{Isuid: true, Hostid: 1000, Nsid: 0, Maprange: 1000}}}
+	orig := IdmapSet{Idmap: []IdmapEntry{{Isuid: true, Hostid: 1000, Nsid: 0, Maprange: 1000}}}
 
 	if err := orig.AddSafe(IdmapEntry{Isuid: true, Hostid: 500, Nsid: 500, Maprange: 10}); err != nil {
 		t.Error(err)
@@ -35,7 +35,7 @@ func TestIdmapSetAddSafe_split(t *testing.T) {
 }
 
 func TestIdmapSetAddSafe_lower(t *testing.T) {
-	orig := IdmapSet{Idmap: []IdmapEntry{IdmapEntry{Isuid: true, Hostid: 1000, Nsid: 0, Maprange: 1000}}}
+	orig := IdmapSet{Idmap: []IdmapEntry{{Isuid: true, Hostid: 1000, Nsid: 0, Maprange: 1000}}}
 
 	if err := orig.AddSafe(IdmapEntry{Isuid: true, Hostid: 500, Nsid: 0, Maprange: 10}); err != nil {
 		t.Error(err)
@@ -59,7 +59,7 @@ func TestIdmapSetAddSafe_lower(t *testing.T) {
 }
 
 func TestIdmapSetAddSafe_upper(t *testing.T) {
-	orig := IdmapSet{Idmap: []IdmapEntry{IdmapEntry{Isuid: true, Hostid: 1000, Nsid: 0, Maprange: 1000}}}
+	orig := IdmapSet{Idmap: []IdmapEntry{{Isuid: true, Hostid: 1000, Nsid: 0, Maprange: 1000}}}
 
 	if err := orig.AddSafe(IdmapEntry{Isuid: true, Hostid: 500, Nsid: 995, Maprange: 10}); err != nil {
 		t.Error(err)
@@ -83,7 +83,7 @@ func TestIdmapSetAddSafe_upper(t *testing.T) {
 }
 
 func TestIdmapSetIntersects(t *testing.T) {
-	orig := IdmapSet{Idmap: []IdmapEntry{IdmapEntry{Isuid: true, Hostid: 165536, Nsid: 0, Maprange: 65536}}}
+	orig := IdmapSet{Idmap: []IdmapEntry{{Isuid: true, Hostid: 165536, Nsid: 0, Maprange: 65536}}}
 
 	if !orig.Intersects(IdmapEntry{Isuid: true, Hostid: 231071, Nsid: 0, Maprange: 65536}) {
 		t.Error("ranges don't intersect")
diff --git a/shared/osarch/architectures.go b/shared/osarch/architectures.go
index 728098c..265d7cb 100644
--- a/shared/osarch/architectures.go
+++ b/shared/osarch/architectures.go
@@ -28,13 +28,13 @@ var architectureNames = map[int]string{
 }
 
 var architectureAliases = map[int][]string{
-	ARCH_32BIT_INTEL_X86:             []string{"i386"},
-	ARCH_64BIT_INTEL_X86:             []string{"amd64"},
-	ARCH_32BIT_ARMV7_LITTLE_ENDIAN:   []string{"armel", "armhf"},
-	ARCH_64BIT_ARMV8_LITTLE_ENDIAN:   []string{"arm64"},
-	ARCH_32BIT_POWERPC_BIG_ENDIAN:    []string{"powerpc"},
-	ARCH_64BIT_POWERPC_BIG_ENDIAN:    []string{"powerpc64"},
-	ARCH_64BIT_POWERPC_LITTLE_ENDIAN: []string{"ppc64el"},
+	ARCH_32BIT_INTEL_X86:             {"i386"},
+	ARCH_64BIT_INTEL_X86:             {"amd64"},
+	ARCH_32BIT_ARMV7_LITTLE_ENDIAN:   {"armel", "armhf"},
+	ARCH_64BIT_ARMV8_LITTLE_ENDIAN:   {"arm64"},
+	ARCH_32BIT_POWERPC_BIG_ENDIAN:    {"powerpc"},
+	ARCH_64BIT_POWERPC_BIG_ENDIAN:    {"powerpc64"},
+	ARCH_64BIT_POWERPC_LITTLE_ENDIAN: {"ppc64el"},
 }
 
 var architecturePersonalities = map[int]string{
@@ -49,14 +49,14 @@ var architecturePersonalities = map[int]string{
 }
 
 var architectureSupportedPersonalities = map[int][]int{
-	ARCH_32BIT_INTEL_X86:             []int{},
-	ARCH_64BIT_INTEL_X86:             []int{ARCH_32BIT_INTEL_X86},
-	ARCH_32BIT_ARMV7_LITTLE_ENDIAN:   []int{},
-	ARCH_64BIT_ARMV8_LITTLE_ENDIAN:   []int{ARCH_32BIT_ARMV7_LITTLE_ENDIAN},
-	ARCH_32BIT_POWERPC_BIG_ENDIAN:    []int{},
-	ARCH_64BIT_POWERPC_BIG_ENDIAN:    []int{ARCH_32BIT_POWERPC_BIG_ENDIAN},
-	ARCH_64BIT_POWERPC_LITTLE_ENDIAN: []int{},
-	ARCH_64BIT_S390_BIG_ENDIAN:       []int{},
+	ARCH_32BIT_INTEL_X86:             {},
+	ARCH_64BIT_INTEL_X86:             {ARCH_32BIT_INTEL_X86},
+	ARCH_32BIT_ARMV7_LITTLE_ENDIAN:   {},
+	ARCH_64BIT_ARMV8_LITTLE_ENDIAN:   {ARCH_32BIT_ARMV7_LITTLE_ENDIAN},
+	ARCH_32BIT_POWERPC_BIG_ENDIAN:    {},
+	ARCH_64BIT_POWERPC_BIG_ENDIAN:    {ARCH_32BIT_POWERPC_BIG_ENDIAN},
+	ARCH_64BIT_POWERPC_LITTLE_ENDIAN: {},
+	ARCH_64BIT_S390_BIG_ENDIAN:       {},
 }
 
 const ArchitectureDefault = "x86_64"
diff --git a/shared/simplestreams/simplestreams.go b/shared/simplestreams/simplestreams.go
index dd5d206..d71fcd3 100644
--- a/shared/simplestreams/simplestreams.go
+++ b/shared/simplestreams/simplestreams.go
@@ -212,7 +212,7 @@ func (s *SimpleStreamsManifest) ToLXD() ([]api.Image, map[string][][]string) {
 				}
 			}
 
-			downloads[fingerprint] = [][]string{[]string{metaPath, metaHash, "meta"}, []string{rootfsPath, rootfsHash, "root"}}
+			downloads[fingerprint] = [][]string{{metaPath, metaHash, "meta"}, {rootfsPath, rootfsHash, "root"}}
 			images = append(images, image)
 		}
 	}
diff --git a/shared/stringset.go b/shared/stringset.go
index 1094e61..a851d7a 100644
--- a/shared/stringset.go
+++ b/shared/stringset.go
@@ -5,7 +5,7 @@ package shared
 type StringSet map[string]bool
 
 func (ss StringSet) IsSubset(oss StringSet) bool {
-	for k, _ := range map[string]bool(ss) {
+	for k := range map[string]bool(ss) {
 		if _, ok := map[string]bool(oss)[k]; !ok {
 			return false
 		}
diff --git a/shared/util_linux.go b/shared/util_linux.go
index 8ef5b82..3adfc78 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -413,7 +413,7 @@ func ReadLastNLines(f *os.File, lines int) (string, error) {
 		}
 
 		if lines < 0 {
-			return string(data[i+1 : len(data)]), nil
+			return string(data[i+1:]), nil
 		}
 	}
 

From 0c23c13c264fc509d86120c908ced43e8fb0a3c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:27:27 +0200
Subject: [PATCH 04/12] Fix typos
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/container_lxc.go   | 2 +-
 lxd/containers_post.go | 2 +-
 lxd/devlxd.go          | 4 ++--
 lxd/images.go          | 2 +-
 lxd/networks.go        | 2 +-
 shared/util.go         | 2 +-
 shared/util_linux.go   | 2 +-
 7 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index d6e9b3c..de2fe14 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -2804,7 +2804,7 @@ func writeBackupFile(c container) error {
 		return os.ErrNotExist
 	}
 
-	/* deal with the container occasionaly not being monuted */
+	/* deal with the container occasionally not being monuted */
 	if !shared.PathExists(c.RootfsPath()) {
 		shared.LogWarn("Unable to update backup.yaml at this time.", log.Ctx{"name": c.Name()})
 		return nil
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index fd9babc..598cabf 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -257,7 +257,7 @@ func createFromMigration(d *Daemon, req *api.ContainersPost) Response {
 	}
 
 	run := func(op *operation) error {
-		// And finaly run the migration.
+		// And finally run the migration.
 		err = sink.Do(op)
 		if err != nil {
 			shared.LogError("Error during migration sink", log.Ctx{"err": err})
diff --git a/lxd/devlxd.go b/lxd/devlxd.go
index 7e27a16..1d0acc1 100644
--- a/lxd/devlxd.go
+++ b/lxd/devlxd.go
@@ -269,7 +269,7 @@ func getCred(conn *net.UnixConn) (*ucred, error) {
 /*
  * As near as I can tell, there is no nice way of extracting an underlying
  * net.Conn (or in our case, net.UnixConn) from an http.Request or
- * ResponseWriter without hijacking it [1]. Since we want to send and recieve
+ * ResponseWriter without hijacking it [1]. Since we want to send and receive
  * unix creds to figure out which container this request came from, we need to
  * do this.
  *
@@ -301,7 +301,7 @@ func findContainerForPid(pid int32, d *Daemon) (container, error) {
 	 *    an lxc monitor process and extract its name from there.
 	 *
 	 * 2. If this fails, it may be that someone did an `lxc exec foo bash`,
-	 *    so the process isn't actually a decendant of the container's
+	 *    so the process isn't actually a descendant of the container's
 	 *    init. In this case we just look through all the containers until
 	 *    we find an init with a matching pid namespace. This is probably
 	 *    uncommon, so hopefully the slowness won't hurt us.
diff --git a/lxd/images.go b/lxd/images.go
index 1d34299..10c179b 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -35,7 +35,7 @@ import (
    The CPU and I/O load of publish is such that running multiple ones in
    parallel takes longer than running them serially.
 
-   Additionaly, publishing the same container or container snapshot
+   Additionally, publishing the same container or container snapshot
    twice would lead to storage problem, not to mention a conflict at the
    end for whichever finishes last. */
 var imagePublishLock sync.Mutex
diff --git a/lxd/networks.go b/lxd/networks.go
index 867844a..9635734 100644
--- a/lxd/networks.go
+++ b/lxd/networks.go
@@ -1150,7 +1150,7 @@ func (n *network) Start() error {
 			}
 		}
 
-		// Start dnsmasq (occasionaly races, try a few times)
+		// Start dnsmasq (occasionally races, try a few times)
 		output, err := tryExec(dnsmasqCmd[0], dnsmasqCmd[1:]...)
 		if err != nil {
 			return fmt.Errorf("Failed to run: %s: %s", strings.Join(dnsmasqCmd, " "), strings.TrimSpace(string(output)))
diff --git a/shared/util.go b/shared/util.go
index 9afc3f6..351bbd6 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -726,7 +726,7 @@ func GetByteSizeString(input int64, precision uint) string {
 }
 
 // RemoveDuplicatesFromString removes all duplicates of the string 'sep'
-// from the specified string 's'.  Leading and trailing occurences of sep
+// from the specified string 's'.  Leading and trailing occurrences of sep
 // are NOT removed (duplicate leading/trailing are).  Performs poorly if
 // there are multiple consecutive redundant separators.
 func RemoveDuplicatesFromString(s string, sep string) string {
diff --git a/shared/util_linux.go b/shared/util_linux.go
index 3adfc78..9ce2fb0 100644
--- a/shared/util_linux.go
+++ b/shared/util_linux.go
@@ -642,7 +642,7 @@ func ExecReaderToChannel(r io.Reader, bufferSize int, exited <-chan bool, fd int
 					// still be handling a pure POLLIN event from a write prior to the childs
 					// exit. But the child might have exited right before and performed
 					// atomic.StoreInt32() to update attachedChildIsDead before we
-					// performed our atomic.LoadInt32(). This means we accidently hit this
+					// performed our atomic.LoadInt32(). This means we accidentally hit this
 					// codepath and are misinformed about the available poll() events. So we
 					// need to perform a non-blocking poll() again to exclude that case:
 					//

From 2c27bfa93f00b531f7f5940d22ef213c2ea54d84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:56:24 +0200
Subject: [PATCH 05/12] client: Better handle http errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 client.go | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/client.go b/client.go
index 36ab676..b4629b8 100644
--- a/client.go
+++ b/client.go
@@ -998,6 +998,10 @@ func (c *Client) PostImage(imageFile string, rootfsFile string, properties []str
 		}
 
 		req, err = http.NewRequest("POST", uri, progress)
+		if err != nil {
+			return "", err
+		}
+
 		req.Header.Set("Content-Type", w.FormDataContentType())
 	} else {
 		fImage, err = os.Open(imageFile)
@@ -1020,6 +1024,10 @@ func (c *Client) PostImage(imageFile string, rootfsFile string, properties []str
 		}
 
 		req, err = http.NewRequest("POST", uri, progress)
+		if err != nil {
+			return "", err
+		}
+
 		req.Header.Set("X-LXD-filename", filepath.Base(imageFile))
 		req.Header.Set("Content-Type", "application/octet-stream")
 	}

From 29ae83fe636c9c23a488cb3a9131cdfce3d54e1d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:57:04 +0200
Subject: [PATCH 06/12] Properly check yaml errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/config.go  | 3 +++
 lxc/network.go | 4 ++++
 lxc/profile.go | 4 ++++
 3 files changed, 11 insertions(+)

diff --git a/lxc/config.go b/lxc/config.go
index 3314ccf..ce79c9e 100644
--- a/lxc/config.go
+++ b/lxc/config.go
@@ -344,6 +344,9 @@ func (c *configCmd) run(config *lxd.Config, args []string) error {
 
 			brief := config.Writable()
 			data, err = yaml.Marshal(&brief)
+			if err != nil {
+				return err
+			}
 		} else {
 			var brief api.ContainerPut
 			if shared.IsSnapshot(container) {
diff --git a/lxc/network.go b/lxc/network.go
index e4d68d2..853932b 100644
--- a/lxc/network.go
+++ b/lxc/network.go
@@ -477,6 +477,10 @@ func (c *networkCmd) doNetworkShow(client *lxd.Client, name string) error {
 	}
 
 	data, err := yaml.Marshal(&network)
+	if err != nil {
+		return err
+	}
+
 	fmt.Printf("%s", data)
 
 	return nil
diff --git a/lxc/profile.go b/lxc/profile.go
index 30cc3c8..1685826 100644
--- a/lxc/profile.go
+++ b/lxc/profile.go
@@ -315,6 +315,10 @@ func (c *profileCmd) doProfileShow(client *lxd.Client, p string) error {
 	}
 
 	data, err := yaml.Marshal(&profile)
+	if err != nil {
+		return err
+	}
+
 	fmt.Printf("%s", data)
 
 	return nil

From 4fa65627e05927346d11ddae928bc381ecc63952 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:58:41 +0200
Subject: [PATCH 07/12] init: Properly replace args list
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/init.go | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lxc/init.go b/lxc/init.go
index 0e6df1d..4305902 100644
--- a/lxc/init.go
+++ b/lxc/init.go
@@ -126,6 +126,7 @@ func (c *initCmd) massage_args() {
 		initRequestedEmptyProfiles = true
 		newargs := os.Args[0 : l-2]
 		newargs = append(newargs, os.Args[l-1])
+		os.Args = newargs
 		return
 	}
 }

From 55a6fe1c299acd06fd151ae9271bf39d7d28d850 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:58:59 +0200
Subject: [PATCH 08/12] list: Fix unused variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxc/list.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxc/list.go b/lxc/list.go
index c5e2f4e..8ec0a16 100644
--- a/lxc/list.go
+++ b/lxc/list.go
@@ -495,7 +495,7 @@ func (c *listCmd) parseColumns() ([]column, error) {
 			column.Data = func(cInfo api.Container, cState *api.ContainerState, cSnaps []api.ContainerSnapshot) string {
 				v, ok := cInfo.Config[k]
 				if !ok {
-					v, ok = cInfo.ExpandedConfig[k]
+					v, _ = cInfo.ExpandedConfig[k]
 				}
 
 				// Truncate the data according to the max width.  A negative max width

From f949777e9bcb01233b7e11c2e212c1ead8efdead Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:59:16 +0200
Subject: [PATCH 09/12] profiles: Fix unusued variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/db_profiles.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/db_profiles.go b/lxd/db_profiles.go
index abbb3ab..b05bdf0 100644
--- a/lxd/db_profiles.go
+++ b/lxd/db_profiles.go
@@ -108,7 +108,7 @@ func dbProfileCreateDefault(db *sql.DB) error {
 		return nil
 	}
 
-	id, err := dbProfileCreate(db, "default", "Default LXD profile", map[string]string{}, types.Devices{})
+	_, err := dbProfileCreate(db, "default", "Default LXD profile", map[string]string{}, types.Devices{})
 	if err != nil {
 		return err
 	}

From 5f2ac19de1fdcc4311fb5e122004db8bb0c70be1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:59:37 +0200
Subject: [PATCH 10/12] devices: Don't ignore regexp failures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/devices.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lxd/devices.go b/lxd/devices.go
index 9e0e413..a21808d 100644
--- a/lxd/devices.go
+++ b/lxd/devices.go
@@ -187,6 +187,10 @@ func deviceLoadGpu() ([]gpuDevice, []nvidiaGpuDevices, error) {
 			tmpGpu.minor = minorInt
 
 			isCard, err := regexp.MatchString("^card[0-9]+", drmEnt.Name())
+			if err != nil {
+				continue
+			}
+
 			if isCard {
 				// If it is a card it's minor number will be its id.
 				tmpGpu.id = strconv.Itoa(minorInt)

From a42ff29b1a03135c4c3dde28d1ca20e89f33327c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 16:59:49 +0200
Subject: [PATCH 11/12] migrate: Use the generate snapshot list
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/migrate.go | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lxd/migrate.go b/lxd/migrate.go
index e45fb15..db753d0 100644
--- a/lxd/migrate.go
+++ b/lxd/migrate.go
@@ -793,7 +793,8 @@ func (c *migrationSink) Do(migrateOp *operation) error {
 			} else {
 				fsConn = c.src.fsConn
 			}
-			if err := mySink(live, c.src.container, header.Snapshots, fsConn, srcIdmap, migrateOp); err != nil {
+
+			if err := mySink(live, c.src.container, snapshots, fsConn, srcIdmap, migrateOp); err != nil {
 				fsTransfer <- err
 				return
 			}

From aa8f40b6938684bc4bddab5c04fdfbfede892500 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Wed, 11 Jan 2017 17:00:04 +0200
Subject: [PATCH 12/12] tests: Don't ignore errors in db tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/db_test.go | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/lxd/db_test.go b/lxd/db_test.go
index ae0e504..b967127 100644
--- a/lxd/db_test.go
+++ b/lxd/db_test.go
@@ -99,6 +99,9 @@ func Test_deleting_a_container_cascades_on_related_tables(t *testing.T) {
 	// Make sure there are 0 containers_devices_config entries left.
 	statements = `SELECT count(*) FROM containers_devices_config;`
 	err = db.QueryRow(statements).Scan(&count)
+	if err != nil {
+		t.Errorf(err)
+	}
 
 	if count != 0 {
 		t.Errorf("Deleting a container didn't delete the associated container_devices_config! There are %d left", count)
@@ -151,6 +154,9 @@ func Test_deleting_a_profile_cascades_on_related_tables(t *testing.T) {
 	// Make sure there are 0 profiles_devices_config entries left.
 	statements = `SELECT count(*) FROM profiles_devices_config WHERE profile_device_id == 4;`
 	err = db.QueryRow(statements).Scan(&count)
+	if err != nil {
+		t.Errorf(err)
+	}
 
 	if count != 0 {
 		t.Errorf("Deleting a profile didn't delete the related profiles_devices_config! There are %d left", count)
@@ -186,6 +192,9 @@ func Test_deleting_an_image_cascades_on_related_tables(t *testing.T) {
 	// Make sure there are 0 images_properties entries left.
 	statements = `SELECT count(*) FROM images_properties;`
 	err = db.QueryRow(statements).Scan(&count)
+	if err != nil {
+		t.Errorf(err)
+	}
 
 	if count != 0 {
 		t.Errorf("Deleting an image didn't delete the related images_properties! There are %d left", count)
@@ -285,6 +294,9 @@ INSERT INTO containers_config (container_id, key, value) VALUES (1, 'thekey', 't
 	// Make sure there are 0 container_profiles entries left.
 	statements = `SELECT count(*) FROM containers_profiles;`
 	err = d.db.QueryRow(statements).Scan(&count)
+	if err != nil {
+		t.Errorf(err)
+	}
 
 	if count != 0 {
 		t.Errorf("Deleting a container didn't delete the profile association! There are %d left", count)
@@ -392,6 +404,9 @@ INSERT INTO containers_config (container_id, key, value) VALUES (1, 'thekey', 't
 	// Make sure there are 0 containers_config entries left.
 	statements = `SELECT count(*) FROM containers_config;`
 	err = db.QueryRow(statements).Scan(&count)
+	if err != nil {
+		t.Errorf(err)
+	}
 
 	if count != 0 {
 		t.Fatal("updateDb did not delete orphaned child entries after adding ON DELETE CASCADE!")


More information about the lxc-devel mailing list