[PATCH 2/4] logical: Add capability to get the thin pool name

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

 



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

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