]>
Commit | Line | Data |
---|---|---|
5e97c3fc | 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> |
5e97c3fc | 8 | * |
9 | * This library is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License as published by the Free Software Foundation; either | |
12 | * version 2.1 of the License, or (at your option) any later version. | |
13 | * | |
14 | * This library is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * Lesser General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU Lesser General Public | |
20 | * License along with this library; if not, write to the Free Software | |
250b1eec | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
5e97c3fc | 22 | */ |
23 | #include <stdio.h> | |
24 | #include <unistd.h> | |
25 | #include <sys/types.h> | |
26 | #include <libgen.h> | |
27 | #include <string.h> | |
28 | ||
b113348e | 29 | #include <lxc/lxc.h> |
00b3c2e2 | 30 | #include <lxc/log.h> |
92b0b5ba | 31 | #include <lxc/lxccontainer.h> |
00b3c2e2 | 32 | |
4237c6ca | 33 | #include "arguments.h" |
5e97c3fc | 34 | |
92b0b5ba SH |
35 | lxc_log_define(lxc_freeze_ui, lxc_cgroup); |
36 | ||
4237c6ca MN |
37 | static const struct option my_longopts[] = { |
38 | LXC_COMMON_OPTIONS | |
39 | }; | |
40 | ||
41 | static struct lxc_arguments my_args = { | |
42 | .progname = "lxc-freeze", | |
43 | .help = "\ | |
44 | --name=NAME\n\ | |
45 | \n\ | |
46 | lxc-freeze freezes a container with the identifier NAME\n\ | |
47 | \n\ | |
48 | Options :\n\ | |
49 | -n, --name=NAME NAME for name of the container", | |
50 | .options = my_longopts, | |
51 | .parser = NULL, | |
52 | .checker = NULL, | |
53 | }; | |
5e97c3fc | 54 | |
55 | int main(int argc, char *argv[]) | |
56 | { | |
92b0b5ba SH |
57 | struct lxc_container *c; |
58 | ||
c8f55b0e | 59 | if (lxc_arguments_parse(&my_args, argc, argv)) |
92b0b5ba | 60 | exit(1); |
5e97c3fc | 61 | |
5e1e7aaf | 62 | if (lxc_log_init(my_args.name, my_args.log_file, my_args.log_priority, |
8d06bd13 | 63 | my_args.progname, my_args.quiet, my_args.lxcpath[0])) |
92b0b5ba | 64 | exit(1); |
5e97c3fc | 65 | |
92b0b5ba SH |
66 | c = lxc_container_new(my_args.name, my_args.lxcpath[0]); |
67 | if (!c) { | |
68 | ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name); | |
69 | exit(1); | |
70 | } | |
5e97c3fc | 71 | |
92b0b5ba SH |
72 | if (!c->freeze(c)) { |
73 | ERROR("Failed to freeze %s:%s", my_args.lxcpath[0], my_args.name); | |
74 | lxc_container_put(c); | |
75 | exit(1); | |
76 | } | |
77 | ||
78 | lxc_container_put(c); | |
79 | ||
80 | return 0; | |
81 | } |