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
124fef5a
Commit
124fef5a
authored
Jun 29, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: lxc-checkpoint: share internal API symbols
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
4f66541c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
18 deletions
+26
-18
Makefile.am
src/lxc/Makefile.am
+1
-1
lxc_checkpoint.c
src/lxc/tools/lxc_checkpoint.c
+25
-17
No files found.
src/lxc/Makefile.am
View file @
124fef5a
...
@@ -286,7 +286,7 @@ lxc_unshare_SOURCES = tools/lxc_unshare.c tools/arguments.c
...
@@ -286,7 +286,7 @@ lxc_unshare_SOURCES = tools/lxc_unshare.c tools/arguments.c
lxc_wait_SOURCES
=
tools/lxc_wait.c tools/arguments.c
lxc_wait_SOURCES
=
tools/lxc_wait.c tools/arguments.c
lxc_create_SOURCES
=
tools/lxc_create.c tools/arguments.c tools/tool_utils.c
lxc_create_SOURCES
=
tools/lxc_create.c tools/arguments.c tools/tool_utils.c
lxc_snapshot_SOURCES
=
tools/lxc_snapshot.c tools/arguments.c tools/tool_utils.c
lxc_snapshot_SOURCES
=
tools/lxc_snapshot.c tools/arguments.c tools/tool_utils.c
lxc_checkpoint_SOURCES
=
tools/lxc_checkpoint.c tools/arguments.c
tools/tool_utils.c
lxc_checkpoint_SOURCES
=
tools/lxc_checkpoint.c tools/arguments.c
endif
endif
if
ENABLE_COMMANDS
if
ENABLE_COMMANDS
...
...
src/lxc/tools/lxc_checkpoint.c
View file @
124fef5a
...
@@ -27,7 +27,8 @@
...
@@ -27,7 +27,8 @@
#include <lxc/lxccontainer.h>
#include <lxc/lxccontainer.h>
#include "arguments.h"
#include "arguments.h"
#include "tool_utils.h"
#include "log.h"
#include "utils.h"
static
char
*
checkpoint_dir
=
NULL
;
static
char
*
checkpoint_dir
=
NULL
;
static
bool
stop
=
false
;
static
bool
stop
=
false
;
...
@@ -53,24 +54,26 @@ static const struct option my_longopts[] = {
...
@@ -53,24 +54,26 @@ static const struct option my_longopts[] = {
LXC_COMMON_OPTIONS
LXC_COMMON_OPTIONS
};
};
lxc_log_define
(
lxc_start
,
lxc
);
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
static
int
my_checker
(
const
struct
lxc_arguments
*
args
)
{
{
if
(
do_restore
&&
stop
)
{
if
(
do_restore
&&
stop
)
{
lxc_error
(
args
,
"-s not compatible with -r."
);
ERROR
(
"-s not compatible with -r."
);
return
-
1
;
return
-
1
;
}
else
if
(
!
do_restore
&&
daemonize_set
)
{
}
else
if
(
!
do_restore
&&
daemonize_set
)
{
lxc_error
(
args
,
"-d/-F not compatible with -r."
);
ERROR
(
"-d/-F not compatible with -r."
);
return
-
1
;
return
-
1
;
}
}
if
(
checkpoint_dir
==
NULL
)
{
if
(
!
checkpoint_dir
)
{
lxc_error
(
args
,
"-D is required."
);
ERROR
(
"-D is required."
);
return
-
1
;
return
-
1
;
}
}
if
(
pre_dump
&&
do_restore
)
{
if
(
pre_dump
&&
do_restore
)
{
lxc_error
(
args
,
"-p not compatible with -r."
);
ERROR
(
"-p not compatible with -r."
);
return
-
1
;
return
-
1
;
}
}
...
@@ -116,6 +119,7 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
...
@@ -116,6 +119,7 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
return
-
1
;
return
-
1
;
break
;
break
;
}
}
return
0
;
return
0
;
}
}
...
@@ -158,7 +162,7 @@ static bool checkpoint(struct lxc_container *c)
...
@@ -158,7 +162,7 @@ static bool checkpoint(struct lxc_container *c)
int
mode
;
int
mode
;
if
(
!
c
->
is_running
(
c
))
{
if
(
!
c
->
is_running
(
c
))
{
fprintf
(
stderr
,
"%s not running, not checkpointing.
\n
"
,
my_args
.
name
);
ERROR
(
"%s not running, not checkpointing.
"
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
return
false
;
return
false
;
}
}
...
@@ -182,7 +186,7 @@ static bool checkpoint(struct lxc_container *c)
...
@@ -182,7 +186,7 @@ static bool checkpoint(struct lxc_container *c)
/* the migrate() API does not negate the return code like
/* the migrate() API does not negate the return code like
* checkpoint() and restore() does. */
* checkpoint() and restore() does. */
if
(
ret
)
{
if
(
ret
)
{
fprintf
(
stderr
,
"Checkpointing %s failed.
\n
"
,
my_args
.
name
);
ERROR
(
"Checkpointing %s failed.
"
,
my_args
.
name
);
return
false
;
return
false
;
}
}
...
@@ -200,9 +204,10 @@ static bool restore_finalize(struct lxc_container *c)
...
@@ -200,9 +204,10 @@ static bool restore_finalize(struct lxc_container *c)
opts
.
verbose
=
verbose
;
opts
.
verbose
=
verbose
;
opts
.
stop
=
stop
;
opts
.
stop
=
stop
;
opts
.
action_script
=
actionscript_path
;
opts
.
action_script
=
actionscript_path
;
ret
=
c
->
migrate
(
c
,
MIGRATE_RESTORE
,
&
opts
,
sizeof
(
opts
));
ret
=
c
->
migrate
(
c
,
MIGRATE_RESTORE
,
&
opts
,
sizeof
(
opts
));
if
(
ret
)
{
if
(
ret
)
{
fprintf
(
stderr
,
"Restoring %s failed.
\n
"
,
my_args
.
name
);
ERROR
(
"Restoring %s failed.
"
,
my_args
.
name
);
return
false
;
return
false
;
}
}
...
@@ -213,7 +218,7 @@ static bool restore_finalize(struct lxc_container *c)
...
@@ -213,7 +218,7 @@ static bool restore_finalize(struct lxc_container *c)
static
bool
restore
(
struct
lxc_container
*
c
)
static
bool
restore
(
struct
lxc_container
*
c
)
{
{
if
(
c
->
is_running
(
c
))
{
if
(
c
->
is_running
(
c
))
{
fprintf
(
stderr
,
"%s is running, not restoring.
\n
"
,
my_args
.
name
);
ERROR
(
"%s is running, not restoring.
"
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
return
false
;
return
false
;
}
}
...
@@ -223,7 +228,7 @@ static bool restore(struct lxc_container *c)
...
@@ -223,7 +228,7 @@ static bool restore(struct lxc_container *c)
pid
=
fork
();
pid
=
fork
();
if
(
pid
<
0
)
{
if
(
pid
<
0
)
{
perror
(
"
fork"
);
SYSERROR
(
"Failed to
fork"
);
return
false
;
return
false
;
}
}
...
@@ -231,7 +236,7 @@ static bool restore(struct lxc_container *c)
...
@@ -231,7 +236,7 @@ static bool restore(struct lxc_container *c)
close
(
0
);
close
(
0
);
close
(
1
);
close
(
1
);
exit
(
!
restore_finalize
(
c
));
_
exit
(
!
restore_finalize
(
c
));
}
else
{
}
else
{
return
wait_for_pid
(
pid
)
==
0
;
return
wait_for_pid
(
pid
)
==
0
;
}
}
...
@@ -272,33 +277,35 @@ int main(int argc, char *argv[])
...
@@ -272,33 +277,35 @@ int main(int argc, char *argv[])
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
)
{
fprintf
(
stderr
,
"System error loading %s
\n
"
,
my_args
.
name
);
ERROR
(
"System error loading %s
"
,
my_args
.
name
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
my_args
.
rcfile
)
{
if
(
my_args
.
rcfile
)
{
c
->
clear_config
(
c
);
c
->
clear_config
(
c
);
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
if
(
!
c
->
load_config
(
c
,
my_args
.
rcfile
))
{
fprintf
(
stderr
,
"Failed to load rcfile
\n
"
);
ERROR
(
"Failed to load rcfile
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
c
->
configfile
=
strdup
(
my_args
.
rcfile
);
if
(
!
c
->
configfile
)
{
if
(
!
c
->
configfile
)
{
fprintf
(
stderr
,
"Out of memory setting new config filename
\n
"
);
ERROR
(
"Out of memory setting new config filename
"
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
}
if
(
!
c
->
may_control
(
c
))
{
if
(
!
c
->
may_control
(
c
))
{
fprintf
(
stderr
,
"Insufficent privileges to control %s
\n
"
,
my_args
.
name
);
ERROR
(
"Insufficent privileges to control %s
"
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
!
c
->
is_defined
(
c
))
{
if
(
!
c
->
is_defined
(
c
))
{
fprintf
(
stderr
,
"%s is not defined
\n
"
,
my_args
.
name
);
ERROR
(
"%s is not defined
"
,
my_args
.
name
);
lxc_container_put
(
c
);
lxc_container_put
(
c
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
...
@@ -308,6 +315,7 @@ int main(int argc, char *argv[])
...
@@ -308,6 +315,7 @@ int main(int argc, char *argv[])
ret
=
restore
(
c
);
ret
=
restore
(
c
);
else
else
ret
=
checkpoint
(
c
);
ret
=
checkpoint
(
c
);
free
(
actionscript_path
);
free
(
actionscript_path
);
free
(
checkpoint_dir
);
free
(
checkpoint_dir
);
free
(
predump_dir
);
free
(
predump_dir
);
...
...
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