]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Add overwrite flag checking for logical pool
authorJohn Ferlan <jferlan@redhat.com>
Thu, 15 Dec 2016 13:39:13 +0000 (08:39 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 10 Jan 2017 13:44:50 +0000 (08:44 -0500)
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>
src/libvirt_private.syms
src/storage/storage_backend_logical.c
tools/virsh.pod

index b69e8bcc25b310fe40c15f23175b4b298835f761..4d16620b4e30c3a174bd4f6f08f7c8148e8aa62f 100644 (file)
@@ -887,6 +887,7 @@ virStoragePoolFormatDiskTypeFromString;
 virStoragePoolFormatDiskTypeToString;
 virStoragePoolFormatFileSystemNetTypeToString;
 virStoragePoolFormatFileSystemTypeToString;
+virStoragePoolFormatLogicalTypeToString;
 virStoragePoolGetVhbaSCSIHostParent;
 virStoragePoolLoadAllConfigs;
 virStoragePoolLoadAllState;
index 2d8e288d9920b23991b1689030d066ce76e810fe..6a6720e220bcf2c12c7e7e23e6641d790270a31a 100644 (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;
 
index f5990c76b84237a889d9caff2a85800fa47479c3..b95d67f661680530b77201d749f62ca80aa21240 100644 (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>]]