The attached patch adjusts for a difference in behavior in the LVM
utilities 'lvs' and 'vgs'.  The SLES10-SP2 versions of these (and
presumably others) append a trailing separator.  This patch simply
adjusts the regexps to allow (but not require) this.

I thought just adding the ":?" to the regexps would do this, but this
was leaving the trailing separator in the last group match, so I ended
up tweaking the preceding group pattern as well.

Dave

commit 021470f5cfa0e770f09c73cf8a2fc270121378f6
Author: David Lively <[EMAIL PROTECTED]>
Date:   Mon Jul 28 15:05:30 2008 -0400

    Some distros' (e.g. SLES10-SP2) lvm utilities (lvs, vgs) put the specified
    separator at the end of each input line.  Adjusted the regexes used by the
    logical storage backend to allow this.
    
    Signed-off-by: David Lively <[EMAIL PROTECTED]>

diff --git a/src/storage_backend_logical.c b/src/storage_backend_logical.c
index 674a74f..52e645b 100644
--- a/src/storage_backend_logical.c
+++ b/src/storage_backend_logical.c
@@ -201,9 +201,11 @@ virStorageBackendLogicalFindLVs(virConnectPtr conn,
      * Pull out name & uuid, device, device extent start #, segment size, extent size.
      *
      * 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
      */
     const char *regexes[] = {
-        "^\\s*(\\S+):(\\S+):(\\S+)\\((\\S+)\\):(\\S+):(\\S+)\\s*$"
+        "^\\s*(\\S+):(\\S+):(\\S+)\\((\\S+)\\):(\\S+):([0-9]+):?\\s*$"
     };
     int vars[] = {
         6
@@ -442,9 +444,11 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn,
      *    10603200512:4328521728
      *
      * Pull out size & free
+     *
+     * NB vgs from some distros (e.g. SLES10 SP2) outputs trailing ":" on each line
      */
     const char *regexes[] = {
-        "^\\s*(\\S+):(\\S+)\\s*$"
+        "^\\s*(\\S+):([0-9]+):?\\s*$"
     };
     int vars[] = {
         2
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to