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
40947787
Unverified
Commit
40947787
authored
Mar 26, 2019
by
Christian Brauner
Committed by
GitHub
Mar 26, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2911 from tomponline/tp-2019-03-19/lvcreate
lvm: Updates lvcreate to wipe signatures if supported
parents
86e27dbd
99a8edfc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
4 deletions
+52
-4
lvm.c
src/lxc/storage/lvm.c
+22
-3
utils.c
src/lxc/utils.c
+15
-1
utils.h
src/lxc/utils.h
+15
-0
No files found.
src/lxc/storage/lvm.c
View file @
40947787
...
@@ -55,6 +55,7 @@ struct lvcreate_args {
...
@@ -55,6 +55,7 @@ struct lvcreate_args {
const
char
*
lv
;
const
char
*
lv
;
const
char
*
thinpool
;
const
char
*
thinpool
;
const
char
*
fstype
;
const
char
*
fstype
;
bool
sigwipe
;
/* snapshot specific arguments */
/* snapshot specific arguments */
const
char
*
source_lv
;
const
char
*
source_lv
;
...
@@ -76,9 +77,16 @@ static int lvm_create_exec_wrapper(void *data)
...
@@ -76,9 +77,16 @@ static int lvm_create_exec_wrapper(void *data)
(
void
)
setenv
(
"LVM_SUPPRESS_FD_WARNINGS"
,
"1"
,
1
);
(
void
)
setenv
(
"LVM_SUPPRESS_FD_WARNINGS"
,
"1"
,
1
);
if
(
args
->
thinpool
)
if
(
args
->
thinpool
)
if
(
args
->
sigwipe
)
execlp
(
"lvcreate"
,
"lvcreate"
,
"-Wy"
,
"--yes"
,
"--thinpool"
,
args
->
thinpool
,
"-V"
,
args
->
size
,
args
->
vg
,
"-n"
,
args
->
lv
,
(
char
*
)
NULL
);
else
execlp
(
"lvcreate"
,
"lvcreate"
,
"-qq"
,
"--thinpool"
,
args
->
thinpool
,
execlp
(
"lvcreate"
,
"lvcreate"
,
"-qq"
,
"--thinpool"
,
args
->
thinpool
,
"-V"
,
args
->
size
,
args
->
vg
,
"-n"
,
args
->
lv
,
"-V"
,
args
->
size
,
args
->
vg
,
"-n"
,
args
->
lv
,
(
char
*
)
NULL
);
(
char
*
)
NULL
);
else
if
(
args
->
sigwipe
)
execlp
(
"lvcreate"
,
"lvcreate"
,
"-Wy"
,
"--yes"
,
"-L"
,
args
->
size
,
args
->
vg
,
"-n"
,
args
->
lv
,
(
char
*
)
NULL
);
else
else
execlp
(
"lvcreate"
,
"lvcreate"
,
"-qq"
,
"-L"
,
args
->
size
,
args
->
vg
,
"-n"
,
execlp
(
"lvcreate"
,
"lvcreate"
,
"-qq"
,
"-L"
,
args
->
size
,
args
->
vg
,
"-n"
,
args
->
lv
,
(
char
*
)
NULL
);
args
->
lv
,
(
char
*
)
NULL
);
...
@@ -177,11 +185,22 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool)
...
@@ -177,11 +185,22 @@ static int do_lvm_create(const char *path, uint64_t size, const char *thinpool)
cmd_args
.
vg
=
vg
;
cmd_args
.
vg
=
vg
;
cmd_args
.
lv
=
lv
;
cmd_args
.
lv
=
lv
;
cmd_args
.
size
=
sz
;
cmd_args
.
size
=
sz
;
cmd_args
.
sigwipe
=
true
;
TRACE
(
"Creating new lvm storage volume
\"
%s
\"
on volume group
\"
%s
\"
"
TRACE
(
"Creating new lvm storage volume
\"
%s
\"
on volume group
\"
%s
\"
"
"of size
\"
%s
\"
"
,
lv
,
vg
,
sz
);
"of size
\"
%s
\"
"
,
lv
,
vg
,
sz
);
ret
=
run_command_status
(
cmd_output
,
sizeof
(
cmd_output
),
lvm_create_exec_wrapper
,
(
void
*
)
&
cmd_args
);
/* If lvcreate is old and doesn't support signature wiping, try again without it.
* Test for exit code EINVALID_CMD_LINE(3) of lvcreate command.
*/
if
(
WIFEXITED
(
ret
)
&&
WEXITSTATUS
(
ret
)
==
3
)
{
cmd_args
.
sigwipe
=
false
;
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
ret
=
run_command
(
cmd_output
,
sizeof
(
cmd_output
),
lvm_create_exec_wrapper
,
(
void
*
)
&
cmd_args
);
lvm_create_exec_wrapper
,
(
void
*
)
&
cmd_args
);
if
(
ret
<
0
)
{
}
if
(
ret
!=
0
)
{
ERROR
(
"Failed to create logical volume
\"
%s
\"
: %s"
,
lv
,
ERROR
(
"Failed to create logical volume
\"
%s
\"
: %s"
,
lv
,
cmd_output
);
cmd_output
);
free
(
pathdup
);
free
(
pathdup
);
...
...
src/lxc/utils.c
View file @
40947787
...
@@ -1594,7 +1594,7 @@ pop_stack:
...
@@ -1594,7 +1594,7 @@ pop_stack:
return
umounts
;
return
umounts
;
}
}
int
run_command
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
arg
s
)
int
run_command
_internal
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
,
bool
wait_statu
s
)
{
{
pid_t
child
;
pid_t
child
;
int
ret
,
fret
,
pipefd
[
2
];
int
ret
,
fret
,
pipefd
[
2
];
...
@@ -1651,13 +1651,27 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args)
...
@@ -1651,13 +1651,27 @@ int run_command(char *buf, size_t buf_size, int (*child_fn)(void *), void *args)
buf
[
bytes
-
1
]
=
'\0'
;
buf
[
bytes
-
1
]
=
'\0'
;
}
}
if
(
wait_status
)
fret
=
lxc_wait_for_pid_status
(
child
);
else
fret
=
wait_for_pid
(
child
);
fret
=
wait_for_pid
(
child
);
/* close the read-end of the pipe */
/* close the read-end of the pipe */
close
(
pipefd
[
0
]);
close
(
pipefd
[
0
]);
return
fret
;
return
fret
;
}
}
int
run_command
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
)
{
return
run_command_internal
(
buf
,
buf_size
,
child_fn
,
args
,
false
);
}
int
run_command_status
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
)
{
return
run_command_internal
(
buf
,
buf_size
,
child_fn
,
args
,
true
);
}
bool
lxc_nic_exists
(
char
*
nic
)
bool
lxc_nic_exists
(
char
*
nic
)
{
{
#define __LXC_SYS_CLASS_NET_LEN 15 + IFNAMSIZ + 1
#define __LXC_SYS_CLASS_NET_LEN 15 + IFNAMSIZ + 1
...
...
src/lxc/utils.h
View file @
40947787
...
@@ -201,6 +201,21 @@ extern int lxc_unstack_mountpoint(const char *path, bool lazy);
...
@@ -201,6 +201,21 @@ extern int lxc_unstack_mountpoint(const char *path, bool lazy);
extern
int
run_command
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
extern
int
run_command
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
);
void
*
args
);
/*
* run_command runs a command and collect it's std{err,out} output in buf, returns exit status.
*
* @param[out] buf The buffer where the commands std{err,out] output will be
* read into. If no output was produced, buf will be memset
* to 0.
* @param[in] buf_size The size of buf. This function will reserve one byte for
* \0-termination.
* @param[in] child_fn The function to be run in the child process. This
* function must exec.
* @param[in] args Arguments to be passed to child_fn.
*/
extern
int
run_command_status
(
char
*
buf
,
size_t
buf_size
,
int
(
*
child_fn
)(
void
*
),
void
*
args
);
/* Concatenate all passed-in strings into one path. Do not fail. If any piece
/* Concatenate all passed-in strings into one path. Do not fail. If any piece
* is not prefixed with '/', add a '/'.
* is not prefixed with '/', add a '/'.
*/
*/
...
...
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