]> sourceware.org Git - lvm2.git/commitdiff
Require --restorefile when using pvcreate --uuid.
authorMike Snitzer <snitzer@redhat.com>
Thu, 12 Aug 2010 04:08:59 +0000 (04:08 +0000)
committerMike Snitzer <snitzer@redhat.com>
Thu, 12 Aug 2010 04:08:59 +0000 (04:08 +0000)
Introduce --norestorefile to allow user to override the new requirement.

This can also be overridden with "devices/require_restorefile_with_uuid"
in lvm.conf -- however the default is 1.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
WHATS_NEW
doc/example.conf.in
lib/config/defaults.h
man/pvcreate.8.in
test/t-covercmd.sh
test/t-pvcreate-operation.sh
test/t-vgcfgbackup-usage.sh
tools/args.h
tools/commands.h
tools/pvcreate.c

index 8e8c3e8e9306b9dc12b945fb54a16b0a4ad74b55..91367363c929764240658aeb93289a0f877f5a09 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
 Version 2.02.73 - 
 ================================
+  Add --norestorefile option to pvcreate.
+  Require --restorefile when using pvcreate --uuid.
   Recognise and give preference to md device partitions (blkext major).
   Never scan internal LVM devices.
   Split-mirror operations were ignoring user-specified PVs.
index 850b7e23ee8209eeed7b7290f80b37d26b4e7426..73832d98911a25137238872f778ab73a13b80cad 100644 (file)
@@ -130,6 +130,9 @@ devices {
     # Set this to 1 to skip such devices.  This should only be needed
     # in recovery situations.
     ignore_suspended_devices = 0
+
+    # Allow use of pvcreate --uuid without requiring --restorefile.
+    require_restorefile_with_uuid = 1
 }
 
 # This section that allows you to configure the nature of the
index 3d8881ca065f2eab6307d451f764dee98ff8ef92..dd9897da2ef05e440f451ee23af269d15bd7d48c 100644 (file)
@@ -30,6 +30,7 @@
 #define DEFAULT_MD_COMPONENT_DETECTION 1
 #define DEFAULT_MD_CHUNK_ALIGNMENT 1
 #define DEFAULT_IGNORE_SUSPENDED_DEVICES 1
+#define DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID 1
 #define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1
 #define DEFAULT_DATA_ALIGNMENT_DETECTION 1
 
index 16a608d33cee673a1179cc34406c30aaf280e9c8..cb100494425618582ae8eb0385227f9fdb30f546 100644 (file)
@@ -17,6 +17,7 @@ pvcreate \- initialize a disk or partition for use by LVM
 .RB [ \-\-dataalignment alignment ]
 .RB [ \-\-dataalignmentoffset alignment_offset ]
 .RB [ \-\-restorefile file ]
+.RB [ \-\-norestorefile ]
 .RB [ \-\-setphysicalvolumesize size ]
 .RB [ \-u | \-\-uuid uuid ]
 .RB [ \-\-version ]
@@ -60,7 +61,9 @@ Specify the uuid for the device.
 Without this option, \fBpvcreate\fP generates a random uuid.
 All of your physical volumes must have unique uuids.
 You need to use this option before restoring a backup of LVM metadata 
-onto a replacement device - see \fBvgcfgrestore\fP(8).
+onto a replacement device - see \fBvgcfgrestore\fP(8).  As such, use of
+\fB--restorefile\fP is compulsory unless the \fB--norestorefile\fP is
+used.
 .TP
 .BR \-y ", " \-\-yes
 Answer yes to all questions.
@@ -138,6 +141,10 @@ the same place and not get overwritten by new metadata.  This provides
 a mechanism to upgrade the metadata format or to add/remove metadata
 areas. Use with care. See also \fBvgconvert\fP(8).
 .TP
+.BR \-\-norestorefile
+In conjunction with \fB--uuid\fP, this allows a uuid to be specified
+without also requiring that a backup of the metadata be provided.
+.TP
 .BR \-\-labelsector " sector"
 By default the PV is labelled with an LVM2 identifier in its second 
 sector (sector 1).  This lets you use a different sector near the
index 9697606fcfbd9e80e8f6428be33d443965597578..358a93efe06893e7b1d2dc0193052bc55477c5ff 100755 (executable)
@@ -30,7 +30,7 @@ pvcreate $dev1
 pvcreate --metadatacopies 0 $dev2
 pvcreate --metadatacopies 0 $dev3
 pvcreate $dev4
-pvcreate -u $TEST_UUID --metadatacopies 0 $dev5
+pvcreate --norestorefile -u $TEST_UUID --metadatacopies 0 $dev5
 vgcreate -c n $vg $devs
 lvcreate -n $lv -l 5 -i5 -I256 $vg
 
