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
754076f5
Commit
754076f5
authored
Nov 23, 2017
by
Bernd Helm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added allowrunning command line option for snapshotting alive containers
Signed-off-by:
Bernd Helm
<
bernd.helm@helmundwalter.de
>
parent
2a083985
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
4 deletions
+22
-4
lxc-copy.sgml.in
doc/lxc-copy.sgml.in
+11
-0
lxccontainer.c
src/lxc/lxccontainer.c
+2
-3
lxccontainer.h
src/lxc/lxccontainer.h
+1
-0
arguments.h
src/lxc/tools/arguments.h
+1
-0
lxc_copy.c
src/lxc/tools/lxc_copy.c
+7
-1
No files found.
doc/lxc-copy.sgml.in
View file @
754076f5
...
@@ -55,6 +55,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -55,6 +55,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<arg choice="opt">-p, --newpath <replaceable>newpath</replaceable></arg>
<arg choice="opt">-p, --newpath <replaceable>newpath</replaceable></arg>
<arg choice="opt">-B, --backingstorage <replaceable>backingstorage</replaceable></arg>
<arg choice="opt">-B, --backingstorage <replaceable>backingstorage</replaceable></arg>
<arg choice="opt">-s, --snapshot</arg>
<arg choice="opt">-s, --snapshot</arg>
<arg choice="opt">-a, --allowrunning</arg>
<arg choice="opt">-K, --keepname</arg>
<arg choice="opt">-K, --keepname</arg>
<arg choice="opt">-D, --keepdata</arg>
<arg choice="opt">-D, --keepdata</arg>
<arg choice="opt">-M, --keepmac</arg>
<arg choice="opt">-M, --keepmac</arg>
...
@@ -70,6 +71,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -70,6 +71,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<arg choice="req">-e, --ephemeral</arg>
<arg choice="req">-e, --ephemeral</arg>
<arg choice="opt">-B, --backingstorage <replaceable>backingstorage</replaceable></arg>
<arg choice="opt">-B, --backingstorage <replaceable>backingstorage</replaceable></arg>
<arg choice="opt">-s, --snapshot</arg>
<arg choice="opt">-s, --snapshot</arg>
<arg choice="opt">-a, --allowrunning</arg>
<arg choice="opt">-K, --keepname</arg>
<arg choice="opt">-K, --keepname</arg>
<arg choice="opt">-D, --keepdata</arg>
<arg choice="opt">-D, --keepdata</arg>
<arg choice="opt">-M, --keepmac</arg>
<arg choice="opt">-M, --keepmac</arg>
...
@@ -209,6 +211,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
...
@@ -209,6 +211,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</varlistentry>
</varlistentry>
<varlistentry>
<varlistentry>
<term> <option>-a,--allowrunning </option> </term>
<listitem>
<para> Allow the creation of a Snapshot of an already running container.
This may cause data corruption or data loss depending on the used
filesystem and applications. Use with care. </para>
</listitem>
</varlistentry>
<varlistentry>
<term> <option>-F,--foreground</option> </term>
<term> <option>-F,--foreground</option> </term>
<listitem>
<listitem>
<para>Run the snapshot in the foreground. The snapshots console will
<para>Run the snapshot in the foreground. The snapshots console will
...
...
src/lxc/lxccontainer.c
View file @
754076f5
...
@@ -3799,9 +3799,8 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
...
@@ -3799,9 +3799,8 @@ static struct lxc_container *do_lxcapi_clone(struct lxc_container *c, const char
if
(
container_mem_lock
(
c
))
if
(
container_mem_lock
(
c
))
return
NULL
;
return
NULL
;
if
(
!
is_stopped
(
c
)
&&
!
(
flags
&
LXC_CLONE_ALLOW_RUNNING
))
{
if
(
!
is_stopped
(
c
))
{
ERROR
(
"error: Original container (%s) is running. Use --allowrunning if you want to force a snapshot of the running container."
,
c
->
name
);
ERROR
(
"error: Original container (%s) is running"
,
c
->
name
);
goto
out
;
goto
out
;
}
}
...
...
src/lxc/lxccontainer.h
View file @
754076f5
...
@@ -41,6 +41,7 @@ extern "C" {
...
@@ -41,6 +41,7 @@ extern "C" {
#define LXC_CLONE_KEEPBDEVTYPE (1 << 3)
/*!< Use the same bdev type */
#define LXC_CLONE_KEEPBDEVTYPE (1 << 3)
/*!< Use the same bdev type */
#define LXC_CLONE_MAYBE_SNAPSHOT (1 << 4)
/*!< Snapshot only if bdev supports it, else copy */
#define LXC_CLONE_MAYBE_SNAPSHOT (1 << 4)
/*!< Snapshot only if bdev supports it, else copy */
#define LXC_CLONE_MAXFLAGS (1 << 5)
/*!< Number of \c LXC_CLONE_* flags */
#define LXC_CLONE_MAXFLAGS (1 << 5)
/*!< Number of \c LXC_CLONE_* flags */
#define LXC_CLONE_ALLOW_RUNNING (1 << 6)
/*!< allow snapshot creation even if source container is running */
#define LXC_CREATE_QUIET (1 << 0)
/*!< Redirect \c stdin to \c /dev/zero and \c stdout and \c stderr to \c /dev/null */
#define LXC_CREATE_QUIET (1 << 0)
/*!< Redirect \c stdin to \c /dev/zero and \c stdout and \c stderr to \c /dev/null */
#define LXC_CREATE_MAXFLAGS (1 << 1)
/*!< Number of \c LXC_CREATE* flags */
#define LXC_CREATE_MAXFLAGS (1 << 1)
/*!< Number of \c LXC_CREATE* flags */
#define LXC_MOUNT_API_V1 1
#define LXC_MOUNT_API_V1 1
...
...
src/lxc/tools/arguments.h
View file @
754076f5
...
@@ -122,6 +122,7 @@ struct lxc_arguments {
...
@@ -122,6 +122,7 @@ struct lxc_arguments {
int
keepdata
;
int
keepdata
;
int
keepname
;
int
keepname
;
int
keepmac
;
int
keepmac
;
int
allowrunning
;
/* lxc-ls */
/* lxc-ls */
char
*
ls_fancy_format
;
char
*
ls_fancy_format
;
...
...
src/lxc/tools/lxc_copy.c
View file @
754076f5
...
@@ -73,6 +73,7 @@ static const struct option my_longopts[] = {
...
@@ -73,6 +73,7 @@ static const struct option my_longopts[] = {
{
"newpath"
,
required_argument
,
0
,
'p'
},
{
"newpath"
,
required_argument
,
0
,
'p'
},
{
"rename"
,
no_argument
,
0
,
'R'
},
{
"rename"
,
no_argument
,
0
,
'R'
},
{
"snapshot"
,
no_argument
,
0
,
's'
},
{
"snapshot"
,
no_argument
,
0
,
's'
},
{
"allowrunning"
,
no_argument
,
0
,
'a'
},
{
"foreground"
,
no_argument
,
0
,
'F'
},
{
"foreground"
,
no_argument
,
0
,
'F'
},
{
"daemon"
,
no_argument
,
0
,
'd'
},
{
"daemon"
,
no_argument
,
0
,
'd'
},
{
"ephemeral"
,
no_argument
,
0
,
'e'
},
{
"ephemeral"
,
no_argument
,
0
,
'e'
},
...
@@ -108,6 +109,7 @@ Options :\n\
...
@@ -108,6 +109,7 @@ Options :\n\
-p, --newpath=NEWPATH NEWPATH for the container to be stored
\n
\
-p, --newpath=NEWPATH NEWPATH for the container to be stored
\n
\
-R, --rename rename container
\n
\
-R, --rename rename container
\n
\
-s, --snapshot create snapshot instead of clone
\n
\
-s, --snapshot create snapshot instead of clone
\n
\
-a, --allowrunning allow snapshot creation even if source container is running
\n
\
-F, --foreground start with current tty attached to /dev/console
\n
\
-F, --foreground start with current tty attached to /dev/console
\n
\
-d, --daemon daemonize the container (default)
\n
\
-d, --daemon daemonize the container (default)
\n
\
-e, --ephemeral start ephemeral container
\n
\
-e, --ephemeral start ephemeral container
\n
\
...
@@ -195,7 +197,8 @@ int main(int argc, char *argv[])
...
@@ -195,7 +197,8 @@ int main(int argc, char *argv[])
if
(
my_args
.
task
==
SNAP
||
my_args
.
task
==
DESTROY
)
if
(
my_args
.
task
==
SNAP
||
my_args
.
task
==
DESTROY
)
flags
|=
LXC_CLONE_SNAPSHOT
;
flags
|=
LXC_CLONE_SNAPSHOT
;
if
(
my_args
.
allowrunning
)
flags
|=
LXC_CLONE_ALLOW_RUNNING
;
if
(
my_args
.
keepname
)
if
(
my_args
.
keepname
)
flags
|=
LXC_CLONE_KEEPNAME
;
flags
|=
LXC_CLONE_KEEPNAME
;
...
@@ -557,6 +560,9 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
...
@@ -557,6 +560,9 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
case
's'
:
case
's'
:
args
->
task
=
SNAP
;
args
->
task
=
SNAP
;
break
;
break
;
case
'a'
:
args
->
allowrunning
=
1
;
break
;
case
'F'
:
case
'F'
:
args
->
daemonize
=
0
;
args
->
daemonize
=
0
;
break
;
break
;
...
...
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