[lxc-devel] [pylxd/master] configure github actions

2020-12-08 Thread albertodonato on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/433

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Github actions test - DON'T MERGE YET
From 397bde20ca16ec8d1d786c095903a15db2e63f66 Mon Sep 17 00:00:00 2001
From: Alberto Donato 
Date: Wed, 9 Dec 2020 08:34:13 +0100
Subject: [PATCH] configure github actions

---
 .github/workflows | 52 +++
 1 file changed, 52 insertions(+)
 create mode 100644 .github/workflows

diff --git a/.github/workflows b/.github/workflows
new file mode 100644
index ..defb80b0
--- /dev/null
+++ b/.github/workflows
@@ -0,0 +1,52 @@
+# -*- mode: yaml -*-
+
+name: PyLXD
+
+on:
+  push:
+branches:
+  - main
+  pull_request:
+branches:
+  - main
+
+jobs:
+  build:
+
+runs-on: ubuntu-latest
+strategy:
+  matrix:
+python-version:
+  - "3.6"
+  - "3.7"
+  - "3.8"
+
+steps:
+- name: Repository checkout
+  uses: actions/checkout@v2
+
+- name: Set up Python ${{ matrix.python-version }}
+  uses: actions/setup-python@v2
+  with:
+python-version: ${{ matrix.python-version }}
+
+- name: Cache packages
+  uses: actions/cache@v2
+  with:
+path: ~/.cache/pip
+# Look to see if there is a cache hit for the corresponding 
requirements file
+key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
+  restore-keys: |
+${{ runner.os }}-pip-
+${{ runner.os }}-
+- name: Install dependencies
+  run: |
+pip install --upgrade pip
+pip install tox codecov
+- name: Lint
+  run: |
+tox -e lint
+- name: Test
+  run: |
+tox -e py
+codecov
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [lxc/lxc] 67e7ac: added standard resolver option to the lxc-download...

2020-12-08 Thread Stéphane Graber
  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 67e7ac7b851fa75bd2e2280fd83235a13452ee7a
  https://github.com/lxc/lxc/commit/67e7ac7b851fa75bd2e2280fd83235a13452ee7a
  Author: Andrew Deng 
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
M templates/lxc-download.in

  Log Message:
  ---
  added standard resolver option to the lxc-download.in shell script

Signed-off-by: Andrew Deng 


  Commit: 20aa280bf75a4270cbfd011de63acc2077df356d
  https://github.com/lxc/lxc/commit/20aa280bf75a4270cbfd011de63acc2077df356d
  Author: Stéphane Graber 
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
M templates/lxc-download.in

  Log Message:
  ---
  Merge pull request #3585 from AndrewElvisDeng/issue-1507

new standard resolver option in ldc-download.in shell script


Compare: https://github.com/lxc/lxc/compare/4c9ffb3e6631...20aa280bf75a
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [lxc/master] Restore interfaces to the correct namespace on error

2020-12-08 Thread blairsteven on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3596

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
If the container unexpectedly exists we may need to restore physical
interfaces back into the main namespace in a tidy way.

Signed-off-by: Blair Steven 
From abd953eb5120b8a5fd4c97634ba01305ec6e1f3b Mon Sep 17 00:00:00 2001
From: Blair Steven 
Date: Wed, 9 Dec 2020 11:23:39 +1300
Subject: [PATCH] Restore interfaces to the correct namespace on error

If the container unexpectedly exists we may need to restore physical
interfaces back into the main namespace in a tidy way.