index a9d1a4219009628887bc9d03104da041f41fcd01..2c94696f7841dadf31c858451fd01c74559e4d30 100755 (executable)
@@ -95,17 +95,20 @@ uuid2=freddy-fred-fred-fred-fred-fred-fredie
 bogusuuid=fred
 
 # pvcreate rejects uuid option with less than 32 characters
-not pvcreate --uuid $bogusuuid $dev1
+not pvcreate --norestorefile --uuid $bogusuuid $dev1
+
+# pvcreate rejects uuid option without restorefile
+not pvcreate --uuid $uuid1 $dev1
 
 # pvcreate rejects uuid already in use
-pvcreate --uuid $uuid1 $dev1
-not pvcreate --uuid $uuid1 $dev2
+pvcreate --norestorefile --uuid $uuid1 $dev1
+not pvcreate --norestorefile --uuid $uuid1 $dev2
 
 # pvcreate rejects non-existent file given with restorefile
 not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1
 
 # pvcreate rejects restorefile with uuid not found in file
-pvcreate --uuid $uuid1 $dev1
+pvcreate --norestorefile --uuid $uuid1 $dev1
 vgcfgbackup -f $backupfile
 not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2
 
index e1e94b373e1028ee151beec49d284bf8d864cb55..d7b043257a36514bb4926ef9e329dc3c36a484f9 100644 (file)
@@ -37,6 +37,6 @@ pvcreate -ff -y $dev1
 pvcreate -ff -y $dev2
 vgcfgbackup -f "$(pwd)/backup.$$" $vg
 sed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1"
-pvcreate -ff -y -u $pv1_uuid $dev1
-pvcreate -ff -y -u $pv2_uuid $dev2
+pvcreate -ff -y --norestorefile -u $pv1_uuid $dev1
+pvcreate -ff -y --norestorefile -u $pv2_uuid $dev2
 vgcfgrestore -f "$(pwd)/backup.$$1" $vg
index a23c46cbbdb3c8e132237c15d59199b00455d168..91d7b0957b6cc59b0849472d1f75bd35c8fc1d3b 100644 (file)
@@ -27,6 +27,7 @@ arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0)
 arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_arg, 0)
 arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg, 0)
 arg(metadataignore_ARG, '\0', "metadataignore", yes_no_arg, 0)
+arg(norestorefile_ARG, '\0', "norestorefile", NULL, 0)
 arg(restorefile_ARG, '\0', "restorefile", string_arg, 0)
 arg(labelsector_ARG, '\0', "labelsector", int_arg, 0)
 arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg, 0)
index d9e13f42443c1d5cbe68c3ae96c44b04f3fd8673..1c113201dc27387d4486187dcc03b459ba7313fe 100644 (file)
@@ -497,6 +497,7 @@ xx(pvcreate,
    "Initialize physical volume(s) for use by LVM",
    0,
    "pvcreate " "\n"
+   "\t[--norestorefile]\n"
    "\t[--restorefile file]\n"
    "\t[-d|--debug]" "\n"
    "\t[-f[f]|--force [--force]] " "\n"
@@ -517,8 +518,9 @@ xx(pvcreate,
    "\tPhysicalVolume [PhysicalVolume...]\n",
 
    dataalignment_ARG, dataalignmentoffset_ARG, force_ARG, test_ARG,
-   labelsector_ARG, metadatatype_ARG, metadatacopies_ARG, pvmetadatacopies_ARG,
-   metadatasize_ARG, metadataignore_ARG, physicalvolumesize_ARG,
+   labelsector_ARG, metadatatype_ARG, metadatacopies_ARG,
+   metadatasize_ARG, metadataignore_ARG, norestorefile_ARG,
+   physicalvolumesize_ARG, pvmetadatacopies_ARG,
    restorefile_ARG, uuidstr_ARG, yes_ARG, zero_ARG)
 
 xx(pvdata,
index df7664b5ae7dc40af529e6a4cafe536214877d35..23ff02faac5b646e350f57b16660879e969a0442 100644 (file)
@@ -36,6 +36,16 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,
                return 0;
        }
 
+       if (!arg_count(cmd, restorefile_ARG) && arg_count(cmd, uuidstr_ARG)) {
+               if (!arg_count(cmd, norestorefile_ARG) &&
+                   find_config_tree_bool(cmd,
+                                         "devices/require_restorefile_with_uuid",
+                                         DEFAULT_REQUIRE_RESTOREFILE_WITH_UUID)) {
+                       log_error("--restorefile is required with --uuid");
+                       return 0;
+               }
+       }
+
        if (arg_count(cmd, uuidstr_ARG) && argc != 1) {
                log_error("Can only set uuid on one volume at once");
                return 0;
This page took 0.050315 seconds and 5 git commands to generate.