[Libguestfs] [PATCH 1/5] daemon: lvm-filter: set also global_filter

Pino Toscano ptoscano at redhat.com
Tue Jul 26 15:41:25 UTC 2016


When editing the lvm configuration to set the LVM filter, edit the
'global_filter' key in addition to 'filter': the latter is not used when
lvmetad is running, when only the former works.
---
 daemon/lvm-filter.c | 30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/daemon/lvm-filter.c b/daemon/lvm-filter.c
index 44045b3..8629aab 100644
--- a/daemon/lvm-filter.c
+++ b/daemon/lvm-filter.c
@@ -148,7 +148,12 @@ set_filter (char *const *filters)
   /* Remove all the old filters ... */
   r = aug_rm (aug, "/files/lvm/lvm.conf/devices/dict/filter/list/*");
   if (r == -1) {
-    AUGEAS_ERROR ("aug_rm");
+    AUGEAS_ERROR ("aug_rm/filter");
+    return -1;
+  }
+  r = aug_rm (aug, "/files/lvm/lvm.conf/devices/dict/global_filter/list/*");
+  if (r == -1) {
+    AUGEAS_ERROR ("aug_rm/global_filter");
     return -1;
   }
 
@@ -161,7 +166,16 @@ set_filter (char *const *filters)
               count + 1);
 
     if (aug_set (aug, buf, filters[count]) == -1) {
-      AUGEAS_ERROR ("aug_set: %d: %s", count, filters[count]);
+      AUGEAS_ERROR ("aug_set/filter: %d: %s", count, filters[count]);
+      return -1;
+    }
+
+    snprintf (buf, sizeof buf,
+              "/files/lvm/lvm.conf/devices/dict/global_filter/list/%d/str",
+              count + 1);
+
+    if (aug_set (aug, buf, filters[count]) == -1) {
+      AUGEAS_ERROR ("aug_set/global_filter: %d: %s", count, filters[count]);
       return -1;
     }
   }
@@ -170,13 +184,23 @@ set_filter (char *const *filters)
   r = aug_match (aug, "/files/lvm/lvm.conf/devices/dict/filter/list/*/str",
                  NULL);
   if (r == -1) {
-    AUGEAS_ERROR ("aug_match");
+    AUGEAS_ERROR ("aug_match/filter");
     return -1;
   }
   if (r != count) {
     reply_with_error ("filters# vs matches mismatch: %d vs %d", count, r);
     return -1;
   }
+  r = aug_match (aug, "/files/lvm/lvm.conf/devices/dict/global_filter/list/*/str",
+                 NULL);
+  if (r == -1) {
+    AUGEAS_ERROR ("aug_match/global_filter");
+    return -1;
+  }
+  if (r != count) {
+    reply_with_error ("global_filter# vs matches mismatch: %d vs %d", count, r);
+    return -1;
+  }
 
   if (aug_save (aug) == -1) {
     AUGEAS_ERROR ("aug_save");
-- 
2.7.4




More information about the Libguestfs mailing list