Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
83a5624a
Unverified
Commit
83a5624a
authored
Aug 18, 2018
by
2xsec
Committed by
Christian Brauner
Aug 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: lxc-checkpoint: add default log priority & cleanups
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
eda2d856
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
77 deletions
+82
-77
lxc_checkpoint.c
src/lxc/tools/lxc_checkpoint.c
+82
-77
No files found.
src/lxc/tools/lxc_checkpoint.c
View file @
83a5624a
...
@@ -30,16 +30,24 @@
...
@@ -30,16 +30,24 @@
#include "log.h"
#include "log.h"
#include "utils.h"
#include "utils.h"
static
char
*
checkpoint_dir
=
NULL
;
#define OPT_PREDUMP_DIR (OPT_USAGE + 1)
static
bool
stop
=
false
;
static
bool
verbose
=
false
;
static
bool
do_restore
=
false
;
static
bool
daemonize_set
=
false
;
static
bool
pre_dump
=
false
;
static
char
*
predump_dir
=
NULL
;
static
char
*
actionscript_path
=
NULL
;
#define OPT_PREDUMP_DIR OPT_USAGE + 1
lxc_log_define
(
lxc_checkpoint
,
lxc
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
int
my_checker
(
const
struct
lxc_arguments
*
args
);
static
bool
checkpoint
(
struct
lxc_container
*
c
);
static
bool
restore_finalize
(
struct
lxc_container
*
c
);
static
bool
restore
(
struct
lxc_container
*
c
);
static
char
*
checkpoint_dir
;
static
bool
stop
;
static
bool
verbose
;
static
bool
do_restore
;
static
bool
daemonize_set
;
static
bool
pre_dump
;
static
char
*
predump_dir
;
static
char
*
actionscript_path
;
static
const
struct
option
my_longopts
[]
=
{
static
const
struct
option
my_longopts
[]
=
{
{
"checkpoint-dir"
,
required_argument
,
0
,
'D'
},
{
"checkpoint-dir"
,
required_argument
,
0
,
'D'
},
...
@@ -54,31 +62,39 @@ static const struct option my_longopts[] = {
...
@@ -54,31 +62,39 @@ static const struct option my_longopts[] = {
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
};
};
lxc_log_define
(
lxc_checkpoint
,
lxc
);
static
struct
lxc_arguments
my_args
=
{
.
progname
=
"lxc-checkpoint"
,
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
.
help
=
"\
{
--name=NAME
\n
\
if
(
do_restore
&&
stop
)
{
\n
\
ERROR
(
"-s not compatible with -r"
);
lxc-checkpoint checkpoints and restores a container
\n
\
return
-
1
;
Serializes a container's running state to disk to allow restoring it in
\n
\
its running state at a later time.
\n
\
}
else
if
(
!
do_restore
&&
daemonize_set
)
{
\n
\
ERROR
(
"-d/-F not compatible with -r"
);
Options :
\n
\
return
-
1
;
-n, --name=NAME NAME of the container
\n
\
}
-r, --restore Restore container
\n
\
-D, --checkpoint-dir=DIR directory to save the checkpoint in
\n
\
if
(
!
checkpoint_dir
)
{
-v, --verbose Enable verbose criu logs
\n
\
ERROR
(
"-D is required"
);
-A, --action-script=PATH Path to criu action script
\n
\
return
-
1
;
Checkpoint options:
\n
\
}
-s, --stop Stop the container after checkpointing.
\n
\
-p, --pre-dump Only pre-dump the memory of the container.
\n
\
if
(
pre_dump
&&
do_restore
)
{
Container keeps on running and following
\n
\
ERROR
(
"-p not compatible with -r"
);
checkpoints will only dump the changes.
\n
\
return
-
1
;
--predump-dir=DIR path to images from previous dump (relative to -D)
\n
\
}
Restore options:
\n
\
-d, --daemon Daemonize the container (default)
\n
\
return
0
;
-F, --foreground Start with the current tty attached to /dev/console
\n
\
}
--rcfile=FILE Load configuration file FILE
\n
\
"
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
.
daemonize
=
1
,
.
checker
=
my_checker
,
.
log_priority
=
"ERROR"
,
.
log_file
=
"none"
,
};
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
{
...
@@ -88,7 +104,7 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
...
@@ -88,7 +104,7 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
if
(
!
checkpoint_dir
)
if
(
!
checkpoint_dir
)
return
-
1
;
return
-
1
;
break
;
break
;
case
'A'
:
case
'A'
:
actionscript_path
=
strdup
(
arg
);
actionscript_path
=
strdup
(
arg
);
if
(
!
actionscript_path
)
if
(
!
actionscript_path
)
return
-
1
;
return
-
1
;
...
@@ -123,37 +139,29 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
...
@@ -123,37 +139,29 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
return
0
;
return
0
;
}
}
static
struct
lxc_arguments
my_args
=
{
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
.
progname
=
"lxc-checkpoint"
,
{
.
help
=
"\
if
(
do_restore
&&
stop
)
{
--name=NAME
\n
\
ERROR
(
"-s not compatible with -r"
);
\n
\
return
-
1
;
lxc-checkpoint checkpoints and restores a container
\n
\
Serializes a container's running state to disk to allow restoring it in
\n
\
}
else
if
(
!
do_restore
&&
daemonize_set
)
{
its running state at a later time.
\n
\
ERROR
(
"-d/-F not compatible with -r"
);
\n
\
return
-
1
;
Options :
\n
\
}
-n, --name=NAME NAME of the container
\n
\
-r, --restore Restore container
\n
\
if
(
!
checkpoint_dir
)
{
-D, --checkpoint-dir=DIR directory to save the checkpoint in
\n
\
ERROR
(
"-D is required"
);
-v, --verbose Enable verbose criu logs
\n
\
return
-
1
;
-A, --action-script=PATH Path to criu action script
\n
\
}
Checkpoint options:
\n
\
-s, --stop Stop the container after checkpointing.
\n
\
if
(
pre_dump
&&
do_restore
)
{
-p, --pre-dump Only pre-dump the memory of the container.
\n
\
ERROR
(
"-p not compatible with -r"
);
Container keeps on running and following
\n
\
return
-
1
;
checkpoints will only dump the changes.
\n
\
}
--predump-dir=DIR path to images from previous dump (relative to -D)
\n
\
Restore options:
\n
\
return
0
;
-d, --daemon Daemonize the container (default)
\n
\
}
-F, --foreground Start with the current tty attached to /dev/console
\n
\
--rcfile=FILE Load configuration file FILE
\n
\
"
,
.
options
=
my_longopts
,
.
parser
=
my_parser
,
.
daemonize
=
1
,
.
checker
=
my_checker
,
};
static
bool
checkpoint
(
struct
lxc_container
*
c
)
static
bool
checkpoint
(
struct
lxc_container
*
c
)
{
{
...
@@ -262,18 +270,15 @@ int main(int argc, char *argv[])
...
@@ -262,18 +270,15 @@ int main(int argc, char *argv[])
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
if
(
lxc_arguments_parse
(
&
my_args
,
argc
,
argv
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
/* Only create log if explicitly instructed */
log
.
name
=
my_args
.
name
;
if
(
my_args
.
log_file
||
my_args
.
log_priority
)
{
log
.
file
=
my_args
.
log_file
;
log
.
name
=
my_args
.
name
;
log
.
level
=
my_args
.
log_priority
;
log
.
file
=
my_args
.
log_file
;
log
.
prefix
=
my_args
.
progname
;
log
.
level
=
my_args
.
log_priority
;
log
.
quiet
=
my_args
.
quiet
;
log
.
prefix
=
my_args
.
progname
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
log
.
quiet
=
my_args
.
quiet
;
log
.
lxcpath
=
my_args
.
lxcpath
[
0
];
if
(
lxc_log_init
(
&
log
))
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
c
=
lxc_container_new
(
my_args
.
name
,
my_args
.
lxcpath
[
0
]);
c
=
lxc_container_new
(
my_args
.
name
,
my_args
.
lxcpath
[
0
]);
if
(
!
c
)
{
if
(
!
c
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment