[PATCH 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>
---
 docs/formatstorage.html.in            |  9 +++++++--
 src/storage/storage_backend_logical.c | 22 ++++++++++++++--------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 4965a4c..2f4662c 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -566,8 +566,13 @@
         <span class="since">Since 0.4.1</span></dd>
       <dt><code>source</code></dt>
       <dd>Provides information about the underlying storage allocation
-        of the volume. This may not be available for some pool types.
-        <span class="since">Since 0.4.1</span></dd>
+        of the volume. This is available logical pool types to display
+        details of logical volume extent information
+        (<span class="since">Since 0.4.1</span>)
+        or the name of the name of the thin-pool used by the thin
+        logical volume
+        (<span class="since">Since 1.3.2</span>).
+        </dd>
       <dt><code>target</code></dt>
       <dd>Provides information about the representation of the volume
         on the local host. <span class="since">Since 0.4.1</span></dd>
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index d7990e2..15fa228 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -91,9 +91,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
@@ -286,13 +290,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",
@@ -350,7 +356,7 @@ virStorageBackendLogicalMakeVol(char **const groups,
 #define VIR_STORAGE_VOL_LOGICAL_LV_NAME_REGEX "(\\S+)#"
 #define VIR_STORAGE_VOL_LOGICAL_ORIGIN_REGEX "(\\S*)#"
 #define VIR_STORAGE_VOL_LOGICAL_UUID_REGEX "(\\S+)#"
-#define VIR_STORAGE_VOL_LOGICAL_DEVICES_REGEX "(\\S+)#"
+#define VIR_STORAGE_VOL_LOGICAL_DEVICES_REGEX "(\\S*)#"
 #define VIR_STORAGE_VOL_LOGICAL_SEGTYPE_REGEX "(\\S+)#"
 #define VIR_STORAGE_VOL_LOGICAL_STRIPES_REGEX "([0-9]+)#"
 #define VIR_STORAGE_VOL_LOGICAL_SEG_SIZE_REGEX "(\\S+)#"
-- 
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]