[PATCH] storage: Do not use comma as seperator for lvs output

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

 



* src/storage/storage_backend_logical.c:

If a logical vol is created with multiple stripes. (e.g. --stripes 3),
the "device" field of lvs output will have multiple fileds which are
seperated by comma. It means the RE we write in the codes will not
work well anymore. E.g. (lvs output for a stripped vol, uses "#" as
seperator here):

test_stripes##fSLSZH-zAS2-yAIb-n4mV-Al9u-HA3V-oo9K1B#\
/dev/sdc1(10240),/dev/sdd1(0)#42949672960#4194304

The RE we uses:

    const char *regexes[] = {
        "^\\s*(\\S+),(\\S*),(\\S+),(\\S+)\\((\\S+)\\),(\\S+),([0-9]+),?\\s*$"
    };

This patch changes the seperator into "#" to fix the problem.

Related RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=727474
---
 src/storage/storage_backend_logical.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
index 4f42047..45f77ad 100644
--- a/src/storage/storage_backend_logical.c
+++ b/src/storage/storage_backend_logical.c
@@ -187,19 +187,20 @@ virStorageBackendLogicalFindLVs(virStoragePoolObjPtr pool,
      *
      * NB can be multiple rows per volume if they have many extents
      *
-     * NB lvs from some distros (e.g. SLES10 SP2) outputs trailing "," on each line
+     * NB lvs from some distros (e.g. SLES10 SP2) outputs trailing
+     * @separator on each line
      *
      * NB Encrypted logical volumes can print ':' in their name, so it is
      *    not a suitable separator (rhbz 470693).
      */
     const char *regexes[] = {
-        "^\\s*(\\S+),(\\S*),(\\S+),(\\S+)\\((\\S+)\\),(\\S+),([0-9]+),?\\s*$"
+        "^\\s*(\\S+)#(\\S*)#(\\S+)#(\\S+)\\((\\S+)\\)#(\\S+)#([0-9]+)#?\\s*$"
     };
     int vars[] = {
         7
     };
     const char *prog[] = {
-        LVS, "--separator", ",", "--noheadings", "--units", "b",
+        LVS, "--separator", "#", "--noheadings", "--units", "b",
         "--unbuffered", "--nosuffix", "--options",
         "lv_name,origin,uuid,devices,seg_size,vg_extent_size",
         pool->def->source.name, NULL
-- 
1.7.6

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