[libvirt] [PATCH 4/4] logical: Display thin lv's found in a libvirt managed volume group
jferlan at redhat.com
Fri Feb 5 01:40:50 UTC 2016
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.
Based on a proposal authored by Joe Harvell <joe.harvell at tekcomms.com>,
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 at redhat.com>
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
@@ -566,8 +566,13 @@
<span class="since">Since 0.4.1</span></dd>
<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>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
@@ -91,9 +91,13 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDefPtr vol,
unsigned long long offset, size, length;
+ /* If the devices field is NULL or empty, then there's nothing to do */
+ if (!groups || !*groups)
+ 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,
- /* 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 (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
+ * (backingStore).
- if (attrs == 's')
+ if (attrs == 's' || attrs == '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+)#"
More information about the libvir-list