[PATCH v3 4/4] logical: Display thin lv's found in a libvirt managed volume group

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modify the regex for the 'devices' (a/k/a 'extents') from "(\\S+)"
(e.g., 1 or more) to "(\\S*)" (e.g., zero or more).

Then for any "thin" lv's found, mark the volume as a sparse volume so
that the volume wipe algorithm doesn't work.

Since a "thin" segtype has no devices, this will result in any "thin"
lv part of some thin-pool within a volume group used as a libvirt pool
to be displayed as a possible volume to use.

NB:
Based on a proposal authored by Joe Harvell <joe.harvell@xxxxxxxxxxxx>,
but with much intervening rework, the resulting patch is changed from
the original concept. About all that remains is changing the regex and
checking for NULL/empty field during parse.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_backend_logical.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index eb22fd0..601a896 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -88,9 +88,13 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDefPtr vol,
     unsigned long long offset, size, length;
     virStorageVolSourceExtent extent;
 
+    /* If the devices field is NULL or empty, then there's nothing to do */
+    if (!groups[3] || !*groups[3])
+        return 0;
+
     memset(&extent, 0, sizeof(extent));
 
-    /* Assume 1 extent (the regex for 'devices' is "(\\S+)") and only
+    /* Assume 1 extent (since we checked for NULL or empty above) and only
      * check the 'stripes' field if we have a striped, mirror, or one of
      * the raid (raid1, raid4, raid5*, raid6*, or raid10) segtypes in which
      * case the stripes field will denote the number of lv's within the
@@ -257,13 +261,15 @@ virStorageBackendLogicalMakeVol(char **const groups,
             goto cleanup;
     }
 
-    /* Mark the (s) sparse/snapshot lv, e.g. the lv created using
-     * the --virtualsize/-V option. We've already ignored the (t)hin
-     * pool definition. In the manner libvirt defines these, the
-     * thin pool is hidden to the lvs output, except as the name
-     * in brackets [] described for the groups[1] (backingStore).
+    /* Mark the (s) sparse/snapshot or the (V) thin/thin-pool member lv,
+     * e.g. the lv created using the --virtualsize/-V option to ensure
+     * the volume wipe algorithm doesn't overwrite sparse/thin volumes.
+     * We've already ignored the (t)hin pool definition. In the manner
+     * libvirt defines these, the thin pool is hidden to the lvs output,
+     * except as the name in brackets [] described for the groups[1]
+     * (backingStore).
      */
-    if (attrs[0] == 's')
+    if (attrs[0] == 's' || attrs[0] == 'V')
         vol->target.sparse = true;
 
     /* Skips the backingStore of lv created with "--virtualsize",
@@ -342,7 +348,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
      *    striped, so "," is not a suitable separator either (rhbz 727474).
      */
     const char *regexes[] = {
-       "^\\s*(\\S+)#(\\S*)#(\\S+)#(\\S+)#(\\S+)#([0-9]+)#(\\S+)#([0-9]+)#([0-9]+)#(\\S+)#?\\s*$"
+       "^\\s*(\\S+)#(\\S*)#(\\S+)#(\\S*)#(\\S+)#([0-9]+)#(\\S+)#([0-9]+)#([0-9]+)#(\\S+)#?\\s*$"
     };
     int vars[] = {
         10
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]