storage: Add overwrite flag checking for logical pool

https://bugzilla.redhat.com/show_bug.cgi?id=1373711

Add support and documentation for the [NO_]OVERWRITE flags for the
logical backend.

Update virsh.pod with a description of the process for usage of
the flags and building of the pool's volume group.

Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
John Ferlan 2016-12-15 08:39:13 -05:00
parent d5cc5f8997
commit f573f84eb7
3 changed files with 27 additions and 4 deletions

View File

@ -887,6 +887,7 @@ virStoragePoolFormatDiskTypeFromString;
virStoragePoolFormatDiskTypeToString;
virStoragePoolFormatFileSystemNetTypeToString;
virStoragePoolFormatFileSystemTypeToString;
virStoragePoolFormatLogicalTypeToString;
virStoragePoolGetVhbaSCSIHostParent;
virStoragePoolLoadAllConfigs;
virStoragePoolLoadAllState;

View File

@ -759,17 +759,29 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
unsigned int flags)
{
virCommandPtr vgcmd;
virCommandPtr vgcmd = NULL;
int ret = -1;
size_t i;
size_t i = 0;
virCheckFlags(0, -1);
virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, ret);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_STORAGE_POOL_BUILD_OVERWRITE,
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE,
cleanup);
vgcmd = virCommandNewArgList(VGCREATE, pool->def->source.name, NULL);
for (i = 0; i < pool->def->source.ndevice; i++) {
const char *path = pool->def->source.devices[i].path;
/* The blkid FS and Part probing code doesn't know "lvm2" (this
* pool's only format type), but it does know "LVM2_member", so
* we'll pass that here */
if (!(flags & VIR_STORAGE_POOL_BUILD_OVERWRITE) &&
!virStorageBackendDeviceIsEmpty(path, "LVM2_member", true))
goto cleanup;
if (virStorageBackendLogicalInitializeDevice(path) < 0)
goto cleanup;

View File

@ -3466,7 +3466,7 @@ Configure whether I<pool> should automatically start at boot.
Build a given pool.
Options I<--overwrite> and I<--no-overwrite> can only be used for
B<pool-build> a filesystem or disk pool.
B<pool-build> a filesystem, disk, or logical pool.
For a file system pool if neither flag is specified, then B<pool-build>
just makes the target path directory and no attempt to run mkfs on the
@ -3485,6 +3485,16 @@ then no check will be made on the target volume device prior to writing
a new label. Writing of the label uses the pool source format type
or "dos" if not specified.
For a logical pool, if neither of them is specified or I<--no-overwrite>
is specified, B<pool-build> will check the target volume devices for
existing filesystems or partitions before attempting to initialize
and format each device for usage by the logical pool. If any target
volume device already has a label, the command will fail. If
I<--overwrite> is specified, then no check will be made on the target
volume devices prior to initializing and formatting each device. Once
all the target volume devices are properly formatted via pvcreate,
the volume group will be created using all the devices.
=item B<pool-create> I<file>
[I<--build>] [[I<--overwrite>] | [I<--no-overwrite>]]