[PATCH RFC 2/3] util: Introduce virFileCacheForEach

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

 



Add an API to allow traversing each of the file cache elements
and invoking a virHashIterator callback function for each element.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virfilecache.c  | 24 ++++++++++++++++++++++++
 src/util/virfilecache.h  |  5 +++++
 3 files changed, 30 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2343a757c1..d59126c83f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1882,6 +1882,7 @@ virFindFileInPath;
 
 
 # util/virfilecache.h
+virFileCacheForEach;
 virFileCacheGetPriv;
 virFileCacheInsertData;
 virFileCacheLookup;
diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c
index 15c0d99fd9..cb7580e11a 100644
--- a/src/util/virfilecache.c
+++ b/src/util/virfilecache.c
@@ -349,6 +349,30 @@ virFileCacheLookupByFunc(virFileCachePtr cache,
 }
 
 
+/**
+ * virFileCacheForEach
+ * @cache: existing cache object
+ * @iter: an iterator to process each data
+ * @opaque: opaque data to pass to the iterator
+ *
+ * For each element in the file cache, run the @iter which uses
+ * @virHashIterator arguments with @opaque data.
+ */
+int
+virFileCacheForEach(virFileCachePtr cache,
+                    virHashIterator iter,
+                    void *opaque)
+{
+    int ret;
+
+    virObjectLock(cache);
+    ret = virHashForEach(cache->table, iter, opaque);
+    virObjectUnlock(cache);
+
+    return ret;
+}
+
+
 /**
  * virFileCacheGetPriv:
  * @cache: existing cache object
diff --git a/src/util/virfilecache.h b/src/util/virfilecache.h
index af6a189d7f..44b766153e 100644
--- a/src/util/virfilecache.h
+++ b/src/util/virfilecache.h
@@ -122,6 +122,11 @@ virFileCacheLookupByFunc(virFileCachePtr cache,
                          virHashSearcher iter,
                          const void *iterData);
 
+int
+virFileCacheForEach(virFileCachePtr cache,
+                    virHashIterator iter,
+                    void *opaque);
+
 void *
 virFileCacheGetPriv(virFileCachePtr cache);
 
-- 
2.17.2

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

  Powered by Linux