Signed-off-by: Blair Steven 
---
 src/lxc/start.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 7bf7f8a2fb..863ae123b3 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -2144,6 +2144,7 @@ int __lxc_start(struct lxc_handler *handler, struct 
lxc_operations *ops,
 
 out_delete_network:
lxc_abort(handler);
+   lxc_restore_phys_nics_to_netns(handler);
lxc_delete_network(handler);
detach_block_device(handler->conf);
lxc_end(handler);
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [lxc/lxc] c4ef8f: tree-wide: use call_cleaner(netns_freeifaddrs)

2020-12-08 Thread Wolfgang Bumiller
  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: c4ef8f4c1103c87144e5dabe051d23b3619179d7
  https://github.com/lxc/lxc/commit/c4ef8f4c1103c87144e5dabe051d23b3619179d7
  Author: Christian Brauner 
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
M src/include/netns_ifaddrs.h
M src/lxc/confile.c
M src/lxc/lxccontainer.c

  Log Message:
  ---
  tree-wide: use call_cleaner(netns_freeifaddrs)

Signed-off-by: Christian Brauner 


  Commit: 059a1ec30bf9a04c296b173b72c143a720176af2
  https://github.com/lxc/lxc/commit/059a1ec30bf9a04c296b173b72c143a720176af2
  Author: Christian Brauner 
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
M src/lxc/confile.c
M src/lxc/utils.c

  Log Message:
  ---
  confile: clean up network configuration parsing

Signed-off-by: Christian Brauner 


  Commit: ed1454e85281cbabe6821b370decaee26b919dc3
  https://github.com/lxc/lxc/commit/ed1454e85281cbabe6821b370decaee26b919dc3
  Author: Christian Brauner 
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
M src/lxc/confile.c

  Log Message:
  ---
  confile: clean up hooks

Signed-off-by: Christian Brauner 


  Commit: 4c9ffb3e663109b767bb16beafe71b0eb6fb52f7
  https://github.com/lxc/lxc/commit/4c9ffb3e663109b767bb16beafe71b0eb6fb52f7
  Author: Wolfgang Bumiller 
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
M src/include/netns_ifaddrs.h
M src/lxc/confile.c
M src/lxc/lxccontainer.c
M src/lxc/utils.c

  Log Message:
  ---
  Merge pull request #3594 from brauner/2020-12-08/fixes

tree-wide: fixes and cleanups


Compare: https://github.com/lxc/lxc/compare/d1042c9dc463...4c9ffb3e6631
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [distrobuilder/master] sources/openwrt: Use fallback image if necessary

2020-12-08 Thread monstermunchkin on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/distrobuilder/pull/381

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From 4eed9c1197d39fb2f054c18425dfd41599c34d53 Mon Sep 17 00:00:00 2001
From: Thomas Hipp 
Date: Tue, 8 Dec 2020 17:46:40 +0100
Subject: [PATCH] sources/openwrt: Use fallback image if necessary

Signed-off-by: Thomas Hipp 
---
 sources/openwrt-http.go | 12 
 1 file changed, 12 insertions(+)

diff --git a/sources/openwrt-http.go b/sources/openwrt-http.go
index 4093f50..d40de2e 100644
--- a/sources/openwrt-http.go
+++ b/sources/openwrt-http.go
@@ -68,6 +68,18 @@ func (s *OpenWrtHTTP) Run(definition shared.Definition, 
rootfsDir string) error
strings.Replace(definition.Image.ArchitectureMapped, 
"_", "-", 1))
}
 
