mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
Add validation of LV name to pvmove -n.
This commit is contained in:
parent
e7bdd69af0
commit
ac7334c167
@ -1,5 +1,6 @@
|
||||
Version 2.02.34 -
|
||||
===================================
|
||||
Add validation of LV name to pvmove -n.
|
||||
Make clvmd refresh the context correctly when lvm.conf is updated.
|
||||
Add some basic internal VG lock validation.
|
||||
Add per-command flags to control which commands use the VG metadata cache.
|
||||
|
@ -37,14 +37,13 @@ test_expect_success \
|
||||
lvcreate -L4 -n"$lv" "$vg"'
|
||||
|
||||
# Test for the bogus diagnostic reported in BZ 284771
|
||||
# http://bugzilla.redhat.com/284771. Once the BZ is fixed,
|
||||
# update the code below to expect an improved diagnostic.
|
||||
# http://bugzilla.redhat.com/284771.
|
||||
test_expect_success \
|
||||
'run pvmove with an unrecognized LV name to show bad diagnostic' \
|
||||
'pvmove -v -nbogus $d1 $d2 2> err
|
||||
test $? = 5 &&
|
||||
tail -n1 err > out &&
|
||||
echo " No data to move for $vg" > expected &&
|
||||
echo " Logical volume bogus not found." > expected &&
|
||||
diff -u out expected'
|
||||
|
||||
# With lvm-2.02.28 and earlier, on a system with 64-bit "long int",
|
||||
|
@ -147,6 +147,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
|
||||
struct logical_volume *lv_mirr, *lv;
|
||||
struct lv_list *lvl;
|
||||
uint32_t log_count = 0;
|
||||
int lv_found = 0;
|
||||
|
||||
/* FIXME Cope with non-contiguous => splitting existing segments */
|
||||
if (!(lv_mirr = lv_create_empty("pvmove%d", NULL,
|
||||
@ -168,9 +169,13 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
|
||||
/* Find segments to be moved and set up mirrors */
|
||||
list_iterate_items(lvl, &vg->lvs) {
|
||||
lv = lvl->lv;
|
||||
if ((lv == lv_mirr) ||
|
||||
(lv_name && strcmp(lv->name, lv_name)))
|
||||
if ((lv == lv_mirr))
|
||||
continue;
|
||||
if (lv_name) {
|
||||
if (strcmp(lv->name, lv_name))
|
||||
continue;
|
||||
lv_found = 1;
|
||||
}
|
||||
if (lv_is_origin(lv) || lv_is_cow(lv)) {
|
||||
log_print("Skipping snapshot-related LV %s", lv->name);
|
||||
continue;
|
||||
@ -196,6 +201,11 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
if (lv_name && !lv_found) {
|
||||
log_error("Logical volume %s not found.", lv_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Is temporary mirror empty? */
|
||||
if (!lv_mirr->le_count) {
|
||||
log_error("No data to move for %s", vg->name);
|
||||
@ -310,6 +320,11 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
|
||||
stack;
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
if (!validate_name(lv_name)) {
|
||||
log_error("Logical volume name %s is invalid", lv_name);
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read VG */
|
||||
|
Loading…
Reference in New Issue
Block a user