]> git.proxmox.com Git - lxc.git/blob - debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch
buildsys: use the ARCH variable for package names
[lxc.git] / debian / patches / 0001-tools-move-rcfile-to-the-common-options-list.patch
1 From dacc363d7d21434b764d95e4bd3d740c8995e951 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Fri, 12 Aug 2016 12:21:22 +0200
4 Subject: [PATCH 1/3] tools: move --rcfile to the common options list
5
6 In almost all commands it's a useful addition to the -n
7 switch which is a common option, too.
8
9 Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 ---
11 src/lxc/arguments.c | 1 +
12 src/lxc/arguments.h | 2 ++
13 src/lxc/tools/lxc_attach.c | 1 -
14 src/lxc/tools/lxc_cgroup.c | 12 +++++++++++-
15 src/lxc/tools/lxc_checkpoint.c | 10 ++++++++++
16 src/lxc/tools/lxc_console.c | 12 +++++++++++-
17 src/lxc/tools/lxc_copy.c | 11 ++++++++++-
18 src/lxc/tools/lxc_destroy.c | 12 +++++++++++-
19 src/lxc/tools/lxc_device.c | 11 ++++++++++-
20 src/lxc/tools/lxc_freeze.c | 12 +++++++++++-
21 src/lxc/tools/lxc_info.c | 12 +++++++++++-
22 src/lxc/tools/lxc_snapshot.c | 12 +++++++++++-
23 src/lxc/tools/lxc_stop.c | 11 ++++++++++-
24 src/lxc/tools/lxc_unfreeze.c | 12 +++++++++++-
25 src/lxc/tools/lxc_wait.c | 12 +++++++++++-
26 15 files changed, 131 insertions(+), 12 deletions(-)
27
28 diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c
29 index c2f7b67..0d2b203 100644
30 --- a/src/lxc/arguments.c
31 +++ b/src/lxc/arguments.c
32 @@ -203,6 +203,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
33 case 'o': args->log_file = optarg; break;
34 case 'l': args->log_priority = optarg; break;
35 case 'q': args->quiet = 1; break;
36 + case OPT_RCFILE: args->rcfile = optarg; break;
37 case 'P':
38 remove_trailing_slashes(optarg);
39 ret = lxc_arguments_lxcpath_add(args, optarg);
40 diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h
41 index f68f8ab..39bedf5 100644
42 --- a/src/lxc/arguments.h
43 +++ b/src/lxc/arguments.h
44 @@ -151,11 +151,13 @@ struct lxc_arguments {
45 {"logfile", required_argument, 0, 'o'}, \
46 {"logpriority", required_argument, 0, 'l'}, \
47 {"lxcpath", required_argument, 0, 'P'}, \
48 + {"rcfile", required_argument, 0, OPT_RCFILE}, \
49 {0, 0, 0, 0}
50
51 /* option keys for long only options */
52 #define OPT_USAGE 0x1000
53 #define OPT_VERSION OPT_USAGE-1
54 +#define OPT_RCFILE OPT_USAGE-2
55
56 extern int lxc_arguments_parse(struct lxc_arguments *args,
57 int argc, char *const argv[]);
58 diff --git a/src/lxc/tools/lxc_cgroup.c b/src/lxc/tools/lxc_cgroup.c
59 index dd60fd1..c644501 100644
60 --- a/src/lxc/tools/lxc_cgroup.c
61 +++ b/src/lxc/tools/lxc_cgroup.c
62 @@ -56,7 +56,8 @@ Get or set the value of a state object (for example, 'cpuset.cpus')\n\
63 in the container's cgroup for the corresponding subsystem.\n\
64 \n\
65 Options :\n\
66 - -n, --name=NAME NAME of the container",
67 + -n, --name=NAME NAME of the container\n\
68 + --rcfile=FILE Load configuration file FILE\n",
69 .options = my_longopts,
70 .parser = NULL,
71 .checker = my_checker,
72 @@ -84,6 +85,15 @@ int main(int argc, char *argv[])
73 if (!c)
74 return 1;
75
76 + if (my_args.rcfile) {
77 + c->clear_config(c);
78 + if (!c->load_config(c, my_args.rcfile)) {
79 + ERROR("Failed to load rcfile");
80 + lxc_container_put(c);
81 + return 1;
82 + }
83 + }
84 +
85 if (!c->may_control(c)) {
86 ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
87 lxc_container_put(c);
88 diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c
89 index 7130245..bc18b80 100644
90 --- a/src/lxc/tools/lxc_checkpoint.c
91 +++ b/src/lxc/tools/lxc_checkpoint.c
92 @@ -114,6 +114,7 @@ Options :\n\
93 Restore options:\n\
94 -d, --daemon Daemonize the container (default)\n\
95 -F, --foreground Start with the current tty attached to /dev/console\n\
96 + --rcfile=FILE Load configuration file FILE\n\
97 ",
98 .options = my_longopts,
99 .parser = my_parser,
100 @@ -214,6 +215,15 @@ int main(int argc, char *argv[])
101 exit(1);
102 }
103
104 + if (my_args.rcfile) {
105 + c->clear_config(c);
106 + if (!c->load_config(c, my_args.rcfile)) {
107 + fprintf(stderr, "Failed to load rcfile\n");
108 + lxc_container_put(c);
109 + exit(1);
110 + }
111 + }
112 +
113 if (!c->may_control(c)) {
114 fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
115 lxc_container_put(c);
116 diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c
117 index adbd7e0..8a4d1c0 100644
118 --- a/src/lxc/tools/lxc_console.c
119 +++ b/src/lxc/tools/lxc_console.c
120 @@ -80,7 +80,8 @@ lxc-console logs on the container with the identifier NAME\n\
121 Options :\n\
122 -n, --name=NAME NAME of the container\n\
123 -t, --tty=NUMBER console tty number\n\
124 - -e, --escape=PREFIX prefix for escape command\n",
125 + -e, --escape=PREFIX prefix for escape command\n\
126 + --rcfile=FILE Load configuration file FILE\n",
127 .options = my_longopts,
128 .parser = my_parser,
129 .checker = NULL,
130 @@ -112,6 +113,15 @@ int main(int argc, char *argv[])
131 exit(EXIT_FAILURE);
132 }
133
134 + if (my_args.rcfile) {
135 + c->clear_config(c);
136 + if (!c->load_config(c, my_args.rcfile)) {
137 + fprintf(stderr, "Failed to load rcfile\n");
138 + lxc_container_put(c);
139 + exit(EXIT_FAILURE);
140 + }
141 + }
142 +
143 if (!c->may_control(c)) {
144 fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
145 lxc_container_put(c);
146 diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c
147 index 3257ab7..c81c077 100644
148 --- a/src/lxc/tools/lxc_copy.c
149 +++ b/src/lxc/tools/lxc_copy.c
150 @@ -126,7 +126,8 @@ Options :\n\
151 -D, --keedata pass together with -e start a persistent snapshot \n\
152 -K, --keepname keep the hostname of the original container\n\
153 -- hook options arguments passed to the hook program\n\
154 - -M, --keepmac keep the MAC address of the original container\n",
155 + -M, --keepmac keep the MAC address of the original container\n\
156 + --rcfile=FILE Load configuration file FILE\n",
157 .options = my_longopts,
158 .parser = my_parser,
159 .task = CLONE,
160 @@ -210,6 +211,14 @@ int main(int argc, char *argv[])
161 if (!c)
162 exit(ret);
163
164 + if (my_args.rcfile) {
165 + c->clear_config(c);
166 + if (!c->load_config(c, my_args.rcfile)) {
167 + fprintf(stderr, "Failed to load rcfile\n");
168 + goto out;
169 + }
170 + }
171 +
172 if (!c->may_control(c)) {
173 if (!my_args.quiet)
174 fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
175 diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c
176 index b521739..50fd708 100644
177 --- a/src/lxc/tools/lxc_destroy.c
178 +++ b/src/lxc/tools/lxc_destroy.c
179 @@ -53,7 +53,8 @@ lxc-destroy destroys a container with the identifier NAME\n\
180 Options :\n\
181 -n, --name=NAME NAME of the container\n\
182 -s, --snapshots destroy including all snapshots\n\
183 - -f, --force wait for the container to shut down\n",
184 + -f, --force wait for the container to shut down\n\
185 + --rcfile=FILE Load configuration file FILE\n",
186 .options = my_longopts,
187 .parser = my_parser,
188 .checker = NULL,
189 @@ -88,6 +89,15 @@ int main(int argc, char *argv[])
190 exit(EXIT_FAILURE);
191 }
192
193 + if (my_args.rcfile) {
194 + c->clear_config(c);
195 + if (!c->load_config(c, my_args.rcfile)) {
196 + fprintf(stderr, "Failed to load rcfile\n");
197 + lxc_container_put(c);
198 + exit(EXIT_FAILURE);
199 + }
200 + }
201 +
202 if (!c->may_control(c)) {
203 if (!quiet)
204 fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name);
205 diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c
206 index 0c9e066..0f1ee8b 100644
207 --- a/src/lxc/tools/lxc_device.c
208 +++ b/src/lxc/tools/lxc_device.c
209 @@ -53,7 +53,8 @@ static struct lxc_arguments my_args = {
210 lxc-device attach or detach DEV to or from container.\n\
211 \n\
212 Options :\n\
213 - -n, --name=NAME NAME of the container",
214 + -n, --name=NAME NAME of the container\n\
215 + --rcfile=FILE Load configuration file FILE\n",
216 .options = my_longopts,
217 .parser = NULL,
218 .checker = NULL,
219 @@ -125,6 +126,14 @@ int main(int argc, char *argv[])
220 goto err;
221 }
222
223 + if (my_args.rcfile) {
224 + c->clear_config(c);
225 + if (!c->load_config(c, my_args.rcfile)) {
226 + ERROR("Failed to load rcfile");
227 + goto err1;
228 + }
229 + }
230 +
231 if (!c->is_running(c)) {
232 ERROR("Container %s is not running.", c->name);
233 goto err1;
234 diff --git a/src/lxc/tools/lxc_freeze.c b/src/lxc/tools/lxc_freeze.c
235 index ea8bd3e..d0239bf 100644
236 --- a/src/lxc/tools/lxc_freeze.c
237 +++ b/src/lxc/tools/lxc_freeze.c
238 @@ -47,7 +47,8 @@ static struct lxc_arguments my_args = {
239 lxc-freeze freezes a container with the identifier NAME\n\
240 \n\
241 Options :\n\
242 - -n, --name=NAME NAME of the container",
243 + -n, --name=NAME NAME of the container\n\
244 + --rcfile=FILE Load configuration file FILE\n",
245 .options = my_longopts,
246 .parser = NULL,
247 .checker = NULL,
248 @@ -74,6 +75,15 @@ int main(int argc, char *argv[])
249 exit(1);
250 }
251
252 + if (my_args.rcfile) {
253 + c->clear_config(c);
254 + if (!c->load_config(c, my_args.rcfile)) {
255 + ERROR("Failed to load rcfile");
256 + lxc_container_put(c);
257 + exit(1);
258 + }
259 + }
260 +
261 if (!c->may_control(c)) {
262 ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name);
263 lxc_container_put(c);
264 diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c
265 index 58ff619..e833697 100644
266 --- a/src/lxc/tools/lxc_info.c
267 +++ b/src/lxc/tools/lxc_info.c
268 @@ -93,7 +93,8 @@ Options :\n\
269 -p, --pid shows the process id of the init container\n\
270 -S, --stats shows usage stats\n\
271 -H, --no-humanize shows stats as raw numbers, not humanized\n\
272 - -s, --state shows the state of the container\n",
273 + -s, --state shows the state of the container\n\
274 + --rcfile=FILE Load configuration file FILE\n",
275 .name = NULL,
276 .options = my_longopts,
277 .parser = my_parser,
278 @@ -295,6 +296,15 @@ static int print_info(const char *name, const char *lxcpath)
279 return -1;
280 }
281
282 + if (my_args.rcfile) {
283 + c->clear_config(c);
284 + if (!c->load_config(c, my_args.rcfile)) {
285 + fprintf(stderr, "Failed to load rcfile\n");
286 + lxc_container_put(c);
287 + return -1;
288 + }
289 + }
290 +
291 if (!c->may_control(c)) {
292 fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
293 lxc_container_put(c);
294 diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c
295 index 8f44891..aa9b6fe 100644
296 --- a/src/lxc/tools/lxc_snapshot.c
297 +++ b/src/lxc/tools/lxc_snapshot.c
298 @@ -62,7 +62,8 @@ Options :\n\
299 -d, --destroy=NAME destroy snapshot NAME, e.g. 'snap0'\n\
300 use ALL to destroy all snapshots\n\
301 -c, --comment=FILE add FILE as a comment\n\
302 - -C, --showcomments show snapshot comments\n",
303 + -C, --showcomments show snapshot comments\n\
304 + --rcfile=FILE Load configuration file FILE\n",
305 .options = my_longopts,
306 .parser = my_parser,
307 .checker = NULL,
308 @@ -107,6 +108,15 @@ int main(int argc, char *argv[])
309 exit(EXIT_FAILURE);
310 }
311
312 + if (my_args.rcfile) {
313 + c->clear_config(c);
314 + if (!c->load_config(c, my_args.rcfile)) {
315 + fprintf(stderr, "Failed to load rcfile\n");
316 + lxc_container_put(c);
317 + exit(EXIT_FAILURE);
318 + }
319 + }
320 +
321 if (!c->may_control(c)) {
322 fprintf(stderr, "Insufficent privileges to control %s\n",
323 my_args.name);
324 diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c
325 index 10ddce6..bbe1f1c 100644
326 --- a/src/lxc/tools/lxc_stop.c
327 +++ b/src/lxc/tools/lxc_stop.c
328 @@ -75,7 +75,8 @@ Options :\n\
329 -t, --timeout=T wait T seconds before hard-stopping\n\
330 -k, --kill kill container rather than request clean shutdown\n\
331 --nolock Avoid using API locks\n\
332 - --nokill Only request clean shutdown, don't force kill after timeout\n",
333 + --nokill Only request clean shutdown, don't force kill after timeout\n\
334 + --rcfile=FILE Load configuration file FILE\n",
335 .options = my_longopts,
336 .parser = my_parser,
337 .checker = NULL,
338 @@ -203,6 +204,14 @@ int main(int argc, char *argv[])
339 goto out;
340 }
341
342 + if (my_args.rcfile) {
343 + c->clear_config(c);
344 + if (!c->load_config(c, my_args.rcfile)) {
345 + fprintf(stderr, "Failed to load rcfile\n");
346 + goto out;
347 + }
348 + }
349 +
350 if (!c->may_control(c)) {
351 fprintf(stderr, "Insufficent privileges to control %s\n", c->name);
352 goto out;
353 diff --git a/src/lxc/tools/lxc_unfreeze.c b/src/lxc/tools/lxc_unfreeze.c
354 index 3a13d37..b7bbea6 100644
355 --- a/src/lxc/tools/lxc_unfreeze.c
356 +++ b/src/lxc/tools/lxc_unfreeze.c
357 @@ -45,7 +45,8 @@ static struct lxc_arguments my_args = {
358 lxc-unfreeze unfreezes a container with the identifier NAME\n\
359 \n\
360 Options :\n\
361 - -n, --name=NAME NAME of the container\n",
362 + -n, --name=NAME NAME of the container\n\
363 + --rcfile=FILE Load configuration file FILE\n",
364 .options = my_longopts,
365 .parser = NULL,
366 .checker = NULL,
367 @@ -78,6 +79,15 @@ int main(int argc, char *argv[])
368 exit(1);
369 }
370
371 + if (my_args.rcfile) {
372 + c->clear_config(c);
373 + if (!c->load_config(c, my_args.rcfile)) {
374 + ERROR("Failed to load rcfile");
375 + lxc_container_put(c);
376 + exit(1);
377 + }
378 + }
379 +
380 if (!c->unfreeze(c)) {
381 ERROR("Failed to unfreeze %s:%s", my_args.lxcpath[0], my_args.name);
382 lxc_container_put(c);
383 diff --git a/src/lxc/tools/lxc_wait.c b/src/lxc/tools/lxc_wait.c
384 index 712ba52..deeff98 100644
385 --- a/src/lxc/tools/lxc_wait.c
386 +++ b/src/lxc/tools/lxc_wait.c
387 @@ -72,7 +72,8 @@ Options :\n\
388 -s, --state=STATE ORed states to wait for\n\
389 STOPPED, STARTING, RUNNING, STOPPING,\n\
390 ABORTING, FREEZING, FROZEN, THAWED\n\
391 - -t, --timeout=TMO Seconds to wait for state changes\n",
392 + -t, --timeout=TMO Seconds to wait for state changes\n\
393 + --rcfile=FILE Load configuration file FILE\n",
394 .options = my_longopts,
395 .parser = my_parser,
396 .checker = my_checker,
397 @@ -104,6 +105,15 @@ int main(int argc, char *argv[])
398 return 1;
399 }
400
401 + if (my_args.rcfile) {
402 + c->clear_config(c);
403 + if (!c->load_config(c, my_args.rcfile)) {
404 + fprintf(stderr, "Failed to load rcfile\n");
405 + lxc_container_put(c);
406 + return 1;
407 + }
408 + }
409 +
410 if (!c->wait(c, my_args.states, my_args.timeout)) {
411 lxc_container_put(c);
412 return 1;
413 --
414 2.1.4
415