[libvirt] [PATCH 0/4] Display thin lv's from a logical vg

While I know not the preferred mechanism for Jan, these patches provide a means to display thin lv data from a volume group including the source thin-pool name and thin-pool capacity. Since a thin-pool and a thin lv are just members of the vg, it just feels natural to display whatever is in the volume group because a logical pool comprises all the volumes within the vg. Even if not accepted, some concepts can be used as a bases for a single thin-pool to libvirt pool relationship. There are no changes to virsh vol-list --details or virsh vol-info to display the thin-pool capacity. If one self adds all the capacity values in the vol-list --details display, they will determine that the sum is larger than the virsh pool-info output for the volume group. Although that's even true prior to these patches since the thin data is not displayed in the vol-list output, but is accounted for in the pool-info output, thus the sum of the vol-list capacity details are less. John Ferlan (4): vol: Add new elements to _virStorageVolSource for thin lv logical: Add capability to get the thin pool name logical: Add thin-pool look-aside list logical: Display thin lv's found in a libvirt managed volume group docs/formatstorage.html.in | 9 ++- docs/schemas/storagevol.rng | 14 ++++ src/conf/storage_conf.c | 11 +++ src/conf/storage_conf.h | 15 ++++ src/storage/storage_backend_logical.c | 100 +++++++++++++++++++----- tests/storagevolxml2xmlin/vol-logical-thin.xml | 20 +++++ tests/storagevolxml2xmlout/vol-logical-thin.xml | 17 ++++ tests/storagevolxml2xmltest.c | 1 + 8 files changed, 166 insertions(+), 21 deletions(-) create mode 100644 tests/storagevolxml2xmlin/vol-logical-thin.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical-thin.xml -- 2.5.0

