]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/tools/lxc_freeze.c
2 * lxc: linux Container library
4 * (C) Copyright IBM Corp. 2007, 2008
7 * Daniel Lezcano <daniel.lezcano at free.fr>
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.
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.
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
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <sys/types.h>
29 #include <lxc/lxccontainer.h>
34 #include "arguments.h"
36 lxc_log_define(lxc_freeze_ui
, lxc
);
38 static const struct option my_longopts
[] = {
42 static struct lxc_arguments my_args
= {
43 .progname
= "lxc-freeze",
47 lxc-freeze freezes a container with the identifier NAME\n\
50 -n, --name=NAME NAME of the container\n\
51 --rcfile=FILE Load configuration file FILE\n",
52 .options
= my_longopts
,
57 int main(int argc
, char *argv
[])
59 struct lxc_container
*c
;
62 if (lxc_arguments_parse(&my_args
, argc
, argv
))
65 if (!my_args
.log_file
)
66 my_args
.log_file
= "none";
68 log
.name
= my_args
.name
;
69 log
.file
= my_args
.log_file
;
70 log
.level
= my_args
.log_priority
;
71 log
.prefix
= my_args
.progname
;
72 log
.quiet
= my_args
.quiet
;
73 log
.lxcpath
= my_args
.lxcpath
[0];
75 if (lxc_log_init(&log
))
77 lxc_log_options_no_override();
79 /* REMOVE IN LXC 3.0 */
80 setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
82 c
= lxc_container_new(my_args
.name
, my_args
.lxcpath
[0]);
84 ERROR("No such container: %s:%s", my_args
.lxcpath
[0], my_args
.name
);
90 if (!c
->load_config(c
, my_args
.rcfile
)) {
91 ERROR("Failed to load rcfile");
95 c
->configfile
= strdup(my_args
.rcfile
);
97 ERROR("Out of memory setting new config filename");
103 if (!c
->may_control(c
)) {
104 ERROR("Insufficent privileges to control %s:%s", my_args
.lxcpath
[0], my_args
.name
);
105 lxc_container_put(c
);
110 ERROR("Failed to freeze %s:%s", my_args
.lxcpath
[0], my_args
.name
);
111 lxc_container_put(c
);
115 lxc_container_put(c
);