[PATCH v2 5/6] 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 display at the name of
the thin-pool name. This is done by adding 'pool_lv' to the list of
regex's and then when a "thin" lv is found, storing that pool name.

The result will end up being the following for a vol-dumpxml:

  <source>
    <name>thinpool_test_thin</name>
  </source>

instead of an empty <source> </source> pair.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 docs/formatstorage.html.in            |  9 +++++++--
 src/storage/storage_backend_logical.c | 26 ++++++++++++++++----------
 2 files changed, 23 insertions(+), 12 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 a9c6309..b866648 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -239,6 +239,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[9]) < 0)
+            goto cleanup;
+    }
+
     if (virStrToLong_ull(groups[7], NULL, 10, &vol->target.allocation) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("malformed volume allocation value"));
@@ -266,14 +271,15 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
 {
     /*
      * # lvs --separator # --noheadings --units b --unbuffered --nosuffix --options \
-     * "lv_name,origin,uuid,devices,segtype,seg_size,vg_extent_size,size,lv_attr" VGNAME
+     * "lv_name,origin,uuid,devices,segtype,seg_size,vg_extent_size,size,lv_attr,pool_lv" VGNAME
      *
-     * RootLV##06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky#/dev/hda2(0)#linear#5234491392#33554432#5234491392#-wi-ao
-     * SwapLV##oHviCK-8Ik0-paqS-V20c-nkhY-Bm1e-zgzU0M#/dev/hda2(156)#linear#1040187392#33554432#1040187392#-wi-ao
-     * Test2##3pg3he-mQsA-5Sui-h0i6-HNmc-Cz7W-QSndcR#/dev/hda2(219)#linear#1073741824#33554432#1073741824#owi-a-
-     * Test3##UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(251)#linear#2181038080#33554432#2181038080#-wi-a-
-     * Test3#Test2#UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(187)#linear#1040187392#33554432#1040187392#swi-a-
-     * test_stripes##fSLSZH-zAS2-yAIb-n4mV-Al9u-HA3V-oo9K1B#/dev/sdc1(10240),/dev/sdd1(0)#striped#42949672960#4194304#-wi-a-
+     * RootLV##06UgP5-2rhb-w3Bo-3mdR-WeoL-pytO-SAa2ky#/dev/hda2(0)#linear#5234491392#33554432#5234491392#-wi-ao#
+     * SwapLV##oHviCK-8Ik0-paqS-V20c-nkhY-Bm1e-zgzU0M#/dev/hda2(156)#linear#1040187392#33554432#1040187392#-wi-ao#
+     * Test2##3pg3he-mQsA-5Sui-h0i6-HNmc-Cz7W-QSndcR#/dev/hda2(219)#linear#1073741824#33554432#1073741824#owi-a-#
+     * Test3##UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(251)#linear#2181038080#33554432#2181038080#-wi-a-#
+     * Test3#Test2#UB5hFw-kmlm-LSoX-EI1t-ioVd-h7GL-M0W8Ht#/dev/hda2(187)#linear#1040187392#33554432#1040187392#swi-a-#
+     * test_stripes##fSLSZH-zAS2-yAIb-n4mV-Al9u-HA3V-oo9K1B#/dev/sdc1(10240),/dev/sdd1(0)#striped#42949672960#4194304#-wi-a-#
+     * test_thin##9cdaL5-qEyd-pbRn-Ef2B-uU81-WSIE-XUY973##thin#41943040#4194304#41943040#Vwi-a-tz--#thinpool_test_thin
      *
      * Pull out name, origin, & uuid, device, device extent start #,
      * segment size, extent size, size, attrs
@@ -290,10 +296,10 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
      *    striped, so "," is not a suitable separator either (rhbz 727474).
      */
     const char *regexes[] = {
-       "^\\s*(\\S+)#(\\S*)#(\\S+)#(\\S+)#(\\S+)#(\\S+)#([0-9]+)#([0-9]+)#(\\S+)#?\\s*$"
+       "^\\s*(\\S+)#(\\S*)#(\\S+)#(\\S+)#(\\S+)#(\\S+)#([0-9]+)#([0-9]+)#(\\S+)#(\\S*)#?\\s*$"
     };
     int vars[] = {
-        9
+        10
     };
     int ret = -1;
     virCommandPtr cmd;
@@ -309,7 +315,7 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
                                "--unbuffered",
                                "--nosuffix",
                                "--options",
-                               "lv_name,origin,uuid,devices,segtype,seg_size,vg_extent_size,size,lv_attr",
+                               "lv_name,origin,uuid,devices,segtype,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]