A thin lv doesn't have any extents defined - rather it uses a concept of a "thin-pool" in order to describe it's source. In order to allow that to be displayed properly in a future patch, add a new 'thin_pool' name that can be used by a future patch to store the name of the source thin_pool name used by a thin logical volume. A thin_pool has a specific size, so add a thin_capacity field to store that. For now, these are "output only" fields. That is - if a thin lv is found in a volume group, we can display the thinpool data. The output will appear in a vol-dumpxml (similar to how extents are handled) as: <source> <thinpool name='thinmints'> <capacity unit='bytes'>20971520</capacity> </thinpool> </source> The new tests add the "bones" in order to at some point in a future patch add the ability to parse the input XML with a <thinpool> and generate a thinpool within the volume group. Although the storagevolxml2xmltest added valid input (so that storagevolschematest can validate the format), the output will not be listed, thus the storagevolxml2xmlout does not have the source data (similar to vol-logical.xml). Signed-off-by: John Ferlan <jferlan@redhat.com> --- docs/schemas/storagevol.rng | 14 ++++++++++++++ src/conf/storage_conf.c | 11 +++++++++++ src/conf/storage_conf.h | 3 +++ tests/storagevolxml2xmlin/vol-logical-thin.xml | 20 ++++++++++++++++++++ tests/storagevolxml2xmlout/vol-logical-thin.xml | 17 +++++++++++++++++ tests/storagevolxml2xmltest.c | 1 + 6 files changed, 66 insertions(+) create mode 100644 tests/storagevolxml2xmlin/vol-logical-thin.xml create mode 100644 tests/storagevolxml2xmlout/vol-logical-thin.xml diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng index 7450547..25e2db7 100644 --- a/docs/schemas/storagevol.rng +++ b/docs/schemas/storagevol.rng @@ -144,6 +144,9 @@ <zeroOrMore> <ref name='sourcedev'/> </zeroOrMore> + <optional> + <ref name='sourcethinpool'/> + </optional> </element> </define> @@ -172,6 +175,17 @@ </oneOrMore> </define> + <define name='sourcethinpool'> + <element name='thinpool'> + <attribute name='name'> + <text/> + </attribute> + <element name='capacity'> + <ref name='scaledInteger'/> + </element> + </element> + </define> + <define name='formatdev'> <choice> <value>none</value> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 3657dfd..8eef399 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -322,6 +322,7 @@ virStorageVolDefFree(virStorageVolDefPtr def) for (i = 0; i < def->source.nextent; i++) VIR_FREE(def->source.extents[i].path); VIR_FREE(def->source.extents); + VIR_FREE(def->source.thin_pool); virStorageSourceClear(&def->target); VIR_FREE(def); @@ -1655,6 +1656,16 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool, virBufferAddLit(&buf, "</device>\n"); } + if (def->source.thin_pool) { + virBufferEscapeString(&buf, "<thinpool name='%s'>\n", + def->source.thin_pool); + virBufferAdjustIndent(&buf, 2); + virBufferAsprintf(&buf, "<capacity unit='bytes'>%llu</capacity>\n", + def->source.thin_capacity); + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "</thinpool>\n"); + } + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "</source>\n"); diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 31b45be..f19cb59 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -55,6 +55,9 @@ struct _virStorageVolSource { int partType; /* virStorageVolTypeDisk, only used by disk * backend for partition type creation */ + + char *thin_pool; /* For a thin volume, the thin-pool and capacity */ + unsigned long long thin_capacity; /* bytes */ }; diff --git a/tests/storagevolxml2xmlin/vol-logical-thin.xml b/tests/storagevolxml2xmlin/vol-logical-thin.xml new file mode 100644 index 0000000..7d97627 --- /dev/null +++ b/tests/storagevolxml2xmlin/vol-logical-thin.xml @@ -0,0 +1,20 @@ +<volume type='block'> + <name>thinmint1</name> + <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key> + <source> + <thinpool name='thinmints'> + <capacity unit='bytes'>20971520</capacity> + </thinpool> + </source> + <capacity unit='bytes'>2080374784</capacity> + <allocation unit='bytes'>2080374784</allocation> + <target> + <path>/dev/HostVG/thinmints</path> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmlout/vol-logical-thin.xml b/tests/storagevolxml2xmlout/vol-logical-thin.xml new file mode 100644 index 0000000..198d3ea --- /dev/null +++ b/tests/storagevolxml2xmlout/vol-logical-thin.xml @@ -0,0 +1,17 @@ +<volume type='block'> + <name>thinmint1</name> + <key>r4xkCv-MQhr-WKIT-R66x-Epn2-e8hG-1Z5gY0</key> + <source> + </source> + <capacity unit='bytes'>2080374784</capacity> + <allocation unit='bytes'>2080374784</allocation> + <target> + <path>/dev/HostVG/thinmints</path> + <permissions> + <mode>0660</mode> + <owner>0</owner> + <group>6</group> + <label>system_u:object_r:fixed_disk_device_t:s0</label> + </permissions> + </target> +</volume> diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c index 148d1e6..197d308 100644 --- a/tests/storagevolxml2xmltest.c +++ b/tests/storagevolxml2xmltest.c @@ -107,6 +107,7 @@ mymain(void) DO_TEST("pool-dir", "vol-qcow2-nobacking"); DO_TEST("pool-disk", "vol-partition"); DO_TEST("pool-logical", "vol-logical"); + DO_TEST("pool-logical", "vol-logical-thin"); DO_TEST("pool-logical", "vol-logical-backing"); DO_TEST("pool-sheepdog", "vol-sheepdog"); DO_TEST("pool-gluster", "vol-gluster-dir"); -- 2.5.0

