[pve-devel] [PATCH lxc] pull in the -f option branch
Wolfgang Bumiller
w.bumiller at proxmox.com
Fri Aug 12 15:11:32 CEST 2016
These changes are to get dab/aab/... working again (which
also need to be adapted to pass along `-f` to all lxc
calls).
---
Upstream pull request #1122
=> https://github.com/lxc/lxc/pull/1122
.../patches/0001-add-f-option-to-lxc-attach.patch | 68 ++++
...ls-move-rcfile-to-the-common-options-list.patch | 416 +++++++++++++++++++++
...02-tools-set-configfile-after-load_config.patch | 228 +++++++++++
debian/patches/series | 3 +
4 files changed, 715 insertions(+)
create mode 100644 debian/patches/0001-add-f-option-to-lxc-attach.patch
create mode 100644 debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch
create mode 100644 debian/patches/0002-tools-set-configfile-after-load_config.patch
diff --git a/debian/patches/0001-add-f-option-to-lxc-attach.patch b/debian/patches/0001-add-f-option-to-lxc-attach.patch
new file mode 100644
index 0000000..9bedc08
--- /dev/null
+++ b/debian/patches/0001-add-f-option-to-lxc-attach.patch
@@ -0,0 +1,68 @@
+From a7ae6ce4e505882859a1c3683c4600e0d8400d64 Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller at proxmox.com>
+Date: Thu, 4 Aug 2016 11:23:54 +0200
+Subject: [PATCH] add -f option to lxc-attach
+
+Otherwise a container with a non-standard configuration file
+can be started but not attached to.
+Fixes the following case:
+ # lxc-start -n ct -f /different/path/my.config
+ # lxc-attach -n ct
+ Error: container ct is not defined
+
+Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
+---
+ src/lxc/lxc_attach.c | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/src/lxc/lxc_attach.c b/src/lxc/lxc_attach.c
+index 58f658b..7116885 100644
+--- a/src/lxc/lxc_attach.c
++++ b/src/lxc/lxc_attach.c
+@@ -65,6 +65,7 @@ static const struct option my_longopts[] = {
+ {"keep-var", required_argument, 0, 502},
+ {"set-var", required_argument, 0, 'v'},
+ {"pty-log", required_argument, 0, 'L'},
++ {"rcfile", required_argument, 0, 'f'},
+ LXC_COMMON_OPTIONS
+ };
+
+@@ -153,6 +154,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
+ case 'L':
+ args->console_log = arg;
+ break;
++ case 'f': args->rcfile = arg; break;
+ }
+
+ return 0;
+@@ -202,7 +204,10 @@ Options :\n\
+ multiple times.\n\
+ --keep-var Keep an additional environment variable. Only\n\
+ applicable if --clear-env is specified. May be used\n\
+- multiple times.\n",
++ multiple times.\n\
++ -f, --rcfile=FILE\n\
++ Load configuration file FILE\n\
++",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = NULL,
+@@ -373,6 +378,15 @@ int main(int argc, char *argv[])
+ if (!c)
+ exit(EXIT_FAILURE);
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ ERROR("Failed to load rcfile");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
++ }
++
+ if (!c->may_control(c)) {
+ fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
+ lxc_container_put(c);
+--
+2.1.4
+
diff --git a/debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch b/debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch
new file mode 100644
index 0000000..91c6c67
--- /dev/null
+++ b/debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch
@@ -0,0 +1,416 @@
+From b4e38890b70cc11afd325f128c2d7fff8b276434 Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller at proxmox.com>
+Date: Fri, 12 Aug 2016 12:21:22 +0200
+Subject: [PATCH 1/6] tools: move --rcfile to the common options list
+
+In almost all commands it's a useful addition to the -n
+switch which is a common option, too.
+
+Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
+---
+ src/lxc/arguments.c | 1 +
+ src/lxc/arguments.h | 1 +
+ src/lxc/lxc_attach.c | 2 --
+ src/lxc/lxc_cgroup.c | 12 +++++++++++-
+ src/lxc/lxc_checkpoint.c | 10 ++++++++++
+ src/lxc/lxc_console.c | 12 +++++++++++-
+ src/lxc/lxc_copy.c | 3 ++-
+ src/lxc/lxc_destroy.c | 13 ++++++++++++-
+ src/lxc/lxc_device.c | 11 ++++++++++-
+ src/lxc/lxc_freeze.c | 12 +++++++++++-
+ src/lxc/lxc_info.c | 12 +++++++++++-
+ src/lxc/lxc_snapshot.c | 12 +++++++++++-
+ src/lxc/lxc_stop.c | 12 +++++++++++-
+ src/lxc/lxc_unfreeze.c | 12 +++++++++++-
+ src/lxc/lxc_wait.c | 12 +++++++++++-
+ 15 files changed, 124 insertions(+), 13 deletions(-)
+
+diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c
+index c2f7b67..dd6bcfe 100644
+--- a/src/lxc/arguments.c
++++ b/src/lxc/arguments.c
+@@ -200,6 +200,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
+ break;
+ switch (c) {
+ case 'n': args->name = optarg; break;
++ case 'f': args->rcfile = optarg; break;
+ case 'o': args->log_file = optarg; break;
+ case 'l': args->log_priority = optarg; break;
+ case 'q': args->quiet = 1; break;
+diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h
+index f68f8ab..bdb2f5c 100644
+--- a/src/lxc/arguments.h
++++ b/src/lxc/arguments.h
+@@ -151,6 +151,7 @@ struct lxc_arguments {
+ {"logfile", required_argument, 0, 'o'}, \
+ {"logpriority", required_argument, 0, 'l'}, \
+ {"lxcpath", required_argument, 0, 'P'}, \
++ {"rcfile", required_argument, 0, 'f'}, \
+ {0, 0, 0, 0}
+
+ /* option keys for long only options */
+diff --git a/src/lxc/lxc_attach.c b/src/lxc/lxc_attach.c
+index 281f97a..8d39b35 100644
+--- a/src/lxc/lxc_attach.c
++++ b/src/lxc/lxc_attach.c
+@@ -65,7 +65,6 @@ static const struct option my_longopts[] = {
+ {"keep-var", required_argument, 0, 502},
+ {"set-var", required_argument, 0, 'v'},
+ {"pty-log", required_argument, 0, 'L'},
+- {"rcfile", required_argument, 0, 'f'},
+ LXC_COMMON_OPTIONS
+ };
+
+@@ -154,7 +153,6 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg)
+ case 'L':
+ args->console_log = arg;
+ break;
+- case 'f': args->rcfile = arg; break;
+ }
+
+ return 0;
+diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
+index dd60fd1..f623e0b 100644
+--- a/src/lxc/lxc_cgroup.c
++++ b/src/lxc/lxc_cgroup.c
+@@ -56,7 +56,8 @@ Get or set the value of a state object (for example, 'cpuset.cpus')\n\
+ in the container's cgroup for the corresponding subsystem.\n\
+ \n\
+ Options :\n\
+- -n, --name=NAME NAME of the container",
++ -n, --name=NAME NAME of the container\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = NULL,
+ .checker = my_checker,
+@@ -84,6 +85,15 @@ int main(int argc, char *argv[])
+ if (!c)
+ return 1;
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ ERROR("Failed to load rcfile");
++ lxc_container_put(c);
++ return 1;
++ }
++ }
++
+ if (!c->may_control(c)) {
+ ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
+ lxc_container_put(c);
+diff --git a/src/lxc/lxc_checkpoint.c b/src/lxc/lxc_checkpoint.c
+index 7130245..58886b6 100644
+--- a/src/lxc/lxc_checkpoint.c
++++ b/src/lxc/lxc_checkpoint.c
+@@ -114,6 +114,7 @@ Options :\n\
+ Restore options:\n\
+ -d, --daemon Daemonize the container (default)\n\
+ -F, --foreground Start with the current tty attached to /dev/console\n\
++ -f, --rcfile=FILE Load configuration file FILE\n\
+ ",
+ .options = my_longopts,
+ .parser = my_parser,
+@@ -214,6 +215,15 @@ int main(int argc, char *argv[])
+ exit(1);
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ lxc_container_put(c);
++ exit(1);
++ }
++ }
++
+ if (!c->may_control(c)) {
+ fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
+ lxc_container_put(c);
+diff --git a/src/lxc/lxc_console.c b/src/lxc/lxc_console.c
+index adbd7e0..d80462c 100644
+--- a/src/lxc/lxc_console.c
++++ b/src/lxc/lxc_console.c
+@@ -80,7 +80,8 @@ lxc-console logs on the container with the identifier NAME\n\
+ Options :\n\
+ -n, --name=NAME NAME of the container\n\
+ -t, --tty=NUMBER console tty number\n\
+- -e, --escape=PREFIX prefix for escape command\n",
++ -e, --escape=PREFIX prefix for escape command\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = NULL,
+@@ -112,6 +113,15 @@ int main(int argc, char *argv[])
+ exit(EXIT_FAILURE);
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
++ }
++
+ if (!c->may_control(c)) {
+ fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
+ lxc_container_put(c);
+diff --git a/src/lxc/lxc_copy.c b/src/lxc/lxc_copy.c
+index 9f653e3..8deba80 100644
+--- a/src/lxc/lxc_copy.c
++++ b/src/lxc/lxc_copy.c
+@@ -126,7 +126,8 @@ Options :\n\
+ -D, --keedata pass together with -e start a persistent snapshot \n\
+ -K, --keepname keep the hostname of the original container\n\
+ -- hook options arguments passed to the hook program\n\
+- -M, --keepmac keep the MAC address of the original container\n",
++ -M, --keepmac keep the MAC address of the original container\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = my_parser,
+ .task = CLONE,
+diff --git a/src/lxc/lxc_destroy.c b/src/lxc/lxc_destroy.c
+index b521739..d9738dd 100644
+--- a/src/lxc/lxc_destroy.c
++++ b/src/lxc/lxc_destroy.c
+@@ -53,7 +53,9 @@ lxc-destroy destroys a container with the identifier NAME\n\
+ Options :\n\
+ -n, --name=NAME NAME of the container\n\
+ -s, --snapshots destroy including all snapshots\n\
+- -f, --force wait for the container to shut down\n",
++ -f, --force wait for the container to shut down\n\
++ -f, --rcfile=FILE\n\
++ Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = NULL,
+@@ -88,6 +90,15 @@ int main(int argc, char *argv[])
+ exit(EXIT_FAILURE);
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
++ }
++
+ if (!c->may_control(c)) {
+ if (!quiet)
+ fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
+diff --git a/src/lxc/lxc_device.c b/src/lxc/lxc_device.c
+index 0c9e066..8e54668 100644
+--- a/src/lxc/lxc_device.c
++++ b/src/lxc/lxc_device.c
+@@ -53,7 +53,8 @@ static struct lxc_arguments my_args = {
+ lxc-device attach or detach DEV to or from container.\n\
+ \n\
+ Options :\n\
+- -n, --name=NAME NAME of the container",
++ -n, --name=NAME NAME of the container\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = NULL,
+ .checker = NULL,
+@@ -125,6 +126,14 @@ int main(int argc, char *argv[])
+ goto err;
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ ERROR("Failed to load rcfile");
++ goto err1;
++ }
++ }
++
+ if (!c->is_running(c)) {
+ ERROR("Container %s is not running.", c->name);
+ goto err1;
+diff --git a/src/lxc/lxc_freeze.c b/src/lxc/lxc_freeze.c
+index ea8bd3e..4d1864d 100644
+--- a/src/lxc/lxc_freeze.c
++++ b/src/lxc/lxc_freeze.c
+@@ -47,7 +47,8 @@ static struct lxc_arguments my_args = {
+ lxc-freeze freezes a container with the identifier NAME\n\
+ \n\
+ Options :\n\
+- -n, --name=NAME NAME of the container",
++ -n, --name=NAME NAME of the container\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = NULL,
+ .checker = NULL,
+@@ -74,6 +75,15 @@ int main(int argc, char *argv[])
+ exit(1);
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ ERROR("Failed to load rcfile");
++ lxc_container_put(c);
++ exit(1);
++ }
++ }
++
+ if (!c->may_control(c)) {
+ ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
+ lxc_container_put(c);
+diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
+index 58ff619..6a63457 100644
+--- a/src/lxc/lxc_info.c
++++ b/src/lxc/lxc_info.c
+@@ -93,7 +93,8 @@ Options :\n\
+ -p, --pid shows the process id of the init container\n\
+ -S, --stats shows usage stats\n\
+ -H, --no-humanize shows stats as raw numbers, not humanized\n\
+- -s, --state shows the state of the container\n",
++ -s, --state shows the state of the container\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .name = NULL,
+ .options = my_longopts,
+ .parser = my_parser,
+@@ -295,6 +296,15 @@ static int print_info(const char *name, const char *lxcpath)
+ return -1;
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ lxc_container_put(c);
++ return -1;
++ }
++ }
++
+ if (!c->may_control(c)) {
+ fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
+ lxc_container_put(c);
+diff --git a/src/lxc/lxc_snapshot.c b/src/lxc/lxc_snapshot.c
+index 8f44891..3b17b23 100644
+--- a/src/lxc/lxc_snapshot.c
++++ b/src/lxc/lxc_snapshot.c
+@@ -62,7 +62,8 @@ Options :\n\
+ -d, --destroy=NAME destroy snapshot NAME, e.g. 'snap0'\n\
+ use ALL to destroy all snapshots\n\
+ -c, --comment=FILE add FILE as a comment\n\
+- -C, --showcomments show snapshot comments\n",
++ -C, --showcomments show snapshot comments\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = NULL,
+@@ -107,6 +108,15 @@ int main(int argc, char *argv[])
+ exit(EXIT_FAILURE);
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
++ }
++
+ if (!c->may_control(c)) {
+ fprintf(stderr, "Insufficent privileges to control %s\n",
+ my_args.name);
+diff --git a/src/lxc/lxc_stop.c b/src/lxc/lxc_stop.c
+index 10ddce6..6502aa3 100644
+--- a/src/lxc/lxc_stop.c
++++ b/src/lxc/lxc_stop.c
+@@ -75,7 +75,9 @@ Options :\n\
+ -t, --timeout=T wait T seconds before hard-stopping\n\
+ -k, --kill kill container rather than request clean shutdown\n\
+ --nolock Avoid using API locks\n\
+- --nokill Only request clean shutdown, don't force kill after timeout\n",
++ --nokill Only request clean shutdown, don't force kill after timeout\n\
++ -f, --rcfile=FILE\n\
++ Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = NULL,
+@@ -203,6 +205,14 @@ int main(int argc, char *argv[])
+ goto out;
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ goto out;
++ }
++ }
++
+ if (!c->may_control(c)) {
+ fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
+ goto out;
+diff --git a/src/lxc/lxc_unfreeze.c b/src/lxc/lxc_unfreeze.c
+index 3a13d37..e2e9b4b 100644
+--- a/src/lxc/lxc_unfreeze.c
++++ b/src/lxc/lxc_unfreeze.c
+@@ -45,7 +45,8 @@ static struct lxc_arguments my_args = {
+ lxc-unfreeze unfreezes a container with the identifier NAME\n\
+ \n\
+ Options :\n\
+- -n, --name=NAME NAME of the container\n",
++ -n, --name=NAME NAME of the container\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = NULL,
+ .checker = NULL,
+@@ -78,6 +79,15 @@ int main(int argc, char *argv[])
+ exit(1);
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ ERROR("Failed to load rcfile");
++ lxc_container_put(c);
++ exit(1);
++ }
++ }
++
+ if (!c->unfreeze(c)) {
+ ERROR("Failed to unfreeze %s:%s", my_args.lxcpath[0], my_args.name);
+ lxc_container_put(c);
+diff --git a/src/lxc/lxc_wait.c b/src/lxc/lxc_wait.c
+index 712ba52..ee61a32 100644
+--- a/src/lxc/lxc_wait.c
++++ b/src/lxc/lxc_wait.c
+@@ -72,7 +72,8 @@ Options :\n\
+ -s, --state=STATE ORed states to wait for\n\
+ STOPPED, STARTING, RUNNING, STOPPING,\n\
+ ABORTING, FREEZING, FROZEN, THAWED\n\
+- -t, --timeout=TMO Seconds to wait for state changes\n",
++ -t, --timeout=TMO Seconds to wait for state changes\n\
++ -f, --rcfile=FILE Load configuration file FILE\n",
+ .options = my_longopts,
+ .parser = my_parser,
+ .checker = my_checker,
+@@ -104,6 +105,15 @@ int main(int argc, char *argv[])
+ return 1;
+ }
+
++ if (my_args.rcfile) {
++ c->clear_config(c);
++ if (!c->load_config(c, my_args.rcfile)) {
++ fprintf(stderr, "Failed to load rcfile\n");
++ lxc_container_put(c);
++ return 1;
++ }
++ }
++
+ if (!c->wait(c, my_args.states, my_args.timeout)) {
+ lxc_container_put(c);
+ return 1;
+--
+2.1.4
+
diff --git a/debian/patches/0002-tools-set-configfile-after-load_config.patch b/debian/patches/0002-tools-set-configfile-after-load_config.patch
new file mode 100644
index 0000000..6b669cd
--- /dev/null
+++ b/debian/patches/0002-tools-set-configfile-after-load_config.patch
@@ -0,0 +1,228 @@
+From be7a90e6433492a18da2e7b4ea27a41800661932 Mon Sep 17 00:00:00 2001
+From: Wolfgang Bumiller <w.bumiller at proxmox.com>
+Date: Fri, 12 Aug 2016 14:49:37 +0200
+Subject: [PATCH 2/6] tools: set configfile after load_config
+
+In order to cause c->is_defined() to become true.
+
+Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
+---
+ src/lxc/lxc_attach.c | 6 ++++++
+ src/lxc/lxc_cgroup.c | 6 ++++++
+ src/lxc/lxc_checkpoint.c | 6 ++++++
+ src/lxc/lxc_console.c | 6 ++++++
+ src/lxc/lxc_destroy.c | 6 ++++++
+ src/lxc/lxc_device.c | 5 +++++
+ src/lxc/lxc_freeze.c | 6 ++++++
+ src/lxc/lxc_info.c | 6 ++++++
+ src/lxc/lxc_snapshot.c | 6 ++++++
+ src/lxc/lxc_stop.c | 5 +++++
+ src/lxc/lxc_unfreeze.c | 6 ++++++
+ src/lxc/lxc_wait.c | 6 ++++++
+ 12 files changed, 70 insertions(+)
+
+diff --git a/src/lxc/lxc_attach.c b/src/lxc/lxc_attach.c
+index 8d39b35..024ae4d 100644
+--- a/src/lxc/lxc_attach.c
++++ b/src/lxc/lxc_attach.c
+@@ -383,6 +383,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(EXIT_FAILURE);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ ERROR("Out of memory setting new config filename");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
+index f623e0b..b8ab45c 100644
+--- a/src/lxc/lxc_cgroup.c
++++ b/src/lxc/lxc_cgroup.c
+@@ -92,6 +92,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ return 1;
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ ERROR("Out of memory setting new config filename");
++ lxc_container_put(c);
++ return 1;
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_checkpoint.c b/src/lxc/lxc_checkpoint.c
+index 58886b6..3f3ba93 100644
+--- a/src/lxc/lxc_checkpoint.c
++++ b/src/lxc/lxc_checkpoint.c
+@@ -222,6 +222,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(1);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ lxc_container_put(c);
++ exit(1);
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_console.c b/src/lxc/lxc_console.c
+index d80462c..bf1d1aa 100644
+--- a/src/lxc/lxc_console.c
++++ b/src/lxc/lxc_console.c
+@@ -120,6 +120,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(EXIT_FAILURE);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_destroy.c b/src/lxc/lxc_destroy.c
+index d9738dd..7e20bf7 100644
+--- a/src/lxc/lxc_destroy.c
++++ b/src/lxc/lxc_destroy.c
+@@ -97,6 +97,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(EXIT_FAILURE);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_device.c b/src/lxc/lxc_device.c
+index 8e54668..f1525c3 100644
+--- a/src/lxc/lxc_device.c
++++ b/src/lxc/lxc_device.c
+@@ -132,6 +132,11 @@ int main(int argc, char *argv[])
+ ERROR("Failed to load rcfile");
+ goto err1;
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ ERROR("Out of memory setting new config filename");
++ goto err1;
++ }
+ }
+
+ if (!c->is_running(c)) {
+diff --git a/src/lxc/lxc_freeze.c b/src/lxc/lxc_freeze.c
+index 4d1864d..e6d547a 100644
+--- a/src/lxc/lxc_freeze.c
++++ b/src/lxc/lxc_freeze.c
+@@ -82,6 +82,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(1);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ ERROR("Out of memory setting new config filename");
++ lxc_container_put(c);
++ exit(1);
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_info.c b/src/lxc/lxc_info.c
+index 6a63457..f6a6723 100644
+--- a/src/lxc/lxc_info.c
++++ b/src/lxc/lxc_info.c
+@@ -303,6 +303,12 @@ static int print_info(const char *name, const char *lxcpath)
+ lxc_container_put(c);
+ return -1;
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ lxc_container_put(c);
++ return -1;
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_snapshot.c b/src/lxc/lxc_snapshot.c
+index 3b17b23..74f483c 100644
+--- a/src/lxc/lxc_snapshot.c
++++ b/src/lxc/lxc_snapshot.c
+@@ -115,6 +115,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(EXIT_FAILURE);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ lxc_container_put(c);
++ exit(EXIT_FAILURE);
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_stop.c b/src/lxc/lxc_stop.c
+index 6502aa3..3542f63 100644
+--- a/src/lxc/lxc_stop.c
++++ b/src/lxc/lxc_stop.c
+@@ -211,6 +211,11 @@ int main(int argc, char *argv[])
+ fprintf(stderr, "Failed to load rcfile\n");
+ goto out;
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ goto out;
++ }
+ }
+
+ if (!c->may_control(c)) {
+diff --git a/src/lxc/lxc_unfreeze.c b/src/lxc/lxc_unfreeze.c
+index e2e9b4b..c998e27 100644
+--- a/src/lxc/lxc_unfreeze.c
++++ b/src/lxc/lxc_unfreeze.c
+@@ -86,6 +86,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ exit(1);
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ ERROR("Out of memory setting new config filename");
++ lxc_container_put(c);
++ exit(1);
++ }
+ }
+
+ if (!c->unfreeze(c)) {
+diff --git a/src/lxc/lxc_wait.c b/src/lxc/lxc_wait.c
+index ee61a32..1455245 100644
+--- a/src/lxc/lxc_wait.c
++++ b/src/lxc/lxc_wait.c
+@@ -112,6 +112,12 @@ int main(int argc, char *argv[])
+ lxc_container_put(c);
+ return 1;
+ }
++ c->configfile = strdup(my_args.rcfile);
++ if (!c->configfile) {
++ fprintf(stderr, "Out of memory setting new config filename\n");
++ lxc_container_put(c);
++ return 1;
++ }
+ }
+
+ if (!c->wait(c, my_args.states, my_args.timeout)) {
+--
+2.1.4
+
diff --git a/debian/patches/series b/debian/patches/series
index 72bfbb4..fbc3a11 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,6 @@ use-var-lib-vz-as-default-dir.patch
#do-not-use-config-path-for-rootfs.patch
run-lxcnetaddbr.patch
0001-conf-set-pty_info-to-NULL-after-free.patch
+0001-add-f-option-to-lxc-attach.patch
+0001-tools-move-rcfile-to-the-common-options-list.patch
+0002-tools-set-configfile-after-load_config.patch
--
2.1.4
More information about the pve-devel
mailing list