1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Add validation of LV name to pvmove -n.

This commit is contained in:
Milan Broz 2008-04-04 11:59:31 +00:00
parent ec074fcf64
commit d2901a62a4
3 changed files with 20 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.34 - Version 2.02.34 -
=================================== ===================================
Add validation of LV name to pvmove -n.
Make clvmd refresh the context correctly when lvm.conf is updated. Make clvmd refresh the context correctly when lvm.conf is updated.
Add some basic internal VG lock validation. Add some basic internal VG lock validation.
Add per-command flags to control which commands use the VG metadata cache. Add per-command flags to control which commands use the VG metadata cache.

View File

@ -37,14 +37,13 @@ test_expect_success \
lvcreate -L4 -n"$lv" "$vg"' lvcreate -L4 -n"$lv" "$vg"'
# Test for the bogus diagnostic reported in BZ 284771 # Test for the bogus diagnostic reported in BZ 284771
# http://bugzilla.redhat.com/284771. Once the BZ is fixed, # http://bugzilla.redhat.com/284771.
# update the code below to expect an improved diagnostic.
test_expect_success \ test_expect_success \
'run pvmove with an unrecognized LV name to show bad diagnostic' \ 'run pvmove with an unrecognized LV name to show bad diagnostic' \
'pvmove -v -nbogus $d1 $d2 2> err 'pvmove -v -nbogus $d1 $d2 2> err
test $? = 5 && test $? = 5 &&
tail -n1 err > out && tail -n1 err > out &&
echo " No data to move for $vg" > expected && echo " Logical volume bogus not found." > expected &&
diff -u out expected' diff -u out expected'
# With lvm-2.02.28 and earlier, on a system with 64-bit "long int", # With lvm-2.02.28 and earlier, on a system with 64-bit "long int",

View File

@ -147,6 +147,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
struct logical_volume *lv_mirr, *lv; struct logical_volume *lv_mirr, *lv;
struct lv_list *lvl; struct lv_list *lvl;
uint32_t log_count = 0; uint32_t log_count = 0;
int lv_found = 0;
/* FIXME Cope with non-contiguous => splitting existing segments */ /* FIXME Cope with non-contiguous => splitting existing segments */
if (!(lv_mirr = lv_create_empty("pvmove%d", NULL, 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 */ /* Find segments to be moved and set up mirrors */
list_iterate_items(lvl, &vg->lvs) { list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv; lv = lvl->lv;
if ((lv == lv_mirr) || if ((lv == lv_mirr))
(lv_name && strcmp(lv->name, lv_name)))
continue; continue;
if (lv_name) {
if (strcmp(lv->name, lv_name))
continue;
lv_found = 1;
}
if (lv_is_origin(lv) || lv_is_cow(lv)) { if (lv_is_origin(lv) || lv_is_cow(lv)) {
log_print("Skipping snapshot-related LV %s", lv->name); log_print("Skipping snapshot-related LV %s", lv->name);
continue; continue;
@ -196,6 +201,11 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
return_NULL; return_NULL;
} }
if (lv_name && !lv_found) {
log_error("Logical volume %s not found.", lv_name);
return NULL;
}
/* Is temporary mirror empty? */ /* Is temporary mirror empty? */
if (!lv_mirr->le_count) { if (!lv_mirr->le_count) {
log_error("No data to move for %s", vg->name); 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; stack;
return EINVALID_CMD_LINE; 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 */ /* Read VG */