+   resp, err := http.Head(baseURL)
+   if err != nil {
+   return err
+   }
+
+   // Use fallback image "generic"
+   if resp.StatusCode == http.StatusNotFound && 
definition.Image.ArchitectureMapped == "x86_64" {
+   baseURL = strings.ReplaceAll(baseURL, "x86/64", "x86/generic")
+   baseURL = strings.ReplaceAll(baseURL, "x86-64", "x86-generic")
+   fname = strings.ReplaceAll(fname, "x86-64", "x86-generic")
+   }
+
url, err := url.Parse(baseURL)
if err != nil {
return err
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [lxc-ci/master] bin/test-lxd-vm: Adds ceph support and uses random pool name

2020-12-08 Thread tomponline on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc-ci/pull/209

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Depends on https://github.com/lxc/lxd/pull/8225

Signed-off-by: Thomas Parrott 
From f358834e4a7820e12f51d4022abaa6ec86379a0a Mon Sep 17 00:00:00 2001
From: Thomas Parrott 
Date: Tue, 8 Dec 2020 16:30:43 +
Subject: [PATCH] bin/test-lxd-vm: Adds ceph support and uses random pool name

Signed-off-by: Thomas Parrott 
---
 bin/test-lxd-vm | 46 +-
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/bin/test-lxd-vm b/bin/test-lxd-vm
index b02715d..6fe72d1 100755
--- a/bin/test-lxd-vm
+++ b/bin/test-lxd-vm
@@ -12,7 +12,7 @@ cleanup() {
 exit 0
 }
 
-poolDriverList="${1:-dir btrfs lvm zfs}"
+poolDriverList="${1:-dir btrfs lvm zfs ceph}"
 FAIL=1
 trap cleanup EXIT HUP INT TERM
 
@@ -39,17 +39,21 @@ lxd waitready --timeout=300
 lxc network create lxdbr0
 lxc profile device add default eth0 nic network=lxdbr0
 
+poolName="vmpool$$"
+
 for poolDriver in $poolDriverList
 do
 echo "==> Create storage pool using driver ${poolDriver}"
 if [ "${poolDriver}" = "dir" ]; then
-lxc storage create vmpool "${poolDriver}"
+lxc storage create "${poolName}" "${poolDriver}"
+elif [ "${poolDriver}" = "ceph" ]; then
+lxc storage create "${poolName}" "${poolDriver}" 
source="${poolName}"
 else
-lxc storage create vmpool "${poolDriver}" size=20GB
+lxc storage create "${poolName}" "${poolDriver}" size=20GB
 fi
 
 echo "==> Create VM and boot"
-lxc init images:ubuntu/20.04/cloud v1 --vm -s vmpool
+lxc init images:ubuntu/20.04/cloud v1 --vm -s "${poolName}"
 lxc start v1
 sleep 60
 lxc info v1
@@ -74,8 +78,8 @@ do
 lxc delete -f v1
 
 echo "==> Change volume.size on pool and create VM"
-lxc storage set vmpool volume.size 6GB
-lxc init images:ubuntu/20.04/cloud v1 --vm -s vmpool
+lxc storage set "${poolName}" volume.size 6GB
+lxc init images:ubuntu/20.04/cloud v1 --vm -s "${poolName}"
 lxc start v1
 sleep 60
 lxc info v1
@@ -85,12 +89,12 @@ do
 
 echo "==> Deleting VM and reset pool volume.size"
 lxc delete -f v1
-lxc storage unset vmpool volume.size
+lxc storage unset "${poolName}" volume.size
 
 if [ "${poolDriver}" = "lvm" ]; then
 echo "==> Change volume.block.filesystem on pool and create VM"
-lxc storage set vmpool volume.block.filesystem xfs
-lxc init images:ubuntu/20.04/cloud v1 --vm -s vmpool
+lxc storage set "${poolName}" volume.block.filesystem xfs
+lxc init images:ubuntu/20.04/cloud v1 --vm -s "${poolName}"
 lxc start v1
 sleep 60
 lxc info v1
@@ -101,12 +105,12 @@ do
 
 echo "==> Deleting VM"
 lxc delete -f v1
-lxc storage unset vmpool volume.block.filesystem
+lxc storage unset "${poolName}" volume.block.filesystem
 fi
 
 echo "==> Create VM from profile with small disk size"
 lxc profile copy default vmsmall
-lxc profile device add vmsmall root disk pool=vmpool path=/ size=7GB
+lxc profile device add vmsmall root disk pool="${poolName}" path=/ 
size=7GB
 lxc init images:ubuntu/20.04/cloud v1 --vm -p vmsmall
 lxc start v1
 sleep 60
@@ -122,8 +126,8 @@ do
 dstPoolDriver=lvm # Use something different when testing ZFS.
 fi
 
-lxc storage create vmpool2 "${dstPoolDriver}" size=20GB
-lxc copy v1 v2 -s vmpool2
+lxc storage create "${poolName}"2 "${dstPoolDriver}" size=20GB
+lxc copy v1 v2 -s "${poolName}"2
 lxc start v2
 sleep 60
 lxc info v2
@@ -132,9 +136,9 @@ do
 lxc exec v2 -- df -B10 | grep sda2 | grep 7
 lxc delete -f v2
 
-echo "==> Grow above default voume size and copy to different storage 
pool"
+echo "==> Grow above default volume size and copy to different storage 
pool"
 lxc config device override v1 root size=11GB
-lxc copy v1 v2 -s vmpool2
+lxc copy v1 v2 -s "${poolName}"2
 lxc start v2
 sleep 60
 lxc info v2
@@ -146,14 +150,14 @@ do
 echo "==> Publishing larger VM"
 lxc publish v1 --alias vmbig
 lxc delete -f v1
-lxc storage set vmpool volume.size 9GB
+lxc storage set "${poolName}" volume.size 9GB
 
 echo "==> Check VM create fails when image larger than volume.size"
-! lxc init vmbig v1 --vm -s vmpool || false
+

[lxc-devel] [lxc-ci/master] images/centos: Fix CentOS Plus repo location

2020-12-08 Thread monstermunchkin on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc-ci/pull/208

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From e7a505c596a58b02890c724b05b2d6409abb44c1 Mon Sep 17 00:00:00 2001
From: Thomas Hipp 
Date: Tue, 8 Dec 2020 16:56:05 +0100
Subject: [PATCH] images/centos: Fix CentOS Plus repo location

Signed-off-by: Thomas Hipp 
---
 images/centos.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/images/centos.yaml b/images/centos.yaml
index ce4bfef..c098a1b 100644
--- a/images/centos.yaml
+++ b/images/centos.yaml
@@ -585,7 +585,7 @@ actions:
 set -eux
 
 # Enable the centosplus repo which has a kernel with 9p support
-sed -i 's/^enabled=0/enabled=1/' /etc/yum.repos.d/CentOS-centosplus.repo
+sed -i 's/^enabled=0/enabled=1/' /etc/yum.repos.d/CentOS-Linux-Plus.repo
   types:
   - vm
   releases:
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [lxc-ci/master] Remove CentOS 6 (EOL)

2020-12-08 Thread monstermunchkin on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc-ci/pull/207

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From 03fa639a708dde4ed6479ebb0c917ed65c02c2e1 Mon Sep 17 00:00:00 2001
From: Thomas Hipp 
Date: Tue, 8 Dec 2020 16:21:13 +0100
Subject: [PATCH 1/2] jenkins/jobs: Drop CentOS 6 (EOL)

Signed-off-by: Thomas Hipp 
---
 jenkins/jobs/image-centos.yaml | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/jenkins/jobs/image-centos.yaml b/jenkins/jobs/image-centos.yaml
index 607e4d2..e711ad0 100644
--- a/jenkins/jobs/image-centos.yaml
+++ b/jenkins/jobs/image-centos.yaml
@@ -20,7 +20,6 @@
 name: release
 type: user-defined
 values:
-- 6
 - 7
 - 8
 - 8-Stream
@@ -53,7 +52,7 @@
 fi
 
 TYPE="container"
-if [ "${architecture}" = "amd64" ] && [ "${release}" != "6" ]; then
+if [ "${architecture}" = "amd64" ]; then
 TYPE="container,vm"
 fi
 
@@ -64,13 +63,11 @@
 
 execution-strategy:
   combination-filter: '
-  !(architecture=="arm64" && release == "6")
-  && !(architecture=="arm64" && release == "7")
+  !(architecture=="arm64" && release == "7")
   && !(architecture=="ppc64el" && release == "7")
   && !(architecture=="armhf" && release != "7")
   && !(architecture=="i386" && release == "8")
-  && !(architecture=="i386" && release == "8-Stream")
-  && !(architecture=="ppc64el" && release == "6")'
+  && !(architecture=="i386" && release == "8-Stream")'
 
 properties:
 - build-discarder:

From 24b0966efec24ca3990bc4f6479ef4ace38f9bfe Mon Sep 17 00:00:00 2001
From: Thomas Hipp 
Date: Tue, 8 Dec 2020 16:22:39 +0100
Subject: [PATCH 2/2] images: Remove CentOS 6 references

Signed-off-by: Thomas Hipp 
---
 images/centos.yaml | 37 -
 1 file changed, 37 deletions(-)

diff --git a/images/centos.yaml b/images/centos.yaml
index ce4bfef..8d4bc61 100644
--- a/images/centos.yaml
+++ b/images/centos.yaml
@@ -259,7 +259,6 @@ files:
 MTU=
 DHCP_HOSTNAME=LXC_NAME
   releases:
-  - 6
   - 7
   types:
   - container
@@ -295,7 +294,6 @@ files:
 MTU=
 DHCP_HOSTNAME={{ container.name }}
   releases:
-  - 6
   - 7
 
 - name: ifcfg-eth0.lxd
@@ -416,41 +414,6 @@ files:
 NETWORKING=yes
 HOSTNAME={{ container.name }}
 
-- name: lxc-sysinit
-  path: /etc/init/lxc-sysinit.conf
-  generator: dump
-  content: |-
-start on startup
-env container
-
-pre-start script
-if [ "x$container" != "xlxc" -a "x$container" != "xlibvirt" ]; then
-stop;
-fi
-
-rm -f /var/lock/subsys/*
-rm -f /var/run/*.pid
-[ -e /etc/mtab ] || ln -s /proc/mounts /etc/mtab
-mkdir -p /dev/shm
-mount -t tmpfs -o nosuid,nodev tmpfs /dev/shm
-
-initctl start tty TTY=console
-telinit 3
-exit 0
-end script
-  releases:
-  - 6
-
-- name: sigpwr.conf
-  path: /etc/init/power-status-changed.conf
-  generator: dump
-  content: |-
-start on power-status-changed
-
-exec /sbin/shutdown -h now "SIGPWR received"
-  releases:
-  - 6
-
 - name: meta-data
   generator: cloud-init
   variants:
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


[lxc-devel] [lxc/master] tree-wide: fixes

2020-12-08 Thread brauner on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3595

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner 
From 62af653cc125c90997b48179fbcff7e0fe6317b6 Mon Sep 17 00:00:00 2001
From: Christian Brauner 
Date: Tue, 8 Dec 2020 14:34:06 +0100
Subject: [PATCH 01/25] confile: cleanup set_config_personality()

Signed-off-by: Christian Brauner 
---
 src/lxc/confile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index e7ab359291..e7f9df3c49 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1242,8 +1242,9 @@ static int set_config_hooks_version(const char *key, 
const char *value,
 static int set_config_personality(const char *key, const char *value,
  struct lxc_conf *lxc_conf, void *data)
 {
-   signed long personality = lxc_config_parse_arch(value);
+   signed long personality;
 
+   personality = lxc_config_parse_arch(value);
if (personality >= 0)
lxc_conf->personality = personality;
else

From 49aabd9d60e3879254ac6601a2fadb268259cc7e Mon Sep 17 00:00:00 2001
From: Christian Brauner 
Date: Tue, 8 Dec 2020 14:36:17 +0100
Subject: [PATCH 02/25] confile: cleanup set_config_pty_max()

Signed-off-by: Christian Brauner 
---
 src/lxc/confile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index e7f9df3c49..412d1045bc 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1266,7 +1266,7 @@ static int set_config_pty_max(const char *key, const char 
*value,
 
ret = lxc_safe_uint(value, &max);
if (ret < 0)
-   return -1;
+   return ret_errno(EINVAL);
 
lxc_conf->pty_max = max;
 

From 572f6a14705f2e1a187cc50f40e825a774cf5de1 Mon Sep 17 00:00:00 2001
From: Christian Brauner 
Date: Tue, 8 Dec 2020 14:38:16 +0100
Subject: [PATCH 03/25] confile: cleanup set_config_start()

Signed-off-by: Christian Brauner 
---
 src/lxc/confile.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 412d1045bc..38416e840c 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1281,6 +1281,7 @@ static int set_config_pty_max(const char *key, const char 
*value,
 static int set_config_start(const char *key, const char *value,
struct lxc_conf *lxc_conf, void *data)
 {
+   int ret;
bool is_empty;
 
is_empty = lxc_config_value_empty(value);
@@ -1291,11 +1292,12 @@ static int set_config_start(const char *key, const char 
*value,
return 0;
}
 
-   if (lxc_safe_uint(value, &lxc_conf->start_auto) < 0)
-   return -1;
+   ret = lxc_safe_uint(value, &lxc_conf->start_auto);
+   if (ret)
+   return ret;
 
if (lxc_conf->start_auto > 1)
-   return -1;
+   return ret_errno(EINVAL);
 
return 0;
} else if (*(key + 10) == 'd') { /* lxc.start.delay */
@@ -1314,7 +1316,7 @@ static int set_config_start(const char *key, const char 
*value,
return lxc_safe_int(value, &lxc_conf->start_order);
}
 
-   return -1;
+   return ret_errno(EINVAL);
 }
 
 static int set_config_monitor(const char *key, const char *value,

From e16659731606d7f2ef9debe62dd872cbc403eb75 Mon Sep 17 00:00:00 2001
From: Christian Brauner 
Date: Tue, 8 Dec 2020 14:38:57 +0100
Subject: [PATCH 04/25] confile: cleanup set_config_monitor()

Signed-off-by: Christian Brauner 
---
 src/lxc/confile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 38416e840c..6bf8143606 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1330,7 +1330,7 @@ static int set_config_monitor(const char *key, const char 
*value,
if (strcmp(key + 12, "unshare") == 0)
return lxc_safe_uint(value, &lxc_conf->monitor_unshare);
 
-   return -1;
+   return ret_errno(EINVAL);
 }
 
 static int set_config_monitor_signal_pdeath(const char *key, const char *value,

From cb5f3df2588ecf3c34716c6cac49dbfcaf6a83ff Mon Sep 17 00:00:00 2001
From: Christian Brauner 
Date: Tue, 8 Dec 2020 14:39:49 +0100
Subject: [PATCH 05/25] confile: cleanup set_config_monitor_signal_pdeath()

Signed-off-by: Christian Brauner 
---
 src/lxc/confile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 6bf8143606..4d1acc1fb1 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -1346,13 +1346,13 @@ static int set_config_monitor_signal_pdeath(const char 
*key, const char *value,
 
  

[lxc-devel] [lxd/master] Storage: ZFS rounding up

2020-12-08 Thread tomponline on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/8225

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Fixes issue when copying from ceph to zfs pools, the zfs volumes were being rounded to the nearest 8192 bytes, which sometimes meant the volume size created was just too small to accommodate the source ceph volume (which doesn't round to nearest 8192 bytes).

This modifies the ZFS volumes to round up to nearest 8192 bytes.

From 23835ab8cc0a8b7334fff5a185b97e67a5920f86 Mon Sep 17 00:00:00 2001
From: Thomas Parrott 
Date: Tue, 8 Dec 2020 12:56:13 +
Subject: [PATCH 1/8] lxd/storage/drivers/utils: Modifies
 roundVolumeBlockFileSizeBytes to round up

Ensures that the returned bytes is always greater than or equal to the input 
bytes.

Signed-off-by: Thomas Parrott 
---
 lxd/storage/drivers/utils.go | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go
index a64635bbc2..3a216852c7 100644
--- a/lxd/storage/drivers/utils.go
+++ b/lxd/storage/drivers/utils.go
@@ -310,16 +310,24 @@ func ensureSparseFile(filePath string, sizeBytes int64) 
error {
return nil
 }
 
-// roundVolumeBlockFileSizeBytes parses the supplied size string and then 
rounds it to the nearest 8k bytes.
-func roundVolumeBlockFileSizeBytes(sizeBytes int64) (int64, error) {
+// roundVolumeBlockFileSizeBytes parses the supplied size string and then 
rounds it to the nearest multiple of
+// MinBlockBoundary bytes that is equal to or larger than sizeBytes.
+func roundVolumeBlockFileSizeBytes(sizeBytes int64) int64 {
// Qemu requires image files to be in traditional storage block 
boundaries.
// We use 8k here to ensure our images are compatible with all of our 
backend drivers.
if sizeBytes < MinBlockBoundary {
sizeBytes = MinBlockBoundary
}
 
+   roundedSizeBytes := int64(sizeBytes/MinBlockBoundary) * MinBlockBoundary
+
+   // Ensure the rounded size is at least the size specified in sizeBytes.
+   if roundedSizeBytes < sizeBytes {
+   roundedSizeBytes += MinBlockBoundary
+   }
+
// Round the size to closest MinBlockBoundary bytes to avoid qemu 
boundary issues.
-   return int64(sizeBytes/MinBlockBoundary) * MinBlockBoundary, nil
+   return roundedSizeBytes
 }
 
 // ensureVolumeBlockFile creates new block file or enlarges the raw block file 
for a volume to the specified size.

From f1a1b13c5acbd16969c5f3186d1c7cc74e2d3636 Mon Sep 17 00:00:00 2001
From: Thomas Parrott 
Date: Tue, 8 Dec 2020 12:56:55 +
Subject: [PATCH 2/8] lxd/storage/drivers/utils: roundVolumeBlockFileSizeBytes
 usage

Signed-off-by: Thomas Parrott 
---
 lxd/storage/drivers/utils.go | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lxd/storage/drivers/utils.go b/lxd/storage/drivers/utils.go
index 3a216852c7..b922e12160 100644
--- a/lxd/storage/drivers/utils.go
+++ b/lxd/storage/drivers/utils.go
@@ -339,10 +339,7 @@ func ensureVolumeBlockFile(vol Volume, path string, 
sizeBytes int64) (bool, erro
}
 
// Get rounded block size to avoid qemu boundary issues.
-   sizeBytes, err := roundVolumeBlockFileSizeBytes(sizeBytes)
-   if err != nil {
-   return false, err
-   }
+   sizeBytes = roundVolumeBlockFileSizeBytes(sizeBytes)
 
if shared.PathExists(path) {
fi, err := os.Stat(path)
@@ -384,7 +381,7 @@ func ensureVolumeBlockFile(vol Volume, path string, 
sizeBytes int64) (bool, erro
 
// If path doesn't exist, then there has been no filler function 
supplied to create it from another source.
// So instead create an empty volume (use for PXE booting a VM).
-   err = ensureSparseFile(path, sizeBytes)
+   err := ensureSparseFile(path, sizeBytes)
if err != nil {
return false, errors.Wrapf(err, "Failed creating disk image %q 
as size %d", path, sizeBytes)
}

From 8e7d36e48fa423424b37e5b08fb31f0025ac47f3 Mon Sep 17 00:00:00 2001
From: Thomas Parrott 
Date: Tue, 8 Dec 2020 12:57:16 +
Subject: [PATCH 3/8] lxd/storage/drivers/driver/zfs/utils: Use
 roundVolumeBlockFileSizeBytes in createVolume

Signed-off-by: Thomas Parrott 
---
 lxd/storage/drivers/driver_zfs_utils.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lxd/storage/drivers/driver_zfs_utils.go 
b/lxd/storage/drivers/driver_zfs_utils.go
index 13e59cb80f..555a71b7ab 100644
--- a/lxd/storage/drivers/driver_zfs_utils.go
+++ b/lxd/storage/drivers/driver_zfs_utils.go
@@ -55,7 +55,7 @@ func (d *zfs) createDataset(dataset string, options 
...string) error {
 }
 
 func (d *zfs) createVolume(dataset string, size int64, options ...string) 
error {
-   size = (size / MinBlockBoundary) * Min

[lxc-devel] [lxc/master] tree-wide: fixes and cleanups

2020-12-08 Thread brauner on Github
The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/3594

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner 
From c4ef8f4c1103c87144e5dabe051d23b3619179d7 Mon Sep 17 00:00:00 2001
From: Christian Brauner 
Date: Tue, 8 Dec 2020 11:53:54 +0100
Subject: [PATCH 1/3] tree-wide: use call_cleaner(netns_freeifaddrs)

Signed-off-by: Christian Brauner 
---
 src/include/netns_ifaddrs.h |  3 +-
 src/lxc/confile.c   | 12 +++
 src/lxc/lxccontainer.c  | 72 +
 3 files changed, 38 insertions(+), 49 deletions(-)

diff --git a/src/include/netns_ifaddrs.h b/src/include/netns_ifaddrs.h
index 1b8703ee7d..d3f1d6eef8 100644
--- a/src/include/netns_ifaddrs.h
+++ b/src/include/netns_ifaddrs.h
@@ -13,7 +13,7 @@ extern "C" {
 #include 
 
 #include "compiler.h"
-#include "netns_ifaddrs.h"
+#include "memory_utils.h"
 
 struct netns_ifaddrs {
struct netns_ifaddrs *ifa_next;
@@ -52,6 +52,7 @@ struct netns_ifaddrs {
 #define __ifa_dstaddr ifa_ifu.ifu_dstaddr
 
 __hidden extern void netns_freeifaddrs(struct netns_ifaddrs *);
+define_cleanup_function(struct netns_ifaddrs *, netns_freeifaddrs);
 __hidden extern int netns_getifaddrs(struct netns_ifaddrs **ifap, __s32 
netns_id,
 bool *netnsid_aware);
 
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 4f7621a900..6f5bf3909b 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -377,17 +377,16 @@ static int set_config_net_flags(const char *key, const 
char *value,
 static int create_matched_ifnames(const char *value, struct lxc_conf *lxc_conf,
  struct lxc_netdev *netdev)
 {
-   struct netns_ifaddrs *ifaddr, *ifa;
+   call_cleaner(netns_freeifaddrs) struct netns_ifaddrs *ifaddr = NULL;
+   struct netns_ifaddrs *ifa;
int n;
int ret = 0;
const char *type_key = "lxc.net.type";
const char *link_key = "lxc.net.link";
const char *tmpvalue = "phys";
 
-   if (netns_getifaddrs(&ifaddr, -1, &(bool){false}) < 0) {
-   SYSERROR("Failed to get network interfaces");
-   return -1;
-   }
+   if (netns_getifaddrs(&ifaddr, -1, &(bool){false}) < 0)
+   return log_error_errno(-1, errno, "Failed to get network 
interfaces");
 
for (ifa = ifaddr, n = 0; ifa != NULL; ifa = ifa->ifa_next, n++) {
if (!ifa->ifa_addr)
@@ -413,9 +412,6 @@ static int create_matched_ifnames(const char *value, struct 
lxc_conf *lxc_conf,
}
}
 
-   netns_freeifaddrs(ifaddr);
-   ifaddr = NULL;
-
return ret;
 }
 
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 96aa372e1d..da18be8aa1 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -2340,20 +2340,21 @@ static char **do_lxcapi_get_interfaces(struct 
lxc_container *c)
char **interfaces = NULL;
char interface[IFNAMSIZ];
 
-   if (pipe2(pipefd, O_CLOEXEC) < 0)
-   return NULL;
+   if (pipe2(pipefd, O_CLOEXEC))
+   return log_error_errno(NULL, errno, "Failed to create pipe");
 
pid = fork();
if (pid < 0) {
-   SYSERROR("Failed to fork task to get interfaces information");
close(pipefd[0]);
close(pipefd[1]);
-   return NULL;
+   return log_error_errno(NULL, errno, "Failed to fork task to get 
interfaces information");
}
 
-   if (pid == 0) { /* child */
-   int ret = 1, nbytes;
-   struct netns_ifaddrs *interfaceArray = NULL, *tempIfAddr = NULL;
+   if (pid == 0) {
+   call_cleaner(netns_freeifaddrs) struct netns_ifaddrs *ifaddrs = 
NULL;
+   struct netns_ifaddrs *ifa = NULL;
+   int ret = 1;
+   int nbytes;
 
/* close the read-end of the pipe */
close(pipefd[0]);
@@ -2364,15 +2365,15 @@ static char **do_lxcapi_get_interfaces(struct 
lxc_container *c)
}
 
/* Grab the list of interfaces */
-   if (netns_getifaddrs(&interfaceArray, -1, &(bool){false})) {
+   if (netns_getifaddrs(&ifaddrs, -1, &(bool){false})) {
SYSERROR("Failed to get interfaces list");
goto out;
}
 
/* Iterate through the interfaces */
-   for (tempIfAddr = interfaceArray; tempIfAddr != NULL;
-tempIfAddr = tempIfAddr->ifa_next) {
-   nbytes = lxc_write_nointr(pipefd[1], 
tempIfAddr->ifa_name, IFNAMSIZ);
+   for (ifa = ifaddrs; ifa != NULL;
+ifa = ifa->ifa_next) {
+   nbytes = lxc_write_nointr(p