Since a future patch will start displaying thin logical volumes for a logical volume group thin-pool, add the ability to fetch the name of the thin-pool. This is accomplished by adding 'pool_lv' to the list of regex's and when a "thin" lv segtype (groups[4]) is found, we can store the thin-pool name. Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/storage/storage_backend_logical.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index ba26223..3044853 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -67,6 +67,7 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, #define VIR_STORAGE_VOL_LOGICAL_SEGTYPE_STRIPED "striped" #define VIR_STORAGE_VOL_LOGICAL_SEGTYPE_MIRROR "mirror" #define VIR_STORAGE_VOL_LOGICAL_SEGTYPE_RAID "raid" +#define VIR_STORAGE_VOL_LOGICAL_SEGTYPE_THIN "thin" struct virStorageBackendLogicalPoolVolData { virStoragePoolObjPtr pool; @@ -291,6 +292,11 @@ virStorageBackendLogicalMakeVol(char **const groups, VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0) goto cleanup; + if (STREQ(groups[4], VIR_STORAGE_VOL_LOGICAL_SEGTYPE_THIN)) { + if (VIR_STRDUP(vol->source.thin_pool, groups[10]) < 0) + goto cleanup; + } + if (virStrToLong_ull(groups[8], NULL, 10, &vol->target.allocation) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed volume allocation value")); @@ -323,9 +329,10 @@ virStorageBackendLogicalMakeVol(char **const groups, #define VIR_STORAGE_VOL_LOGICAL_VG_EXTENT_SIZE_REGEX "([0-9]+)#" #define VIR_STORAGE_VOL_LOGICAL_SIZE_REGEX "([0-9]+)#" #define VIR_STORAGE_VOL_LOGICAL_LV_ATTR_REGEX "(\\S+)#" +#define VIR_STORAGE_VOL_LOGICAL_POOL_LV_REGEX "(\\S*)#" #define VIR_STORAGE_VOL_LOGICAL_SUFFIX_REGEX "?\\s*$" -#define VIR_STORAGE_VOL_LOGICAL_REGEX_COUNT 10 +#define VIR_STORAGE_VOL_LOGICAL_REGEX_COUNT 11 #define VIR_STORAGE_VOL_LOGICAL_REGEX \ VIR_STORAGE_VOL_LOGICAL_PREFIX_REGEX \ VIR_STORAGE_VOL_LOGICAL_LV_NAME_REGEX \ @@ -338,6 +345,7 @@ virStorageBackendLogicalMakeVol(char **const groups, VIR_STORAGE_VOL_LOGICAL_VG_EXTENT_SIZE_REGEX \ VIR_STORAGE_VOL_LOGICAL_SIZE_REGEX \ VIR_STORAGE_VOL_LOGICAL_LV_ATTR_REGEX \ + VIR_STORAGE_VOL_LOGICAL_POOL_LV_REGEX \ VIR_STORAGE_VOL_LOGICAL_SUFFIX_REGEX static int @@ -346,14 +354,15 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool, { /* * # lvs --separator # --noheadings --units b --unbuffered --nosuffix --options \ - * "lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr" VGNAME + * "lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr,pool_lv" VGNAME * - * RootLV##06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky#/dev/hda2(0)#linear#1#5234491392#33554432#5234491392#-wi-ao - * SwapLV##oHviCK-8Ik0-paqS-V20c-nkhY-Bm1e-zgzU0M#/dev/hda2(156)#linear#1#1040187392#33554432#1040187392#-wi-ao - * Test2##3pg3he-mQsA-5Sui-h0i6-HNmc-Cz7W-QSndcR#/dev/hda2(219)#linear#1#1073741824#33554432#1073741824#owi-a- - * Test3##UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(251)#linear#1#2181038080#33554432#2181038080#-wi-a- - * Test3#Test2#UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(187)#linear#1#1040187392#33554432#1040187392#swi-a- - * test_stripes##fSLSZH-zAS2-yAIb-n4mV-Al9u-HA3V-oo9K1B#/dev/sdc1(10240),/dev/sdd1(0)#striped#2#42949672960#4194304#-wi-a- + * RootLV##06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky#/dev/hda2(0)#linear#1#5234491392#33554432#5234491392#-wi-ao# + * SwapLV##oHviCK-8Ik0-paqS-V20c-nkhY-Bm1e-zgzU0M#/dev/hda2(156)#linear#1#1040187392#33554432#1040187392#-wi-ao# + * Test2##3pg3he-mQsA-5Sui-h0i6-HNmc-Cz7W-QSndcR#/dev/hda2(219)#linear#1#1073741824#33554432#1073741824#owi-a-# + * Test3##UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(251)#linear#1#2181038080#33554432#2181038080#-wi-a-# + * Test3#Test2#UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(187)#linear#1#1040187392#33554432#1040187392#swi-a-# + * test_stripes##fSLSZH-zAS2-yAIb-n4mV-Al9u-HA3V-oo9K1B#/dev/sdc1(10240),/dev/sdd1(0)#striped#2#42949672960#4194304#-wi-a-# + * test_thin##3DvSec-w7Bq-Ukep-Ut62-dOCO-ODE3-vx8Okc##thin#0#1#41943040#4194304#41943040#41943040#Vwi-a-tz--#thinpool_lv_test_thin * * Pull out name, origin, & uuid, device, device extent start #, * segment size, extent size, size, attrs @@ -389,7 +398,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool, "--unbuffered", "--nosuffix", "--options", - "lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr", + "lv_name,origin,uuid,devices,segtype,stripes,seg_size,vg_extent_size,size,lv_attr,pool_lv", pool->def->source.name, NULL); if (virCommandRunRegex(cmd, -- 2.5.0

