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
99a1811c
Unverified
Commit
99a1811c
authored
Mar 23, 2020
by
Stéphane Graber
Committed by
GitHub
Mar 23, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3321 from brauner/2020-03-24/fixes
lxc-update-config: handle lxc.rootfs.backend correctly
parents
cb47a5af
309b71d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
38 deletions
+38
-38
lxc-update-config.in
src/lxc/cmd/lxc-update-config.in
+11
-2
lvm.c
src/lxc/storage/lvm.c
+27
-35
lxc-local.in
templates/lxc-local.in
+0
-1
No files found.
src/lxc/cmd/lxc-update-config.in
View file @
99a1811c
...
@@ -46,8 +46,18 @@ done
...
@@ -46,8 +46,18 @@ done
cp
"
${
CONFIGPATH
}
"
"
${
CONFIGPATH
}
.backup"
cp
"
${
CONFIGPATH
}
"
"
${
CONFIGPATH
}
.backup"
# Deal with lxc.rootfs.backend lines
DRIVER
=
""
while
read
-r
LINE
;
do
DRIVER
=
$(
echo
$LINE
|
sed
-n
's/\([[:blank:]]*\|#*\)\(lxc\.rootfs\.backend\)\([[:blank:]]*\|\)\(=[[:blank:]]*\|\)\([[:alnum:]]*\)\([[:space:]]*\)/\5/p'
)
done
<
"
${
CONFIGPATH
}
"
if
[
-z
"
${
DRIVER
}
"
]
;
then
DRIVER
=
"dir"
fi
sed
-i
's/\([[:blank:]*]\|#*\)\(lxc\.rootfs\)\([[:blank:]*]\|\)\(=[[:blank:]]*\)\(.*\)/\1lxc\.rootfs\.path\3\4'
"
${
DRIVER
}
"
':\5/g'
"
${
CONFIGPATH
}
"
sed
-i
\
sed
-i
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.rootfs\)\([[:blank:]*]\|=\)/\1lxc\.rootfs\.path\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.id_map\)\([[:blank:]*]\|=\)/\1lxc\.idmap\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.id_map\)\([[:blank:]*]\|=\)/\1lxc\.idmap\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.pts\)\([[:blank:]*]\|=\)/\1lxc\.pty\.max\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.pts\)\([[:blank:]*]\|=\)/\1lxc\.pty\.max\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.tty\)\([[:blank:]*]\|=\)/\1lxc\.tty\.max\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.tty\)\([[:blank:]*]\|=\)/\1lxc\.tty\.max\3/g'
\
...
@@ -57,7 +67,6 @@ sed -i \
...
@@ -57,7 +67,6 @@ sed -i \
-e
's/\([[:blank:]*]\|#*\)\(lxc\.se_context\)\([[:blank:]*]\|=\)/\1lxc\.selinux\.context\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.se_context\)\([[:blank:]*]\|=\)/\1lxc\.selinux\.context\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.mount\)\([[:blank:]*]\|=\)/\1lxc\.mount\.fstab\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.mount\)\([[:blank:]*]\|=\)/\1lxc\.mount\.fstab\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.utsname\)\([[:blank:]*]\|=\)/\1lxc\.uts\.name\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.utsname\)\([[:blank:]*]\|=\)/\1lxc\.uts\.name\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.rootfs\)\([[:blank:]*]\|=\)/\1lxc\.rootfs\.path\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.seccomp\)\([[:blank:]*]\|=\)/\1lxc\.seccomp\.profile\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.seccomp\)\([[:blank:]*]\|=\)/\1lxc\.seccomp\.profile\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.console\)\([[:blank:]*]\|=\)/\1lxc\.console\.path\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.console\)\([[:blank:]*]\|=\)/\1lxc\.console\.path\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.haltsignal\)\([[:blank:]*]\|=\)/\1lxc\.signal\.halt\3/g'
\
-e
's/\([[:blank:]*]\|#*\)\(lxc\.haltsignal\)\([[:blank:]*]\|=\)/\1lxc\.signal\.halt\3/g'
\
...
...
src/lxc/storage/lvm.c
View file @
99a1811c
...
@@ -315,6 +315,11 @@ int lvm_is_thin_pool(const char *path)
...
@@ -315,6 +315,11 @@ int lvm_is_thin_pool(const char *path)
return
lvm_compare_lv_attr
(
path
,
0
,
't'
);
return
lvm_compare_lv_attr
(
path
,
0
,
't'
);
}
}
static
inline
bool
fs_needs_new_uuid
(
const
char
*
fstype
)
{
return
strcmp
(
fstype
,
"xfs"
)
==
0
||
strcmp
(
fstype
,
"btrfs"
)
==
0
;
}
static
int
lvm_snapshot_create_new_uuid_wrapper
(
void
*
data
)
static
int
lvm_snapshot_create_new_uuid_wrapper
(
void
*
data
)
{
{
struct
lvcreate_args
*
args
=
data
;
struct
lvcreate_args
*
args
=
data
;
...
@@ -330,8 +335,9 @@ static int lvm_snapshot_create_new_uuid_wrapper(void *data)
...
@@ -330,8 +335,9 @@ static int lvm_snapshot_create_new_uuid_wrapper(void *data)
static
int
lvm_snapshot
(
struct
lxc_storage
*
orig
,
const
char
*
path
,
uint64_t
size
)
static
int
lvm_snapshot
(
struct
lxc_storage
*
orig
,
const
char
*
path
,
uint64_t
size
)
{
{
__do_free
char
*
pathdup
=
NULL
;
int
ret
;
int
ret
;
char
*
lv
,
*
pathdup
;
char
*
lv
;
char
sz
[
24
];
char
sz
[
24
];
char
fstype
[
100
];
char
fstype
[
100
];
char
cmd_output
[
PATH_MAX
];
char
cmd_output
[
PATH_MAX
];
...
@@ -339,24 +345,17 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
...
@@ -339,24 +345,17 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
const
char
*
origsrc
;
const
char
*
origsrc
;
struct
lvcreate_args
cmd_args
=
{
0
};
struct
lvcreate_args
cmd_args
=
{
0
};
ret
=
snprintf
(
sz
,
24
,
"%"
PRIu64
"b"
,
size
);
ret
=
snprintf
(
sz
,
sizeof
(
sz
),
"%"
PRIu64
"b"
,
size
);
if
(
ret
<
0
||
ret
>=
24
)
{
if
(
ret
<
0
||
(
size_t
)
ret
>=
sizeof
(
sz
))
ERROR
(
"Failed to create string"
);
return
log_error_errno
(
-
EIO
,
EIO
,
"Failed to create string"
);
return
-
1
;
}
pathdup
=
strdup
(
path
);
pathdup
=
strdup
(
path
);
if
(
!
pathdup
)
{
if
(
!
pathdup
)
ERROR
(
"Failed to duplicate string
\"
%s
\"
"
,
path
);
return
log_error_errno
(
-
ENOMEM
,
ENOMEM
,
"Failed to duplicate string
\"
%s
\"
"
,
path
);
return
-
1
;
}
lv
=
strrchr
(
pathdup
,
'/'
);
lv
=
strrchr
(
pathdup
,
'/'
);
if
(
!
lv
)
{
if
(
!
lv
)
ERROR
(
"Failed to detect
\"
/
\"
in string
\"
%s
\"
"
,
pathdup
);
return
log_error_errno
(
-
ENOENT
,
ENOENT
,
"Failed to detect
\"
/
\"
in string
\"
%s
\"
"
,
pathdup
);
free
(
pathdup
);
return
-
1
;
}
repairchar
=
*
lv
;
repairchar
=
*
lv
;
*
lv
=
'\0'
;
*
lv
=
'\0'
;
lv
++
;
lv
++
;
...
@@ -368,12 +367,10 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
...
@@ -368,12 +367,10 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
*/
*/
origsrc
=
lxc_storage_get_path
(
orig
->
src
,
"lvm"
);
origsrc
=
lxc_storage_get_path
(
orig
->
src
,
"lvm"
);
ret
=
lvm_is_thin_volume
(
origsrc
);
ret
=
lvm_is_thin_volume
(
origsrc
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
free
(
pathdup
);
return
-
1
;
return
-
1
;
}
else
if
(
ret
)
{
else
if
(
ret
)
cmd_args
.
thinpool
=
origsrc
;
cmd_args
.
thinpool
=
origsrc
;
}
cmd_args
.
lv
=
lv
;
cmd_args
.
lv
=
lv
;
cmd_args
.
source_lv
=
origsrc
;
cmd_args
.
source_lv
=
origsrc
;
...
@@ -382,17 +379,15 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
...
@@ -382,17 +379,15 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
origsrc
,
sz
);
origsrc
,
sz
);
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
lvm_snapshot_exec_wrapper
,
(
void
*
)
&
cmd_args
);
lvm_snapshot_exec_wrapper
,
(
void
*
)
&
cmd_args
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
ERROR
(
"Failed to create logical volume
\"
%s
\"
: %s"
,
lv
,
cmd_output
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to create logical volume
\"
%s
\"
: %s"
,
free
(
pathdup
);
lv
,
cmd_output
);
return
-
1
;
}
if
(
detect_fs
(
orig
,
fstype
,
100
)
<
0
)
{
if
(
detect_fs
(
orig
,
fstype
,
100
)
<
0
)
INFO
(
"Failed to detect filesystem type for
\"
%s
\"
"
,
origsrc
);
return
log_error_errno
(
-
EINVAL
,
EINVAL
,
"Failed to detect filesystem type for
\"
%s
\"
"
,
origsrc
);
free
(
pathdup
);
return
-
1
;
if
(
!
fs_needs_new_uuid
(
fstype
))
}
return
0
;
/* repair path */
/* repair path */
lv
--
;
lv
--
;
...
@@ -401,13 +396,10 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
...
@@ -401,13 +396,10 @@ static int lvm_snapshot(struct lxc_storage *orig, const char *path, uint64_t siz
cmd_args
.
fstype
=
fstype
;
cmd_args
.
fstype
=
fstype
;
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
lvm_snapshot_create_new_uuid_wrapper
,
(
void
*
)
&
cmd_args
);
lvm_snapshot_create_new_uuid_wrapper
,
(
void
*
)
&
cmd_args
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
ERROR
(
"Failed to create new uuid for volume
\"
%s
\"
: %s"
,
pathdup
,
cmd_output
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to create new uuid for volume
\"
%s
\"
: %s"
,
free
(
pathdup
);
pathdup
,
cmd_output
);
return
-
1
;
}
free
(
pathdup
);
return
0
;
return
0
;
}
}
...
...
templates/lxc-local.in
View file @
99a1811c
...
@@ -66,7 +66,6 @@ LXC container image downloader
...
@@ -66,7 +66,6 @@ LXC container image downloader
Special arguments:
Special arguments:
[ -h | --help ]: Print this help message and exit.
[ -h | --help ]: Print this help message and exit.
[ -l | --list ]: List all available images and exit.
[ -m | --metadata ]: Path to the metadata for the image.
[ -m | --metadata ]: Path to the metadata for the image.
[ -f | --fstree ]: Path to the filesystem tree for the image.
[ -f | --fstree ]: Path to the filesystem tree for the image.
...
...
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