]> git.proxmox.com Git - mirror_lxc.git/blame - src/lxc/tools/arguments.h
added allowrunning command line option for snapshotting alive containers
[mirror_lxc.git] / src / lxc / tools / arguments.h
CommitLineData
cda02a28
MN
1/*
2 * lxc: linux Container library
3 *
4 * (C) Copyright IBM Corp. 2007, 2008
5 *
6 * Authors:
9afe19d6 7 * Daniel Lezcano <daniel.lezcano at free.fr>
cda02a28
MN
8 * Michel Normand <normand at fr.ibm.com>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
250b1eec 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
cda02a28 23 */
15fd209a 24
f1a4a029
ÇO
25#ifndef __LXC_ARGUMENTS_H
26#define __LXC_ARGUMENTS_H
cda02a28
MN
27
28#include <getopt.h>
15fd209a 29#include <stdbool.h>
d659597e 30#include <stdint.h>
a13daf8e 31#include <sys/param.h>
d38dd64a
CB
32#include <sys/types.h>
33
4be48327 34#include <lxc/lxccontainer.h>
cda02a28
MN
35
36struct lxc_arguments;
37
ea0eb48b
CB
38typedef int (*lxc_arguments_parser_t)(struct lxc_arguments *, int, char *);
39typedef int (*lxc_arguments_checker_t)(const struct lxc_arguments *);
cda02a28
MN
40
41struct lxc_arguments {
42 const char *help;
ea0eb48b 43 void (*helpfn)(const struct lxc_arguments *);
cda02a28 44 const char *progname;
ea0eb48b 45 const struct option *options;
cda02a28
MN
46 lxc_arguments_parser_t parser;
47 lxc_arguments_checker_t checker;
48
49 const char *name;
50 char *log_file;
51 char *log_priority;
52 int quiet;
c36583c3 53 int daemonize;
cda02a28 54 const char *rcfile;
829dd918 55 const char *console;
596a818d 56 const char *console_log;
3114c982 57 const char *pidfile;
8d06bd13
DE
58 const char **lxcpath;
59 int lxcpath_cnt;
60 /* set to 0 to accept only 1 lxcpath, -1 for unlimited */
61 int lxcpath_additional;
cda02a28 62
9f30a190 63 /* for lxc-start */
1a0e70ac 64 const char *share_ns[32]; /* size must be greater than LXC_NS_MAX */
9f30a190 65
41cfbac9 66 /* for lxc-console */
31299e70 67 unsigned int ttynum;
84a24de2 68 char escape;
41cfbac9 69
84fbfcb4 70 /* for lxc-wait */
41cfbac9 71 char *states;
b486346a 72 long timeout;
84fbfcb4
DE
73
74 /* for lxc-autostart */
3e625e2d 75 int shutdown;
41cfbac9 76
8face1de 77 /* for lxc-stop */
84fbfcb4
DE
78 int hardstop;
79 int nokill;
8face1de 80 int nolock;
84fbfcb4
DE
81 int nowait;
82 int reboot;
8face1de 83
60bf62d4
SH
84 /* for lxc-destroy */
85 int force;
86
b119f362 87 /* close fds from parent? */
b3187a81 88 bool close_all_fds;
b119f362 89
1897e3bc
SH
90 /* lxc-create */
91 char *bdevtype, *configfile, *template;
92 char *fstype;
d659597e 93 uint64_t fssize;
f99c386b 94 char *lvname, *vgname, *thinpool;
7da812df 95 char *rbdname, *rbdpool;
1897e3bc
SH
96 char *zfsroot, *lowerdir, *dir;
97
727b9b16 98 /* lxc-execute and lxc-unshare */
c5cd20ce
PT
99 uid_t uid;
100 gid_t gid;
101
a6adab20
SG
102 /* auto-start */
103 int all;
e582991f 104 int ignore_auto;
a6adab20 105 int list;
fa659172 106 char *groups; /* also used by lxc-ls */
a6adab20 107
d0a6bd39 108 /* lxc-snapshot and lxc-copy */
513f23df 109 enum task {
43cea62d 110 CLONE,
513f23df
CB
111 DESTROY,
112 LIST,
113 RESTORE,
114 SNAP,
115 RENAME,
116 } task;
117 int print_comments;
118 char *commentfile;
119 char *newname;
120 char *newpath;
121 char *snapname;
43cea62d 122 int keepdata;
513f23df
CB
123 int keepname;
124 int keepmac;
754076f5 125 int allowrunning;
513f23df 126
15fd209a
CB
127 /* lxc-ls */
128 char *ls_fancy_format;
4763f6ca 129 char *ls_filter;
f4336974 130 unsigned int ls_nesting; /* maximum allowed nesting level */
15fd209a
CB
131 bool ls_active;
132 bool ls_fancy;
133 bool ls_frozen;
134 bool ls_line;
15fd209a
CB
135 bool ls_running;
136 bool ls_stopped;
c2e1b07a 137 bool ls_defined;
15fd209a 138
60a77c18
CB
139 /* lxc-copy */
140 bool tmpfs;
141
727b9b16 142 /* lxc-unshare */
143 int flags;
144 int want_default_mounts;
145 const char *want_hostname;
146 bool setuid;
147
cda02a28
MN
148 /* remaining arguments */
149 char *const *argv;
150 int argc;
e788178a
CLG
151
152 /* private arguments */
153 void *data;
cda02a28
MN
154};
155
ea0eb48b
CB
156#define LXC_COMMON_OPTIONS \
157 { "name", required_argument, 0, 'n' }, \
a13daf8e 158 { "help", no_argument, 0, 'h' }, \
ea0eb48b
CB
159 { "usage", no_argument, 0, OPT_USAGE }, \
160 { "version", no_argument, 0, OPT_VERSION }, \
161 { "quiet", no_argument, 0, 'q' }, \
162 { "logfile", required_argument, 0, 'o' }, \
163 { "logpriority", required_argument, 0, 'l' }, \
164 { "lxcpath", required_argument, 0, 'P' }, \
165 { "rcfile", required_argument, 0, OPT_RCFILE }, \
166 { 0, 0, 0, 0 }
cda02a28
MN
167
168/* option keys for long only options */
ea0eb48b
CB
169#define OPT_USAGE 0x1000
170#define OPT_VERSION OPT_USAGE - 1
171#define OPT_RCFILE OPT_USAGE - 2
eeeb5865
TA
172#define OPT_SHARE_NET OPT_USAGE - 3
173#define OPT_SHARE_IPC OPT_USAGE - 4
174#define OPT_SHARE_UTS OPT_USAGE - 5
175#define OPT_SHARE_PID OPT_USAGE - 6
4be48327 176
ea0eb48b
CB
177extern int lxc_arguments_parse(struct lxc_arguments *args, int argc,
178 char *const argv[]);
fa7eddbb 179
ea0eb48b
CB
180extern int lxc_arguments_str_to_int(struct lxc_arguments *args,
181 const char *str);
fa7eddbb 182
4be48327
TA
183extern bool lxc_setup_shared_ns(struct lxc_arguments *args, struct lxc_container *c);
184
a13daf8e 185#define lxc_info(arg, fmt, args...) \
186 do { \
187 if (!(arg)->quiet) { \
188 fprintf(stdout, "%s: " fmt "\n", (arg)->progname, ##args); \
189 } \
190 } while (0)
191
192#define lxc_error(arg, fmt, args...) \
193 do { \
194 if (!(arg)->quiet) { \
195 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ##args); \
196 } \
197 } while (0)
198
199#define lxc_sys_error(arg, fmt, args...) \
200 do { \
201 if (!(arg)->quiet) { \
eb0c9382 202 fprintf(stderr, "%s: " fmt "\n", (arg)->progname, ##args); \
a13daf8e 203 } \
204 } while (0)
205
ea0eb48b 206#endif /* __LXC_ARGUMENTS_H */