During processing of the extents found in a pool, we have historically ignored the thin-pool which means any thin lv found in the pool would also be ignored. This can start to change now - we can save aside the name and capacity of any thin-pool's found so that we can use that when we find a thin lv and fill in the thin-pool capacity value on output. The result will end up being the following for a vol-dumpxml: <source> <thinpool name='thinmints'/> <capacity unit='bytes'>20971520</capacity> </thinpool> </source> instead of an empty <source> </source> pair. An upcoming patch will allow a thin lv to be seen Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/conf/storage_conf.h | 12 +++++++++ src/storage/storage_backend_logical.c | 51 +++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index f19cb59..a9a1288 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -47,6 +47,18 @@ struct _virStorageVolSourceExtent { unsigned long long end; }; +/* + * How to represent thin-pool's for a logical volume. Used by the + * logical parsing code + */ +typedef struct _virStorageVolSourceThinPool virStorageVolSourceThinPool; +typedef virStorageVolSourceThinPool *virStorageVolSourceThinPoolPtr; +struct _virStorageVolSourceThinPool { + char *name; + unsigned long long capacity; +}; + + typedef struct _virStorageVolSource virStorageVolSource; typedef virStorageVolSource *virStorageVolSourcePtr; struct _virStorageVolSource { diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 3044853..d7990e2 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -72,6 +72,8 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, struct virStorageBackendLogicalPoolVolData { virStoragePoolObjPtr pool; virStorageVolDefPtr vol; + size_t nthinpools; + virStorageVolSourceThinPoolPtr thinpools; }; static int @@ -221,12 +223,38 @@ virStorageBackendLogicalMakeVol(char **const groups, return 0; /* - * Skip thin pools(t). These show up in normal lvs output + * Save the thin pools(t). These show up in normal lvs output * but do not have a corresponding /dev/$vg/$lv device that * is created by udev. This breaks assumptions in later code. + * The thin pools are the "capacity container" for all the thin + * lv's found in the pool. A thin lv provides a virtual size upon + * creation and can appear to over subscribe the pool capacity. + * Although usually thin pools are listed before thin lv's in the + * output, we'll just wait until all volumes are processed and + * then match the name saved here with thin_pool name we saved + * earlier to get the capacity value of thin-pool into the volume. + * It's expected that there is more than 1 thin lv per thin-pool. + * There can be more than 1 thin-pool per volume group. */ - if (attrs[0] == 't') + if (attrs[0] == 't') { + virStorageVolSourceThinPool thin; + + memset(&thin, 0, sizeof(thin)); + if (VIR_STRDUP(thin.name, groups[0]) < 0) + goto cleanup; + if (virStrToLong_ull(groups[8], NULL, 10, &thin.capacity) < 0) { + VIR_FREE(thin.name); + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed thin pool capacity value")); + goto cleanup; + } + if (VIR_APPEND_ELEMENT(data->thinpools, data->nthinpools, thin) < 0) { + VIR_FREE(thin.name); + goto cleanup; + } + return 0; + } /* See if we're only looking for a specific volume */ if (data->vol != NULL) { @@ -389,7 +417,10 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool, struct virStorageBackendLogicalPoolVolData cbdata = { .pool = pool, .vol = vol, + .nthinpools = 0, + .thinpools = NULL, }; + size_t i, j; cmd = virCommandNewArgList(LVS, "--separator", "#", @@ -410,9 +441,25 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool, "lvs") < 0) goto cleanup; + /* If we find some thin-pools during processing, let's see if we + * need information from them for any thin lv's in the pool + */ + for (i = 0; i < cbdata.nthinpools; i++) { + for (j = 0; j < pool->volumes.count; j++) { + if (STREQ_NULLABLE(pool->volumes.objs[j]->source.thin_pool, + cbdata.thinpools[i].name)) { + pool->volumes.objs[j]->source.thin_capacity = + cbdata.thinpools[i].capacity; + } + } + } + ret = 0; cleanup: virCommandFree(cmd); + for (i = 0; i < cbdata.nthinpools; i++) + VIR_FREE(cbdata.thinpools[i].name); + VIR_FREE(cbdata.thinpools); return ret; } -- 2.5.0

On Thu, Feb 04, 2016 at 08:40:49PM -0500, John Ferlan wrote:
During processing of the extents found in a pool, we have historically ignored the thin-pool which means any thin lv found in the pool would also be ignored. This can start to change now - we can save aside the name and capacity of any thin-pool's found so that we can use that when we find a thin lv and fill in the thin-pool capacity value on output.
The result will end up being the following for a vol-dumpxml:
<source> <thinpool name='thinmints'/> <capacity unit='bytes'>20971520</capacity> </thinpool> </source>
Volume XML should contain information about the volume. Putting the pool capacity there feels unnatural and out of place.
instead of an empty <source> </source> pair.
An upcoming patch will allow a thin lv to be seen
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/conf/storage_conf.h | 12 +++++++++ src/storage/storage_backend_logical.c | 51 +++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c index 3044853..d7990e2 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -72,6 +72,8 @@ virStorageBackendLogicalSetActive(virStoragePoolObjPtr pool, struct virStorageBackendLogicalPoolVolData { virStoragePoolObjPtr pool; virStorageVolDefPtr vol; + size_t nthinpools; + virStorageVolSourceThinPoolPtr thinpools;
This is literally a list of pools in the pool.
};
static int
@@ -410,9 +441,25 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool, "lvs") < 0) goto cleanup;
+ /* If we find some thin-pools during processing, let's see if we + * need information from them for any thin lv's in the pool + */ + for (i = 0; i < cbdata.nthinpools; i++) { + for (j = 0; j < pool->volumes.count; j++) { + if (STREQ_NULLABLE(pool->volumes.objs[j]->source.thin_pool, + cbdata.thinpools[i].name)) { + pool->volumes.objs[j]->source.thin_capacity = + cbdata.thinpools[i].capacity; + } + } + } +
This information should be stored in one place, not n+1 places. Jan

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@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@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 --- 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

On Thu, Feb 04, 2016 at 20:40:46 -0500, John Ferlan wrote:
While I know not the preferred mechanism for Jan, these patches provide a means to display thin lv data from a volume group including the source thin-pool name and thin-pool capacity. Since a thin-pool and a thin lv are just members of the vg, it just feels natural to display whatever is in the volume group because a logical pool comprises all the volumes within the vg.
You could do a similar claim for volume groups or even directories belonging to a 'disk' type pool since they reside on the partition managed by such pool.
Even if not accepted, some concepts can be used as a bases for a single thin-pool to libvirt pool relationship.
The thin volumes and pools have to be manualy manipulated into the volume group that is used as backing for the libvirt 'logical' storage pool since the API does not support building a thin pool backing volume. From this point looking at libvirt APIs it's more natural to have the LVM thin pool as a regular libvirt storage pool as you implicitly get the APIs for building the pool, for getting sizes and other things.
There are no changes to virsh vol-list --details or virsh vol-info to display the thin-pool capacity. If one self adds all the capacity
Obviously as it fits better into 'virsh pool-list --details'.
values in the vol-list --details display, they will determine that the sum is larger than the virsh pool-info output for the volume group. Although that's even true prior to these patches since the thin data is not displayed in the vol-list output, but is accounted for in the pool-info output, thus the sum of the vol-list capacity details are less.
As stated above. The pool was manipulated outside of libvirt with features that are not (yet) supported. I don't see a reason to cram this stuff into the existing logical pool support. Peter

On Fri, Feb 05, 2016 at 12:07:40PM +0100, Peter Krempa wrote:
On Thu, Feb 04, 2016 at 20:40:46 -0500, John Ferlan wrote:
While I know not the preferred mechanism for Jan, these patches provide a means to display thin lv data from a volume group including the source thin-pool name and thin-pool capacity. Since a thin-pool and a thin lv are just members of the vg, it just feels natural to display whatever is in the volume group because a logical pool comprises all the volumes within the vg.
You could do a similar claim for volume groups or even directories belonging to a 'disk' type pool since they reside on the partition managed by such pool.
Even if not accepted, some concepts can be used as a bases for a single thin-pool to libvirt pool relationship.
The thin volumes and pools have to be manualy manipulated into the volume group that is used as backing for the libvirt 'logical' storage pool since the API does not support building a thin pool backing volume.
From this point looking at libvirt APIs it's more natural to have the LVM thin pool as a regular libvirt storage pool as you implicitly get the APIs for building the pool, for getting sizes and other things.
There are no changes to virsh vol-list --details or virsh vol-info to display the thin-pool capacity. If one self adds all the capacity
Obviously as it fits better into 'virsh pool-list --details'.
values in the vol-list --details display, they will determine that the sum is larger than the virsh pool-info output for the volume group. Although that's even true prior to these patches since the thin data is not displayed in the vol-list output, but is accounted for in the pool-info output, thus the sum of the vol-list capacity details are less.
As stated above. The pool was manipulated outside of libvirt with features that are not (yet) supported. I don't see a reason to cram this stuff into the existing logical pool support.
Agreed, our goal is only really to report on stuff that libvirt was capable of creating in the first place, otherwise the problemspace becomes unmanagably huge IMHO. Also we need to be wary of cramming in too many highly LVM specific features - we need to try and represent them in a platform/technology agnostic manner whereever possible. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 02/05/2016 06:33 AM, Daniel P. Berrange wrote:
On Fri, Feb 05, 2016 at 12:07:40PM +0100, Peter Krempa wrote:
On Thu, Feb 04, 2016 at 20:40:46 -0500, John Ferlan wrote:
While I know not the preferred mechanism for Jan, these patches provide a means to display thin lv data from a volume group including the source thin-pool name and thin-pool capacity. Since a thin-pool and a thin lv are just members of the vg, it just feels natural to display whatever is in the volume group because a logical pool comprises all the volumes within the vg.
You could do a similar claim for volume groups or even directories belonging to a 'disk' type pool since they reside on the partition managed by such pool.
Even if not accepted, some concepts can be used as a bases for a single thin-pool to libvirt pool relationship.
The thin volumes and pools have to be manualy manipulated into the volume group that is used as backing for the libvirt 'logical' storage pool since the API does not support building a thin pool backing volume.
From this point looking at libvirt APIs it's more natural to have the LVM thin pool as a regular libvirt storage pool as you implicitly get the APIs for building the pool, for getting sizes and other things.
There are no changes to virsh vol-list --details or virsh vol-info to display the thin-pool capacity. If one self adds all the capacity
Obviously as it fits better into 'virsh pool-list --details'.
values in the vol-list --details display, they will determine that the sum is larger than the virsh pool-info output for the volume group. Although that's even true prior to these patches since the thin data is not displayed in the vol-list output, but is accounted for in the pool-info output, thus the sum of the vol-list capacity details are less.
As stated above. The pool was manipulated outside of libvirt with features that are not (yet) supported. I don't see a reason to cram this stuff into the existing logical pool support.
Agreed, our goal is only really to report on stuff that libvirt was capable of creating in the first place, otherwise the problemspace becomes unmanagably huge IMHO. Also we need to be wary of cramming in too many highly LVM specific features - we need to try and represent them in a platform/technology agnostic manner whereever possible.
libvirt cannot create mirror, stripe, raid* lvm segtypes, but we can report on those lv's in the pool because each displays data in the 'devices' output. The only reason we don't report on thin lv's is because they have no listed devices. If the last patch had just noted to display lv devices regardless of whether they had a device listed and not mentioning specifically that these were lv thin devices, I wonder now if that would have not raised any questions ;-)... John FWIW: While poking around - I found there are examples of using a /dev/$vgname/$lvthindevice directly rather than using them from a pool.
participants (4)
-
Daniel P. Berrange
-
John Ferlan
-
Ján Tomko
-
Peter Krempa